[DCAEGEN2] Update cm-container and consul-loader
[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 }}/daexim
118            mkdir {{ .Values.persistence.mdsalPath }}/journal
119            mkdir {{ .Values.persistence.mdsalPath }}/snapshots
120            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}
121 {{- if .Values.global.aafEnabled }}
122            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}
123 {{- end }}
124         volumeMounts:
125 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
126           - mountPath: {{ .Values.persistence.mdsalPath }}
127             name: {{ include "common.fullname" . }}-data
128       containers:
129         - name: {{ include "common.name" . }}
130           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
131           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
132           command: ["/bin/bash"]
133           args: ["-c", "/opt/onap/sdnc/bin/createLinks.sh ; /opt/onap/sdnc/bin/startODL.sh"]
134           ports:
135           - containerPort: {{ .Values.service.internalPort }}
136           - containerPort: {{ .Values.service.internalPort2 }}
137           - containerPort: {{ .Values.service.internalPort3 }}
138           - containerPort: {{ .Values.service.clusterPort }}
139           readinessProbe:
140             tcpSocket:
141               port: {{ .Values.service.internalPort }}
142             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
143             periodSeconds: {{ .Values.readiness.periodSeconds }}
144           env:
145           - name: MYSQL_ROOT_PASSWORD
146             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
147           - name: ODL_ADMIN_USERNAME
148             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
149           - name: ODL_ADMIN_PASSWORD
150             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
151           - name: SDNC_DB_USER
152             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
153           - name: SDNC_DB_PASSWORD
154             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
155           - name: SDNC_CONFIG_DIR
156             value: "{{ .Values.config.configDir }}"
157           - name: ENABLE_ODL_CLUSTER
158             value: "{{ .Values.config.enableClustering }}"
159           - name: MY_ODL_CLUSTER
160             value: "{{ .Values.config.myODLCluster }}"
161           - name: PEER_ODL_CLUSTER
162             value: "{{ .Values.config.peerODLCluster }}"
163           - name: IS_PRIMARY_CLUSTER
164             value: "{{ .Values.config.isPrimaryCluster }}"
165           - name: GEO_ENABLED
166             value: "{{ .Values.config.geoEnabled}}"
167           - name: SDNC_AAF_ENABLED
168             value: "{{ .Values.global.aafEnabled}}"
169           - name: SDNC_REPLICAS
170             value: "{{ .Values.replicaCount }}"
171           - name: MYSQL_HOST
172             value: {{ include "common.mariadbService" . }}
173           - name: MDSAL_PATH
174             value: {{ .Values.persistence.mdsalPath }}
175           - name: DAEXIM_PATH
176             value: {{ .Values.persistence.daeximPath }}
177           - name: JOURNAL_PATH
178             value: {{ .Values.persistence.journalPath }}
179           - name: SNAPSHOTS_PATH
180             value: {{ .Values.persistence.snapshotsPath }}
181           - name: JAVA_HOME
182             value: "{{ .Values.config.javaHome}}"
183           - name: JAVA_OPTS
184             value: "-Xms{{.Values.config.odl.javaOptions.minMemory}} -Xmx{{.Values.config.odl.javaOptions.maxMemory}}"
185           - name: KARAF_CONSOLE_LOG_LEVEL
186             value: "{{ include "common.log.level" . }}"
187           - name: SDNRWT
188             value: "{{ .Values.config.sdnr.enabled | default "false"}}"
189           {{- if eq .Values.config.sdnr.mode "web" }}
190           - name: SDNRDM
191             value: "true"
192           {{- end }}
193           - name: SDNRONLY
194             value: "{{ .Values.config.sdnr.sdnronly | default "false" }}"
195           - name: SDNRDBURL
196             {{- $prefix := ternary "https" "http" .Values.global.aafEnabled}}
197             value: "{{$prefix}}://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
198           {{- if .Values.config.sdnr.sdnrdbTrustAllCerts }}
199           - name: SDNRDBTRUSTALLCERTS
200             value: "true"
201           {{ end }}
202
203           volumeMounts:
204 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
205 {{ include "common.certServiceClient.volumeMounts" . | indent 10 }}
206           - mountPath: /etc/localtime
207             name: localtime
208             readOnly: true
209           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
210             name: sdnc-logging-cfg-config
211             subPath: org.ops4j.pax.logging.cfg
212           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
213             name: bin
214             subPath: installSdncDb.sh
215           - mountPath: {{ .Values.config.binDir }}/createLinks.sh
216             name: bin
217             subPath: createLinks.sh
218           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
219             name: properties
220             subPath: aaiclient.properties
221           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
222             name: properties
223             subPath: aaiclient.properties
224           - mountPath: {{ .Values.config.configDir }}/dblib.properties
225             name: properties
226             subPath: dblib.properties
227           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
228             name: properties
229             subPath: lcm-dg.properties
230           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
231             name: properties
232             subPath: svclogic.properties
233           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
234             name: properties
235             subPath: svclogic.properties
236           - mountPath: {{ .Values.config.configDir }}/netbox.properties
237             name: properties
238             subPath: netbox.properties
239           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
240             name: properties
241             subPath: blueprints-processor-adaptor.properties
242           - mountPath: {{ .Values.persistence.mdsalPath }}
243             name: {{ include "common.fullname" . }}-data
244           - mountPath: /var/log/onap
245             name: logs
246           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
247             name: properties
248             subPath: akka.conf
249           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
250             name: properties
251             subPath: org.opendaylight.controller.cluster.datastore.cfg
252           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.aaa.filterchain.cfg
253             name: properties
254             subPath: org.opendaylight.aaa.filterchain.cfg
255           - mountPath: {{ .Values.config.odl.binDir }}/setenv
256             name: properties
257             subPath: setenv
258           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-registrar.properties
259             name: properties
260             subPath: mountpoint-registrar.properties
261           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-state-provider.properties
262             name: properties
263             subPath: mountpoint-state-provider.properties
264           resources:
265 {{ include "common.resources" . | indent 12 }}
266         {{- if .Values.nodeSelector }}
267         nodeSelector:
268 {{ toYaml .Values.nodeSelector | indent 10 }}
269         {{- end -}}
270         {{- if .Values.affinity }}
271         affinity:
272 {{ toYaml .Values.affinity | indent 10 }}
273         {{- end }}
274
275         # side car containers
276         - name: filebeat-onap
277           image: {{ include "repositoryGenerator.image.logging" . }}
278           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
279           volumeMounts:
280           - mountPath: /usr/share/filebeat/filebeat.yml
281             name: filebeat-conf
282             subPath: filebeat.yml
283           - mountPath: /var/log/onap
284             name: logs
285           - mountPath: /usr/share/filebeat/data
286             name: data-filebeat
287       imagePullSecrets:
288       - name: "{{ include "common.namespace" . }}-docker-registry-key"
289       volumes:
290         - name: localtime
291           hostPath:
292             path: /etc/localtime
293         - name: logs
294           emptyDir: {}
295         - name: data-filebeat
296           emptyDir: {}
297         - name: filebeat-conf
298           configMap:
299             name: {{ include "common.fullname" . }}-filebeat-configmap
300         - name: sdnc-logging-cfg-config
301           configMap:
302             name: {{ include "common.fullname" . }}-log-configmap
303         - name: bin
304           configMap:
305             name: {{ include "common.fullname" . }}-bin
306             defaultMode: 0755
307         - name: config-input
308           configMap:
309             name: {{ include "common.fullname" . }}-properties
310             defaultMode: 0644
311         - name: properties
312           emptyDir:
313             medium: Memory
314   {{ if not .Values.persistence.enabled }}
315         - name: {{ include "common.fullname" . }}-data
316           emptyDir: {}
317   {{ else }}
318 {{ include "common.certInitializer.volumes" . | nindent 8 }}
319 {{ include "common.certServiceClient.volumes" . | nindent 8 }}
320   volumeClaimTemplates:
321   - metadata:
322       name: {{ include "common.fullname" . }}-data
323       labels:
324         name: {{ include "common.fullname" . }}
325         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
326         release: "{{ include "common.release" . }}"
327         heritage: "{{ .Release.Service }}"
328     spec:
329       accessModes:
330       - {{ .Values.persistence.accessMode }}
331       storageClassName: {{ include "common.storageClass" . }}
332       resources:
333         requests:
334           storage: {{ .Values.persistence.size }}
335   {{- end }}