Initial commit
[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. In R0 schedule, single, non-redundant, non-persistent redis server is
9 deployed
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 In R0, dbaas service is realized with single container running redis database.
36 The database is configured to be non-persistent and non-redundant. The container
37 exposes single port which is hardcoded to be 6379.
38
39 After dbaas service is installed, environment variables **DBAAS_SERVICE_HOST**
40 and **DBAAS_SERVICE_PORT** are exposed to application containers. SDL library
41 will automatically use these environment variables.
42
43 The service is installed via helm by using dbaas-service chart. Modify the
44 values accordingly before installation (repository location, image name, ..)
45
46 ```
47 helm install ./dbaas-service
48 ```
49
50 ### DBaaS test application
51
52 Test application is installed via helm by using dbaas-test chart. Modify the
53 values accordingly before installation (repository location, image name, ..)
54
55 ```
56 helm install ./dbaas-test
57 ```
58
59 ## Testing
60
61 Make sure that dbaas-service and dbaas-test application are deployed:
62 ```
63 >>helm ls
64 NAME            REVISION  UPDATED                    STATUS     CHART                   APP VERSION     NAMESPACE
65 angry-greyhound 1         Thu Mar 21 11:36:23 2019   DEPLOYED   dbaas-test-0.1.0        1.0             default
66 loitering-toad  1         Thu Mar 21 11:35:21 2019   DEPLOYED   dbaas-0.1.0             1.0             default
67 ```
68
69 Check the deployed pods
70 ```
71 >>kubectl get pods
72 NAME                                READY   STATUS    RESTARTS   AGE
73 dbaas-test-app-7695dbb9ff-qn8c2     1/1     Running   0          5s
74 redis-standalone-78978f4c6f-54b2s   1/1     Running   0          66s
75 ```
76
77 Connect to the test application container:
78 ```
79 kubectl exec -it dbaas-test-app-7695dbb9ff-qn8c2 -- /bin/bash
80 ```
81
82 In test application container:
83 ```
84 The environment variables for database backend should be set:
85
86 >>printenv
87 DBAAS_SERVICE_HOST=10.108.103.51
88 DBAAS_SERVICE_PORT=6379
89
90
91 Go test application using preliminary go SDL-API should be able to perform reads and writes:
92
93 >>./testapp
94 key1:data1
95 key3:%!s(<nil>)
96 key2:data2
97 num1:1
98 num2:2
99 -------------
100 mix2:2
101 num1:1
102 num2:2
103 pair1:data1
104 array1:adata1
105 mix1:data1
106 mix3:data3
107 mix4:4
108 arr1:
109 key1:data1
110 key2:data2
111 pair2:data2
112 array2:adata2
113
114
115 Redis server can be pinged with redis-cli:
116
117 >>redis-cli -h $DBAAS_SERVICE_HOST -p $DBAAS_SERVICE_PORT ping
118 PONG
119 ```
120
121 ## License
122 This project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details