[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / appc / templates / statefulset.yaml
1 # Copyright © 2018  AT&T, Amdocs, Bell Canada Intellectual Property.  All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #       http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 apiVersion: apps/v1
16 kind: StatefulSet
17 metadata:
18   name: {{ include "common.fullname" . }}
19   namespace: {{ include "common.namespace" . }}
20   labels:
21     app: {{ include "common.name" . }}
22     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23     release: {{ include "common.release" . }}
24     heritage: {{ .Release.Service }}
25 spec:
26   selector:
27     matchLabels:
28       app: {{ include "common.name" . }}
29   serviceName: "{{ .Values.service.name }}-cluster"
30   replicas: {{ .Values.replicaCount }}
31   podManagementPolicy: Parallel
32   template:
33     metadata:
34       labels:
35         app: {{ include "common.name" . }}
36         release: {{ include "common.release" . }}
37     spec:
38       initContainers:
39       - command:
40         - sh
41         args:
42         - -c
43         - "cd /config-input && for PFILE in `find . -not -type d | grep -v -F ..`; do envsubst <${PFILE} >/config/${PFILE}; chmod 0755 /config/${PFILE}; done"
44         env:
45         - name: APPC_DB_USER
46           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "login") | indent 10 }}
47         - name: APPC_DB_PASSWD
48           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "password") | indent 10 }}
49         - name: SDNC_DB_USER
50           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "login") | indent 10 }}
51         - name: SDNC_DB_PASSWD
52           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "password") | indent 10 }}
53         volumeMounts:
54         - mountPath: /config-input/appc-data-properties
55           name: onap-appc-data-properties-input
56         - mountPath: /config-input/appc-svclogic-config
57           name: onap-appc-svclogic-config-input
58         - mountPath: /config-input/sdnc-data-properties
59           name: onap-sdnc-data-properties-input
60         - mountPath: /config-input/sdnc-svclogic-config
61           name: onap-sdnc-svclogic-config-input
62         - mountPath: /config/appc-data-properties
63           name: onap-appc-data-properties
64         - mountPath: /config/appc-svclogic-config
65           name: onap-appc-svclogic-config
66         - mountPath: /config/sdnc-data-properties
67           name: onap-sdnc-data-properties
68         - mountPath: /config/sdnc-svclogic-config
69           name: onap-sdnc-svclogic-config
70         image: "{{ .Values.global.envsubstImage }}"
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         name: {{ include "common.name" . }}-update-config
73
74       - name: {{ include "common.name" . }}-readiness
75         command:
76         - /app/ready.py
77         args:
78         - --container-name
79         - {{.Values.config.mariadbGaleraContName}}
80         env:
81         - name: NAMESPACE
82           valueFrom:
83             fieldRef:
84               apiVersion: v1
85               fieldPath: metadata.namespace
86         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
87         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
88       - name: {{ include "common.name" . }}-chown
89         image: "busybox"
90         command: ["sh", "-c", "chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}"]
91         volumeMounts:
92           - mountPath: {{ .Values.persistence.mdsalPath }}
93             name: {{ include "common.fullname" . }}-data
94       containers:
95         - name: {{ include "common.name" . }}
96           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
97           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
98           command:
99           - /opt/appc/bin/startODL.sh
100           ports:
101           - containerPort: {{ .Values.service.internalPort }}
102           - containerPort: {{ .Values.service.externalPort2 }}
103           readinessProbe:
104             tcpSocket:
105                port: {{ .Values.service.internalPort }}
106             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
107             periodSeconds: {{ .Values.readiness.periodSeconds }}
108           env:
109             - name: MYSQL_ROOT_PASSWORD
110               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-pass" "key" "password") | indent 14}}
111             - name: APPC_DB_USER
112               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "login") | indent 14 }}
113             - name: APPC_DB_PASSWD
114               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "password") | indent 14 }}
115             - name: SDNC_DB_USER
116               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "login") | indent 14 }}
117             - name: SDNC_DB_PASSWD
118               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "password") | indent 14 }}
119             - name: SDNC_CONFIG_DIR
120               value: "{{ .Values.config.configDir }}"
121             - name: APPC_CONFIG_DIR
122               value: "{{ .Values.config.configDir }}"
123             - name: DMAAP_TOPIC_ENV
124               value: "{{ .Values.config.dmaapTopic }}"
125             - name: ENABLE_AAF
126               value: "{{ .Values.config.enableAAF }}"
127             - name: ENABLE_ODL_CLUSTER
128               value: "{{ .Values.config.enableClustering }}"
129             - name: APPC_REPLICAS
130               value: "{{ .Values.replicaCount }}"
131           volumeMounts:
132           - mountPath: /etc/localtime
133             name: localtime
134             readOnly: true
135           - mountPath: /opt/onap/appc/data/properties/dblib.properties
136             name: onap-appc-data-properties
137             subPath: dblib.properties
138           - mountPath: /opt/onap/appc/data/properties/svclogic.properties
139             name: onap-appc-data-properties
140             subPath: svclogic.properties
141           - mountPath: /opt/onap/appc/data/properties/appc.properties
142             name: onap-appc-data-properties
143             subPath: appc.properties
144           - mountPath: /opt/onap/appc/data/properties/aaiclient.properties
145             name: onap-appc-data-properties
146             subPath: aaiclient.properties
147           - mountPath: /opt/onap/appc/data/properties/cadi.properties
148             name: onap-appc-data-properties
149             subPath: cadi.properties
150           - mountPath: /opt/onap/appc/data/properties/aaa-app-config.xml
151             name: onap-appc-data-properties-input
152             subPath: aaa-app-config.xml
153           - mountPath: /opt/onap/appc/data/properties/bath_config.csv
154             name: onap-appc-data-properties
155             subPath: bath_config.csv
156           - mountPath: /opt/onap/appc/svclogic/config/svclogic.properties
157             name: onap-appc-svclogic-config
158             subPath: svclogic.properties
159           - mountPath: /opt/onap/appc/svclogic/bin/showActiveGraphs.sh
160             name: onap-appc-svclogic-bin
161             subPath: showActiveGraphs.sh
162           - mountPath: /opt/onap/appc/bin/startODL.sh
163             name: onap-appc-bin
164             subPath: startODL.sh
165           - mountPath: /opt/onap/appc/bin/installAppcDb.sh
166             name: onap-appc-bin
167             subPath: installAppcDb.sh
168           - mountPath: /opt/onap/appc/bin/health_check.sh
169             name: onap-appc-bin
170             subPath: health_check.sh
171           - mountPath: /opt/onap/ccsdk/data/properties/dblib.properties
172             name: onap-sdnc-data-properties
173             subPath: dblib.properties
174           - mountPath: /opt/onap/ccsdk/data/properties/svclogic.properties
175             name: onap-sdnc-data-properties
176             subPath: svclogic.properties
177           - mountPath: /opt/onap/ccsdk/data/properties/aaiclient.properties
178             name: onap-sdnc-data-properties
179             subPath: aaiclient.properties
180           - mountPath: /opt/onap/ccsdk/svclogic/config/svclogic.properties
181             name: onap-sdnc-svclogic-config
182             subPath: svclogic.properties
183           - mountPath: /opt/onap/ccsdk/svclogic/bin/showActiveGraphs.sh
184             name: onap-sdnc-svclogic-bin
185             subPath: showActiveGraphs.sh
186           - mountPath: /opt/onap/ccsdk/bin/installSdncDb.sh
187             name: onap-sdnc-bin
188             subPath: installSdncDb.sh
189           - mountPath: {{ .Values.persistence.mdsalPath }}
190             name: {{ include "common.fullname" . }}-data
191           - mountPath: {{ .Values.log.path }}
192             name: logs
193           - mountPath: /opt/onap/appc/data/org.ops4j.pax.logging.cfg
194             name: log-config
195             subPath: org.ops4j.pax.logging.cfg
196           - mountPath: /opt/onap/appc/data/stores/org.onap.appc.p12
197             name: p12-certs
198             subPath: org.onap.appc.p12
199           - mountPath: /opt/onap/appc/data/stores/org.onap.appc.keyfile
200             name: keyfile-certs
201             subPath: org.onap.appc.keyfile
202           resources:
203 {{ include "common.resources" . | indent 12 }}
204         {{- if .Values.nodeSelector }}
205         nodeSelector:
206 {{ toYaml .Values.nodeSelector | indent 10 }}
207         {{- end -}}
208         {{- if .Values.affinity }}
209         affinity:
210 {{ toYaml .Values.affinity | indent 10 }}
211         {{- end }}
212
213         # side car containers
214         {{ include "common.log.sidecar" . | nindent 8 }}
215       volumes:
216         - name: keyfile-certs
217           secret:
218             secretName: {{ include "common.fullname" . }}-certs
219         - name: p12-certs
220           secret:
221             secretName: {{ include "common.fullname" . }}-certs
222         - name: localtime
223           hostPath:
224             path: /etc/localtime
225         - name: log-config
226           configMap:
227             name: {{ include "common.fullname" . }}-logging-cfg
228         - name: logs
229           emptyDir: {}
230         {{ include "common.log.volumes" . | nindent 8 }}
231         - name: onap-appc-data-properties-input
232           configMap:
233             name: {{ include "common.fullname" . }}-onap-appc-data-properties
234         - name: onap-appc-svclogic-config-input
235           configMap:
236             name: {{ include "common.fullname" . }}-onap-appc-svclogic-config
237         - name: onap-appc-svclogic-bin
238           configMap:
239             name: {{ include "common.fullname" . }}-onap-appc-svclogic-bin
240             defaultMode: 0755
241         - name: onap-appc-bin
242           configMap:
243             name: {{ include "common.fullname" . }}-onap-appc-bin
244             defaultMode: 0755
245         - name: onap-sdnc-data-properties-input
246           configMap:
247             name: {{ include "common.fullname" . }}-onap-sdnc-data-properties
248         - name: onap-sdnc-svclogic-config-input
249           configMap:
250             name: {{ include "common.fullname" . }}-onap-sdnc-svclogic-config
251         - name: onap-sdnc-svclogic-bin
252           configMap:
253             name: {{ include "common.fullname" . }}-onap-sdnc-svclogic-bin
254             defaultMode: 0755
255         - name: onap-sdnc-bin
256           configMap:
257             name: {{ include "common.fullname" . }}-onap-sdnc-bin
258             defaultMode: 0755
259         - name: onap-appc-data-properties
260           emptyDir:
261             medium: Memory
262         - name: onap-appc-svclogic-config
263           emptyDir:
264             medium: Memory
265         - name: onap-sdnc-data-properties
266           emptyDir:
267             medium: Memory
268         - name: onap-sdnc-svclogic-config
269           emptyDir:
270             medium: Memory
271 {{ if not .Values.persistence.enabled }}
272         - name: {{ include "common.fullname" . }}-data
273           emptyDir: {}
274 {{ else }}
275   volumeClaimTemplates:
276   - metadata:
277       name: {{ include "common.fullname" . }}-data
278       labels:
279         name: {{ include "common.fullname" . }}
280         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
281         release: "{{ include "common.release" . }}"
282         heritage: "{{ .Release.Service }}"
283     spec:
284       accessModes:
285       - {{ .Values.persistence.accessMode }}
286       storageClassName: {{ include "common.storageClass" . }}
287       resources:
288         requests:
289           storage: {{ .Values.persistence.size }}
290 {{ end }}