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