[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / sdnc / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2020 Samsung Electronics, highstreet technologies GmbH
3 # Copyright © 2017 Amdocs, Bell Canada
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
18 apiVersion: apps/v1
19 kind: StatefulSet
20 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
21 spec:
22   selector:
23     matchLabels:
24       app: {{ include "common.name" . }}
25   serviceName: {{ include "common.servicename" . }}-cluster
26   replicas: {{ .Values.replicaCount }}
27   selector: {{- include "common.selectors" . | nindent 4 }}
28   podManagementPolicy: Parallel
29   template:
30     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
31     spec:
32       initContainers:
33       - command:
34         - sh
35         args:
36         - -c
37         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
38         env:
39         - name: AAI_CLIENT_NAME
40           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "login") | indent 10 }}
41         - name: AAI_CLIENT_PASSWORD
42           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "password") | indent 10 }}
43         - name: MODELSERVICE_USER
44           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "login") | indent 10 }}
45         - name: MODELSERVICE_PASSWORD
46           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "password") | indent 10 }}
47         - name: RESTCONF_USER
48           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "login") | indent 10 }}
49         - name: RESTCONF_PASSWORD
50           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "password") | indent 10 }}
51         - name: ANSIBLE_USER
52           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "login") | indent 10 }}
53         - name: ANSIBLE_PASSWORD
54           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "password") | indent 10 }}
55         - name: SCALEOUT_USER
56           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "login") | indent 10 }}
57         - name: SCALEOUT_PASSWORD
58           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "password") | indent 10 }}
59         - name: NETBOX_APIKEY
60           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "netbox-apikey" "key" "password") | indent 10 }}
61         - name: SDNC_DB_USER
62           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
63         - name: SDNC_DB_PASSWORD
64           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
65         volumeMounts:
66         - mountPath: /config-input
67           name: config-input
68         - mountPath: /config
69           name: properties
70         image: "{{ .Values.global.envsubstImage }}"
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         name: {{ include "common.name" . }}-update-config
73       {{ if .Values.dgbuilder.enabled -}}
74       - command:
75         - /app/ready.py
76         args:
77         {{ if or .Values.dgbuilder.enabled .Values.config.sdnr.enabled -}}
78         - --container-name
79         - {{ include "common.mariadbService" . }}
80         {{ end -}}
81         {{ if .Values.config.sdnr.enabled -}}
82         - --container-name
83         - {{ include "common.name" . }}-sdnrdb-init-job
84         {{ end -}}
85         env:
86         - name: NAMESPACE
87           valueFrom:
88             fieldRef:
89               apiVersion: v1
90               fieldPath: metadata.namespace
91         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
92         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
93         name: {{ include "common.name" . }}-readiness
94         {{ end -}}
95 {{ include "common.certInitializer.initContainer" . | indent 6 }}
96
97       - name: {{ include "common.name" . }}-chown
98         image: "busybox"
99         command:
100         - sh
101         args:
102         - -c
103         - chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}
104 {{- if .Values.global.aafEnabled }}
105         - chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}
106 {{- end }}
107         volumeMounts:
108 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
109           - mountPath: {{ .Values.persistence.mdsalPath }}
110             name: {{ include "common.fullname" . }}-data
111       containers:
112         - name: {{ include "common.name" . }}
113           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
114           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
115           {{- if not .Values.config.sdnr.enabled }}
116           command: ["/bin/bash"]
117           args: ["-c", "/opt/onap/sdnc/bin/startODL.sh"]
118           {{ else }}
119           command: ["/bin/bash"]
120           args: ["-c", "{{ .Values.config.binDir }}/startODL.oom.sh"]
121           {{ end }}
122           ports:
123           - containerPort: {{ .Values.service.internalPort }}
124           - containerPort: {{ .Values.service.internalPort2 }}
125           - containerPort: {{ .Values.service.internalPort3 }}
126           - containerPort: {{ .Values.service.clusterPort }}
127           readinessProbe:
128             tcpSocket:
129               port: {{ .Values.service.internalPort }}
130             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
131             periodSeconds: {{ .Values.readiness.periodSeconds }}
132           env:
133           - name: MYSQL_ROOT_PASSWORD
134             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
135           - name: ODL_ADMIN_USERNAME
136             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
137           - name: ODL_ADMIN_PASSWORD
138             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
139           - name: SDNC_DB_USER
140             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
141           - name: SDNC_DB_PASSWORD
142             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
143           - name: SDNC_CONFIG_DIR
144             value: "{{ .Values.config.configDir }}"
145           - name: ENABLE_ODL_CLUSTER
146             value: "{{ .Values.config.enableClustering }}"
147           - name: MY_ODL_CLUSTER
148             value: "{{ .Values.config.myODLCluster }}"
149           - name: PEER_ODL_CLUSTER
150             value: "{{ .Values.config.peerODLCluster }}"
151           - name: IS_PRIMARY_CLUSTER
152             value: "{{ .Values.config.isPrimaryCluster }}"
153           - name: GEO_ENABLED
154             value: "{{ .Values.config.geoEnabled}}"
155           - name: SDNC_AAF_ENABLED
156             value: "{{ .Values.global.aafEnabled}}"
157           - name: SDNC_REPLICAS
158             value: "{{ .Values.replicaCount }}"
159           - name: MYSQL_HOST
160             value: {{ include "common.mariadbService" . }}
161           - name: JAVA_HOME
162             value: "{{ .Values.config.javaHome}}"
163           - name: KARAF_CONSOLE_LOG_LEVEL
164             value: "{{ include "common.log.level" . }}"
165           - name: SDNRWT
166             value: "{{ .Values.config.sdnr.enabled | default "false"}}"
167           {{- if eq .Values.config.sdnr.mode "web" }}
168           - name: SDNRDM
169             value: "true"
170           {{- end }}
171           - name: SDNRONLY
172             value: "{{ .Values.config.sdnr.sdnronly | default "false" }}"
173           - name: SDNRDBURL
174             {{- $prefix := ternary "https" "http" .Values.global.aafEnabled}}
175             value: "{{$prefix}}://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
176           {{- if .Values.config.sdnr.sdnrdbTrustAllCerts }}
177           - name: SDNRDBTRUSTALLCERTS
178             value: "true"
179           {{ end }}
180
181           volumeMounts:
182 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
183           - mountPath: /etc/localtime
184             name: localtime
185             readOnly: true
186           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
187             name: sdnc-logging-cfg-config
188             subPath: org.ops4j.pax.logging.cfg
189           - mountPath: {{ .Values.config.binDir }}/startODL.sh
190             name: bin
191             subPath: startODL.sh
192           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
193             name: bin
194             subPath: installSdncDb.sh
195           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
196             name: properties
197             subPath: aaiclient.properties
198           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
199             name: properties
200             subPath: aaiclient.properties
201           - mountPath: {{ .Values.config.configDir }}/dblib.properties
202             name: properties
203             subPath: dblib.properties
204           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
205             name: properties
206             subPath: lcm-dg.properties
207           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
208             name: properties
209             subPath: svclogic.properties
210           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
211             name: properties
212             subPath: svclogic.properties
213           - mountPath: {{ .Values.config.configDir }}/netbox.properties
214             name: properties
215             subPath: netbox.properties
216           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
217             name: properties
218             subPath: blueprints-processor-adaptor.properties
219           - mountPath: {{ .Values.persistence.mdsalPath }}
220             name: {{ include "common.fullname" . }}-data
221           - mountPath: /var/log/onap
222             name: logs
223           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
224             name: properties
225             subPath: akka.conf
226           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
227             name: properties
228             subPath: org.opendaylight.controller.cluster.datastore.cfg
229           - mountPath: {{ .Values.config.odl.binDir }}/setenv
230             name: properties
231             subPath: setenv
232           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-registrar.properties
233             name: properties
234             subPath: mountpoint-registrar.properties
235           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-state-provider.properties
236             name: properties
237             subPath: mountpoint-state-provider.properties
238           resources:
239 {{ include "common.resources" . | indent 12 }}
240         {{- if .Values.nodeSelector }}
241         nodeSelector:
242 {{ toYaml .Values.nodeSelector | indent 10 }}
243         {{- end -}}
244         {{- if .Values.affinity }}
245         affinity:
246 {{ toYaml .Values.affinity | indent 10 }}
247         {{- end }}
248
249         # side car containers
250         - name: filebeat-onap
251           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
252           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
253           volumeMounts:
254           - mountPath: /usr/share/filebeat/filebeat.yml
255             name: filebeat-conf
256             subPath: filebeat.yml
257           - mountPath: /var/log/onap
258             name: logs
259           - mountPath: /usr/share/filebeat/data
260             name: data-filebeat
261       imagePullSecrets:
262       - name: "{{ include "common.namespace" . }}-docker-registry-key"
263       volumes:
264         - name: localtime
265           hostPath:
266             path: /etc/localtime
267         - name: logs
268           emptyDir: {}
269         - name: data-filebeat
270           emptyDir: {}
271         - name: filebeat-conf
272           configMap:
273             name: {{ include "common.fullname" . }}-filebeat-configmap
274         - name: sdnc-logging-cfg-config
275           configMap:
276             name: {{ include "common.fullname" . }}-log-configmap
277         - name: bin
278           configMap:
279             name: {{ include "common.fullname" . }}-bin
280             defaultMode: 0755
281         - name: config-input
282           configMap:
283             name: {{ include "common.fullname" . }}-properties
284             defaultMode: 0644
285         - name: properties
286           emptyDir:
287             medium: Memory
288   {{ if not .Values.persistence.enabled }}
289         - name: {{ include "common.fullname" . }}-data
290           emptyDir: {}
291   {{ else }}
292 {{ include "common.certInitializer.volumes" . | nindent 8 }}
293   volumeClaimTemplates:
294   - metadata:
295       name: {{ include "common.fullname" . }}-data
296       labels:
297         name: {{ include "common.fullname" . }}
298         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
299         release: "{{ include "common.release" . }}"
300         heritage: "{{ .Release.Service }}"
301     spec:
302       accessModes:
303       - {{ .Values.persistence.accessMode }}
304       storageClassName: {{ include "common.storageClass" . }}
305       resources:
306         requests:
307           storage: {{ .Values.persistence.size }}
308   {{- end }}