Merge "[GENERAL] Print helm binary used"
[oom.git] / kubernetes / sdnc / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2020 Samsung Electronics
3 # Copyright © 2017 Amdocs, Bell Canada
4 # Copyright © 2021 Nokia
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 */}}
18
19 apiVersion: apps/v1
20 kind: StatefulSet
21 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
22 spec:
23   selector:
24     matchLabels:
25       app: {{ include "common.name" . }}
26   serviceName: {{ include "common.servicename" . }}-cluster
27   replicas: {{ .Values.replicaCount }}
28   selector: {{- include "common.selectors" . | nindent 4 }}
29   podManagementPolicy: Parallel
30   template:
31     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
32     spec:
33       initContainers:
34       - command:
35         - sh
36         args:
37         - -c
38         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
39         env:
40         - name: AAI_CLIENT_NAME
41           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "login") | indent 10 }}
42         - name: AAI_CLIENT_PASSWORD
43           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "password") | indent 10 }}
44         - name: MODELSERVICE_USER
45           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "login") | indent 10 }}
46         - name: MODELSERVICE_PASSWORD
47           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "password") | indent 10 }}
48         - name: RESTCONF_USER
49           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "login") | indent 10 }}
50         - name: RESTCONF_PASSWORD
51           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "password") | indent 10 }}
52         - name: ANSIBLE_USER
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "login") | indent 10 }}
54         - name: ANSIBLE_PASSWORD
55           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "password") | indent 10 }}
56         - name: SCALEOUT_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "login") | indent 10 }}
58         - name: SCALEOUT_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "password") | indent 10 }}
60         - name: NETBOX_APIKEY
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "netbox-apikey" "key" "password") | indent 10 }}
62         - name: SDNC_DB_USER
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
64         - name: SDNC_DB_PASSWORD
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
66         - name: ODL_ADMIN_USERNAME
67           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 10 }}
68         - name: ODL_ADMIN_PASSWORD
69           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 10 }}
70         {{ if and .Values.config.sdnr.dmaapProxy.enabled  .Values.config.sdnr.dmaapProxy.usepwd }}
71         - name: DMAAP_HTTP_PROXY_USERNAME
72           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "dmaap-proxy-creds" "key" "login") | indent 10 }}
73         - name: DMAAP_HTTP_PROXY_PASSWORD
74           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "dmaap-proxy-creds" "key" "password") | indent 10 }}
75         {{- end }}
76
77
78         volumeMounts:
79         - mountPath: /config-input
80           name: config-input
81         - mountPath: /config
82           name: properties
83         image: {{ include "repositoryGenerator.image.envsubst" . }}
84         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
85         name: {{ include "common.name" . }}-update-config
86       {{ if .Values.dgbuilder.enabled -}}
87       - command:
88         - /app/ready.py
89         args:
90         {{ if or .Values.dgbuilder.enabled .Values.config.sdnr.enabled -}}
91         - --container-name
92         - {{ include "common.mariadbService" . }}
93         {{ end -}}
94         {{ if .Values.config.sdnr.enabled -}}
95         - --container-name
96         - {{ include "common.name" . }}-sdnrdb-init-job
97         {{ end -}}
98         env:
99         - name: NAMESPACE
100           valueFrom:
101             fieldRef:
102               apiVersion: v1
103               fieldPath: metadata.namespace
104         image: {{ include "repositoryGenerator.image.readiness" . }}
105         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
106         name: {{ include "common.name" . }}-readiness
107         {{ end -}}
108 {{ include "common.certInitializer.initContainer" . | indent 6 }}
109 {{ include "common.certServiceClient.initContainer" . | indent 6 }}
110       - name: {{ include "common.name" . }}-chown
111         image: {{ include "repositoryGenerator.image.busybox" . }}
112         command:
113         - sh
114         args:
115         - -c
116         - |
117            mkdir {{ .Values.persistence.mdsalPath }}/journal
118            mkdir {{ .Values.persistence.mdsalPath }}/snapshots
119            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}
120 {{- if .Values.global.aafEnabled }}
121            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}
122 {{- end }}
123         volumeMounts:
124 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
125           - mountPath: {{ .Values.persistence.mdsalPath }}
126             name: {{ include "common.fullname" . }}-data
127       containers:
128         - name: {{ include "common.name" . }}
129           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
130           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
131           {{- if and .Values.global.cmpv2Enabled .Values.global.CMPv2CertManagerIntegration }}
132           {{- $linkCommand := include "common.certManager.linkVolumeMounts" . }}
133           lifecycle:
134             postStart:
135               exec:
136                 command: ["sh", "-c", {{$linkCommand | quote}} ]
137           {{- end }}
138           command: ["/bin/bash"]
139           args: ["-c", "/opt/onap/sdnc/bin/createLinks.sh ; /opt/onap/sdnc/bin/startODL.sh"]
140           ports:
141           - containerPort: {{ .Values.service.internalPort }}
142           - containerPort: {{ .Values.service.internalPort2 }}
143           - containerPort: {{ .Values.service.internalPort3 }}
144           - containerPort: {{ .Values.service.clusterPort }}
145           readinessProbe:
146             tcpSocket:
147               port: {{ .Values.service.internalPort }}
148             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
149             periodSeconds: {{ .Values.readiness.periodSeconds }}
150           env:
151           - name: MYSQL_ROOT_PASSWORD
152             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
153           - name: ODL_ADMIN_USERNAME
154             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
155           - name: ODL_ADMIN_PASSWORD
156             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
157           - name: SDNC_DB_USER
158             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
159           - name: SDNC_DB_PASSWORD
160             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
161           - name: SDNC_CONFIG_DIR
162             value: "{{ .Values.config.configDir }}"
163           - name: ENABLE_ODL_CLUSTER
164             value: "{{ .Values.config.enableClustering }}"
165           - name: MY_ODL_CLUSTER
166             value: "{{ .Values.config.myODLCluster }}"
167           - name: PEER_ODL_CLUSTER
168             value: "{{ .Values.config.peerODLCluster }}"
169           - name: IS_PRIMARY_CLUSTER
170             value: "{{ .Values.config.isPrimaryCluster }}"
171           - name: GEO_ENABLED
172             value: "{{ .Values.config.geoEnabled}}"
173           - name: SDNC_AAF_ENABLED
174             value: "{{ .Values.global.aafEnabled}}"
175           - name: SDNC_REPLICAS
176             value: "{{ .Values.replicaCount }}"
177           - name: MYSQL_HOST
178             value: {{ include "common.mariadbService" . }}
179           - name: MDSAL_PATH
180             value: {{ .Values.persistence.mdsalPath }}
181           - name: DAEXIM_PATH
182             value: {{ .Values.persistence.daeximPath }}
183           - name: JOURNAL_PATH
184             value: {{ .Values.persistence.journalPath }}
185           - name: SNAPSHOTS_PATH
186             value: {{ .Values.persistence.snapshotsPath }}
187           - name: JAVA_HOME
188             value: "{{ .Values.config.javaHome}}"
189           - name: JAVA_OPTS
190             value: "-Xms{{.Values.config.odl.javaOptions.minMemory}} -Xmx{{.Values.config.odl.javaOptions.maxMemory}}"
191           - name: KARAF_CONSOLE_LOG_LEVEL
192             value: "{{ include "common.log.level" . }}"
193           - name: SDNRWT
194             value: "{{ .Values.config.sdnr.enabled | default "false"}}"
195           {{- if eq .Values.config.sdnr.mode "web" }}
196           - name: SDNRDM
197             value: "true"
198           {{- end }}
199           - name: SDNRONLY
200             value: "{{ .Values.config.sdnr.sdnronly | default "false" }}"
201           - name: SDNRDBURL
202             {{- $prefix := ternary "https" "http" .Values.global.aafEnabled}}
203             value: "{{$prefix}}://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
204           {{- if .Values.config.sdnr.sdnrdbTrustAllCerts }}
205           - name: SDNRDBTRUSTALLCERTS
206             value: "true"
207           {{- end }}
208           {{- if .Values.global.cmpv2Enabled }}
209           - name: ODL_CERT_DIR
210             value: {{ (mustFirst (.Values.certificates)).mountPath }}
211           {{- end }}
212
213           volumeMounts:
214 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
215 {{ include "common.certServiceClient.volumeMounts" . | indent 10 }}
216 {{- if and .Values.global.cmpv2Enabled .Values.global.CMPv2CertManagerIntegration }}
217 {{ include "common.certManager.volumeMounts" . | indent 10 }}
218 {{- end }}
219           - mountPath: /etc/localtime
220             name: localtime
221             readOnly: true
222           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
223             name: sdnc-logging-cfg-config
224             subPath: org.ops4j.pax.logging.cfg
225           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
226             name: bin
227             subPath: installSdncDb.sh
228           - mountPath: {{ .Values.config.binDir }}/createLinks.sh
229             name: bin
230             subPath: createLinks.sh
231           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
232             name: properties
233             subPath: aaiclient.properties
234           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
235             name: properties
236             subPath: aaiclient.properties
237           - mountPath: {{ .Values.config.configDir }}/dblib.properties
238             name: properties
239             subPath: dblib.properties
240           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
241             name: properties
242             subPath: lcm-dg.properties
243           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
244             name: properties
245             subPath: svclogic.properties
246           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
247             name: properties
248             subPath: svclogic.properties
249           - mountPath: {{ .Values.config.configDir }}/netbox.properties
250             name: properties
251             subPath: netbox.properties
252           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
253             name: properties
254             subPath: blueprints-processor-adaptor.properties
255           - mountPath: {{ .Values.persistence.mdsalPath }}
256             name: {{ include "common.fullname" . }}-data
257           - mountPath: /var/log/onap
258             name: logs
259           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
260             name: properties
261             subPath: akka.conf
262           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
263             name: properties
264             subPath: org.opendaylight.controller.cluster.datastore.cfg
265           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.aaa.filterchain.cfg
266             name: properties
267             subPath: org.opendaylight.aaa.filterchain.cfg
268           - mountPath: {{ .Values.config.odl.binDir }}/setenv
269             name: properties
270             subPath: setenv
271           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-registrar.properties
272             name: properties
273             subPath: mountpoint-registrar.properties
274           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-state-provider.properties
275             name: properties
276             subPath: mountpoint-state-provider.properties
277           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.daexim.cfg
278             name: properties
279             subPath: org.opendaylight.daexim.cfg
280           resources:
281 {{ include "common.resources" . | indent 12 }}
282         {{- if .Values.nodeSelector }}
283         nodeSelector:
284 {{ toYaml .Values.nodeSelector | indent 10 }}
285         {{- end -}}
286         {{- if .Values.affinity }}
287         affinity:
288 {{ toYaml .Values.affinity | indent 10 }}
289         {{- end }}
290
291         # side car containers
292         - name: filebeat-onap
293           image: {{ include "repositoryGenerator.image.logging" . }}
294           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
295           volumeMounts:
296           - mountPath: /usr/share/filebeat/filebeat.yml
297             name: filebeat-conf
298             subPath: filebeat.yml
299           - mountPath: /var/log/onap
300             name: logs
301           - mountPath: /usr/share/filebeat/data
302             name: data-filebeat
303       imagePullSecrets:
304       - name: "{{ include "common.namespace" . }}-docker-registry-key"
305       volumes:
306         - name: localtime
307           hostPath:
308             path: /etc/localtime
309         - name: logs
310           emptyDir: {}
311         - name: data-filebeat
312           emptyDir: {}
313         - name: filebeat-conf
314           configMap:
315             name: {{ include "common.fullname" . }}-filebeat-configmap
316         - name: sdnc-logging-cfg-config
317           configMap:
318             name: {{ include "common.fullname" . }}-log-configmap
319         - name: bin
320           configMap:
321             name: {{ include "common.fullname" . }}-bin
322             defaultMode: 0755
323         - name: config-input
324           configMap:
325             name: {{ include "common.fullname" . }}-properties
326             defaultMode: 0644
327         - name: properties
328           emptyDir:
329             medium: Memory
330   {{ if not .Values.persistence.enabled }}
331         - name: {{ include "common.fullname" . }}-data
332           emptyDir: {}
333   {{ else }}
334 {{ include "common.certInitializer.volumes" . | nindent 8 }}
335 {{ include "common.certServiceClient.volumes" . | nindent 8 }}
336 {{- if and .Values.global.cmpv2Enabled .Values.global.CMPv2CertManagerIntegration }}
337 {{ include "common.certManager.volumes" . | nindent 8 }}
338 {{- end }}
339   volumeClaimTemplates:
340   - metadata:
341       name: {{ include "common.fullname" . }}-data
342       labels:
343         name: {{ include "common.fullname" . }}
344         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
345         release: "{{ include "common.release" . }}"
346         heritage: "{{ .Release.Service }}"
347     spec:
348       accessModes:
349       - {{ .Values.persistence.accessMode }}
350       storageClassName: {{ include "common.storageClass" . }}
351       resources:
352         requests:
353           storage: {{ .Values.persistence.size }}
354   {{- end }}