CI: Add silent autotools SonarCloud scan
[ric-plt/dbaas.git] / README.md
1 # Database as a service repository
2
3 This repository containes all the needed elements to deploy database as a service to kubernetes
4
5 ## Architecture
6
7 Redis is the chosen database technology and the final product will deploy autonomous
8 redis cluster. Supported deployment options are standalone Redis server and HA
9 (Sentinel) Redis deployment. Either deployment option won't provide data persistency.
10
11 ## Subsystem structure
12
13 **docker** Contains dockerfiles to produce dbaas / testapplication container images
14 **charts** Contais helm charts to deploy dbaas service / testapplication
15 **testapplication** Contains dbaas test applications with various languages such as go, ..
16
17 ## Container image creation
18
19 The images must be built at subsystem root level
20
21 To produce dbaas service image:
22 ```
23 docker build --file docker/Dockerfile.redis --tag redis-standalone .
24 ```
25
26 To produce testapplication image:
27 ```
28 docker build --file docker/Dockerfile.testapp --tag dbaas-test .
29 ```
30
31 ## Deployment
32
33 ### DBaaS service
34
35 Dbaas service is realized either with single container running redis database
36 or with HA deployment implemented by a redis sentinel solution.
37 Standalone dbaas database is configured to be non-persistent and
38 non-redundant. HA dbaas provides redundancy but it is also configured to be
39 non-persistent.
40
41 After dbaas service is installed, environment variables **DBAAS_SERVICE_HOST**,
42 **DBAAS_SERVICE_PORT** and **DBAAS_NODE_COUNT** are exposed to application
43 containers. In the case of HA dbaas deployment also environment variables
44 **DBAAS_MASTER_NAME** and **DBAAS_SERVICE_SENTINEL_PORT** are exposed to
45 application containers. SDL library will automatically use these environment
46 variables.
47
48 The service is installed via helm by using dbaas-service chart. Modify the
49 values accordingly before installation (repository location, image name, ..)
50
51 ```
52 helm install ./dbaas-service
53 ```
54
55 ### SDLCLI
56 There is a pre-installed `sdlcli` tool in DBaaS container. With this tool user
57 can see statistics of database backend (Redis), check healthiness of DBaaS
58 database backend, list database keys and get and set values into database.
59 To get more information about available commands and how to use them, please
60 check help instructions: `sdlcli --help`.
61
62 ### DBaaS test application
63
64 Test application is installed via helm by using dbaas-test chart. Modify the
65 values accordingly before installation (repository location, image name, ..)
66
67 ```
68 helm install ./dbaas-test
69 ```
70
71 ## Testing
72
73 Make sure that dbaas-service and dbaas-test application are deployed:
74 ```
75 >>helm ls
76 NAME            REVISION  UPDATED                    STATUS     CHART                   APP VERSION     NAMESPACE
77 angry-greyhound 1         Thu Mar 21 11:36:23 2019   DEPLOYED   dbaas-test-0.1.0        1.0             default
78 loitering-toad  1         Thu Mar 21 11:35:21 2019   DEPLOYED   dbaas-0.1.0             1.0             default
79 ```
80
81 Check the deployed pods
82 ```
83 >>kubectl get pods
84 NAME                                READY   STATUS    RESTARTS   AGE
85 dbaas-test-app-7695dbb9ff-qn8c2     1/1     Running   0          5s
86 redis-standalone-78978f4c6f-54b2s   1/1     Running   0          66s
87 ```
88
89 Connect to the test application container:
90 ```
91 kubectl exec -it dbaas-test-app-7695dbb9ff-qn8c2 -- /bin/bash
92 ```
93
94 In test application container:
95 ```
96 The environment variables for database backend should be set:
97
98 >>printenv
99 DBAAS_SERVICE_HOST=10.108.103.51
100 DBAAS_SERVICE_PORT=6379
101 DBAAS_NODE_COUNT=1
102
103 Go test application using preliminary go SDL-API should be able to perform reads and writes:
104
105 >>./testapp
106 key1:data1
107 key3:%!s(<nil>)
108 key2:data2
109 num1:1
110 num2:2
111 -------------
112 mix2:2
113 num1:1
114 num2:2
115 pair1:data1
116 array1:adata1
117 mix1:data1
118 mix3:data3
119 mix4:4
120 arr1:
121 key1:data1
122 key2:data2
123 pair2:data2
124 array2:adata2
125
126
127 Redis server can be pinged with redis-cli:
128
129 >>redis-cli -h $DBAAS_SERVICE_HOST -p $DBAAS_SERVICE_PORT ping
130 PONG
131 ```
132
133 ## License
134 This project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details