Fix DBAAS helm charts timeout flag
[ric-plt/ric-dep.git] / helm / dbaas / 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.dbaas.image.registry }}
18 ---
19 apiVersion: apps/v1
20 kind: StatefulSet
21 metadata:
22   name: {{ include "common.statefulsetname.dbaas" . }}-server
23   namespace: {{ include "common.namespace.platform" . }}
24   labels:
25     app: {{ include "common.namespace.platform" . }}-{{ include "common.name.dbaas" . }}
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.dbaas" . }}
33       release: {{ .Release.Name }}
34   serviceName: {{ template "common.servicename.dbaas.tcp" . }}
35 {{- if $.Values.dbaas.enableHighAvailability }}
36   replicas: {{ .Values.dbaas.haReplicas }}
37 {{- else }}
38   replicas: {{ .Values.dbaas.saReplicas }}
39 {{- end }}
40   podManagementPolicy: OrderedReady
41   updateStrategy:
42     type: RollingUpdate
43   template:
44     metadata:
45       labels:
46         app: {{ include "common.namespace.platform" . }}-{{ include "common.name.dbaas" . }}
47         release: {{ .Release.Name }}
48     spec:
49 {{- if $.Values.dbaas.enablePodAntiAffinity }}
50       affinity:
51         podAntiAffinity:
52           requiredDuringSchedulingIgnoredDuringExecution:
53             - labelSelector:
54                 matchLabels:
55                   app: {{ include "common.namespace.platform" . }}-{{ include "common.name.dbaas" . }}
56                   release: {{ .Release.Name }}
57               topologyKey: kubernetes.io/hostname
58           preferredDuringSchedulingIgnoredDuringExecution:
59             - weight: 100
60               podAffinityTerm:
61                 labelSelector:
62                   matchLabels:
63                     app: {{ include "common.namespace.platform" . }}-{{ include "common.name.dbaas" . }}
64                     release: {{ .Release.Name }}
65                 topologyKey: topology.kubernetes.io/zone
66 {{- end }}
67       imagePullSecrets:
68         {{- $ctx := dict "ctx" . "defaultregistry" .Values.dbaas.image.registry }}
69         - name: {{ include "common.dockerregistry.credential" $ctx }}
70       terminationGracePeriodSeconds: {{ .Values.dbaas.terminationGracePeriodSeconds }}
71 {{- if $.Values.dbaas.enableHighAvailability }}
72       initContainers:
73       - name: config-init
74         image: {{ include "common.dockerregistry.url" $ctx }}/{{ .Values.dbaas.image.name }}:{{ .Values.dbaas.image.tag }}
75         imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $ctx  }}
76         command:
77         - sh
78         args:
79         - /readonly-config/init.sh
80         env:
81         - name: ANNOUNCE_IP
82           valueFrom:
83             fieldRef:
84               fieldPath: status.podIP
85         volumeMounts:
86         - name: config
87           mountPath: /readonly-config
88           readOnly: true
89         - name: data
90           mountPath: /data
91 {{- end }}
92       shareProcessNamespace: true
93       containers:
94       - name: {{ include "common.containername.dbaas" . }}-redis
95         image: {{ include "common.dockerregistry.url" $ctx }}/{{ .Values.dbaas.image.name }}:{{ .Values.dbaas.image.tag }}
96         imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $ctx  }}
97         command:
98         - redis-server
99         args:
100 {{- if $.Values.dbaas.enableHighAvailability }}
101         - /data/conf/redis.conf
102 {{- else }}
103         - /data/redis.conf
104 {{- end }}
105         livenessProbe:
106           exec:
107             command: 
108             - /bin/sh
109             - -c
110             - {{ .Values.dbaas.probeTimeoutCommand }} {{ .Values.dbaas.probeTimeout }} redis-cli -p {{ include "common.serviceport.dbaas.redis" . }} ping
111           initialDelaySeconds: 15
112           periodSeconds: 5
113         readinessProbe:
114           exec:
115             command: 
116             - /bin/sh
117             - -c
118             - {{ .Values.dbaas.probeTimeoutCommand }} {{ .Values.dbaas.probeTimeout }} redis-cli -p {{ include "common.serviceport.dbaas.redis" . }} ping
119           initialDelaySeconds: 15
120           periodSeconds: 5
121         ports:
122         - name: redis
123           containerPort: {{ include "common.serviceport.dbaas.redis" . }}
124         volumeMounts:
125         - mountPath: /data
126 {{- if $.Values.dbaas.enableHighAvailability }}
127           name: data
128       - name: {{ include "common.containername.dbaas" . }}-sentinel
129         image: {{ include "common.dockerregistry.url" $ctx }}/{{ .Values.dbaas.image.name }}:{{ .Values.dbaas.image.tag }}
130         imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $ctx  }}
131         command:
132           - redis-server
133         args:
134           - /data/conf/sentinel.conf
135           - --sentinel
136         livenessProbe:
137           exec:
138             command: 
139             - /bin/sh
140             - -c
141             - {{ .Values.dbaas.probeTimeoutCommand }} {{ .Values.dbaas.probeTimeout }} redis-cli -p {{ include "common.serviceport.dbaas.redis" . }} ping
142           initialDelaySeconds: 15
143           periodSeconds: 5
144         readinessProbe:
145           exec:
146             command: 
147             - /bin/sh
148             - -c
149             - {{ .Values.dbaas.probeTimeoutCommand }} {{ .Values.dbaas.probeTimeout }} redis-cli -p {{ include "common.serviceport.dbaas.redis" . }} ping
150           initialDelaySeconds: 15
151           periodSeconds: 5
152         ports:
153           - name: sentinel
154             containerPort: {{ include "common.serviceport.dbaas.sentinel" . }}
155         volumeMounts:
156         - mountPath: /data
157           name: data
158 {{- else }}
159           name: config
160 {{- end }}
161       volumes:
162       - name: config
163         configMap:
164           name: {{ template "common.configmapname.dbaas" . }}-config
165 {{- if $.Values.dbaas.enableHighAvailability }}
166       - name: data
167         emptyDir: {}
168 {{- end }}