Merge "Support for dbaas(HA/SA) in deployment"
[ric-plt/ric-dep.git] / helm / dbaasha / templates / statefulset.yaml
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
3 #   Copyright (c) 2019 Nokia.                                                  #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17 {{- $ctx := dict "ctx" . "defaultregistry" .Values.dbaasha.image.registry }}
18 ---
19 apiVersion: apps/v1
20 kind: StatefulSet
21 metadata:
22   name: {{ include "common.statefulsetname.dbaasha" . }}-server
23   namespace: {{ include "common.namespace.platform" . }}
24   labels:
25     app: {{ include "common.namespace.platform" . }}-{{ include "common.name.dbaasha" . }}
26     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
27     release: {{ .Release.Name }}
28     heritage: {{ .Release.Service }}
29 spec:
30   selector:
31     matchLabels:
32       app: {{ include "common.namespace.platform" . }}-{{ include "common.name.dbaasha" . }}
33       release: {{ .Release.Name }}
34   serviceName: {{ template "common.servicename.dbaasha.tcp" . }}
35   replicas: {{ .Values.dbaasha.replicas }}
36   podManagementPolicy: OrderedReady
37   updateStrategy:
38     type: RollingUpdate
39   template:
40     metadata:
41       labels:
42         app: {{ include "common.namespace.platform" . }}-{{ include "common.name.dbaasha" . }}
43         release: {{ .Release.Name }}
44     spec:
45       {{- if .Values.dbaasha.nodeSelector }}
46       nodeSelector:
47 {{ toYaml .Values.dbaasha.nodeSelector | indent 8 }}
48       {{- end }}
49     {{- with .Values.dbaasha.affinity }}
50       affinity:
51 {{ tpl . $ | indent 8 }}
52     {{- end }}
53       imagePullSecrets:
54         {{- $ctx := dict "ctx" . "defaultregistry" .Values.dbaasha.image.registry }}
55         - name: {{ include "common.dockerregistry.credential" $ctx }}
56       initContainers:
57       {{- if .Values.dbaasha.sysctlImage.enabled }}
58       - name: init-systctl
59         image: {{ include "common.dockerregistry.url" $ctx }}/{{ .Values.dbaasha.image.name }}:{{ .Values.dbaasha.image.tag }}
60         imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $ctx  }}
61         {{ if .Values.dbaasha.sysctlImage.mountHostSys }}
62         volumeMounts:
63           - name: host-sys
64             mountPath: /host-sys
65         {{- end }}
66         command:
67 {{ toYaml .Values.dbaasha.sysctlImage.command | indent 10 }}
68         securityContext:
69           runAsNonRoot: false
70           privileged: true
71           runAsUser: 0
72       {{- end }}
73       - name: config-init
74         image: {{ include "common.dockerregistry.url" $ctx }}/{{ .Values.dbaasha.image.name }}:{{ .Values.dbaasha.image.tag }}
75         imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $ctx  }}
76         command:
77         - sh
78         args:
79         - /readonly-config/init.sh
80         volumeMounts:
81         - name: config
82           mountPath: /readonly-config
83           readOnly: true
84         - name: data
85           mountPath: /data
86       containers:
87       - name: {{ include "common.containername.dbaasha.redis" . }}
88         image: {{ include "common.dockerregistry.url" $ctx }}/{{ .Values.dbaasha.image.name }}:{{ .Values.dbaasha.image.tag }}
89         imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $ctx  }}
90         command:
91         - redis-server
92         args:
93         - /data/conf/redis.conf
94         livenessProbe:
95           exec:
96             command: [ "sh", "/probes/readiness.sh", {{ include "common.serviceport.dbaasha.redis" . | quote }}, {{ .Values.dbaasha.probeTimeout | quote }}]
97           initialDelaySeconds: 15
98           periodSeconds: 5
99         readinessProbe:
100           exec:
101             command: [ "sh", "/probes/readiness.sh", {{ include "common.serviceport.dbaasha.redis" . | quote }}, {{ .Values.dbaasha.probeTimeout | quote }}]
102           initialDelaySeconds: 15
103           periodSeconds: 5
104         ports:
105         - name: redis
106           containerPort: {{ include "common.serviceport.dbaasha.redis" . }}
107         volumeMounts:
108         - mountPath: /data
109           name: data
110         - mountPath: /probes
111           name: probes
112       - name: {{ include "common.containername.dbaasha.sentinel" . }}
113         image: {{ include "common.dockerregistry.url" $ctx }}/{{ .Values.dbaasha.image.name }}:{{ .Values.dbaasha.image.tag }}
114         imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $ctx  }}
115         command:
116           - redis-server
117         args:
118           - /data/conf/sentinel.conf
119           - --sentinel
120         livenessProbe:
121           exec:
122             command: [ "sh", "/probes/readiness.sh", {{ include "common.serviceport.dbaasha.redis" . | quote }}, {{ .Values.dbaasha.probeTimeout | quote }}]
123           initialDelaySeconds: 15
124           periodSeconds: 5
125         readinessProbe:
126           exec:
127             command: [ "sh", "/probes/readiness.sh", {{ include "common.serviceport.dbaasha.redis" . | quote }}, {{ .Values.dbaasha.probeTimeout | quote }}]
128           initialDelaySeconds: 15
129           periodSeconds: 5
130         ports:
131           - name: sentinel
132             containerPort: {{ include "common.serviceport.dbaasha.sentinel" . }}
133         volumeMounts:
134         - mountPath: /data
135           name: data
136         - mountPath: /probes
137           name: probes
138       volumes:
139       - name: config
140         configMap:
141           name: {{ template "common.configmapname.dbaasha" . }}-config
142       - name: probes
143         configMap:
144           name: {{ template "common.configmapname.dbaasha" . }}-probes
145       {{- if .Values.dbaasha.sysctlImage.mountHostSys }}
146       - name: host-sys
147         hostPath:
148           path: /sys
149       {{- end }}
150       - name: data
151         emptyDir: {}