Merge "Revert "[SDNC] Change path to daexim directory"" into guilin
[oom.git] / kubernetes / sdnc / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2020 Samsung Electronics
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         - name: ODL_ADMIN_USERNAME
66           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 10 }}
67         - name: ODL_ADMIN_PASSWORD
68           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 10 }}
69
70         volumeMounts:
71         - mountPath: /config-input
72           name: config-input
73         - mountPath: /config
74           name: properties
75         image: "{{ .Values.global.envsubstImage }}"
76         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         name: {{ include "common.name" . }}-update-config
78       {{ if .Values.dgbuilder.enabled -}}
79       - command:
80         - /app/ready.py
81         args:
82         {{ if or .Values.dgbuilder.enabled .Values.config.sdnr.enabled -}}
83         - --container-name
84         - {{ include "common.mariadbService" . }}
85         {{ end -}}
86         {{ if .Values.config.sdnr.enabled -}}
87         - --container-name
88         - {{ include "common.name" . }}-sdnrdb-init-job
89         {{ end -}}
90         env:
91         - name: NAMESPACE
92           valueFrom:
93             fieldRef:
94               apiVersion: v1
95               fieldPath: metadata.namespace
96         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
97         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
98         name: {{ include "common.name" . }}-readiness
99         {{ end -}}
100 {{ include "common.certInitializer.initContainer" . | indent 6 }}
101
102       {{ if .Values.global.cmpv2Enabled }}
103       - name: certs-init
104         image: "{{ .Values.global.repository }}/{{ .Values.global.platform.certServiceClient.image }}"
105         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
106         env:
107           - name: REQUEST_URL
108             value: {{ .Values.global.platform.certServiceClient.envVariables.requestURL }}
109           - name: REQUEST_TIMEOUT
110             value: "30000"
111           - name: OUTPUT_PATH
112             value: {{ .Values.global.platform.certServiceClient.envVariables.cert_path }}
113           - name: CA_NAME
114             value: {{ .Values.global.platform.certServiceClient.envVariables.caName }}
115           - name: COMMON_NAME
116             value: {{ .Values.global.platform.certServiceClient.envVariables.common_name }}
117           - name: ORGANIZATION
118             value: {{ .Values.global.platform.certServiceClient.envVariables.cmpv2Organization }}
119           - name: ORGANIZATION_UNIT
120             value: {{ .Values.global.platform.certServiceClient.envVariables.cmpv2OrganizationalUnit }}
121           - name: LOCATION
122             value: {{ .Values.global.platform.certServiceClient.envVariables.cmpv2Location }}
123           - name: STATE
124             value: {{ .Values.global.platform.certServiceClient.envVariables.cmpv2State }}
125           - name: COUNTRY
126             value: {{ .Values.global.platform.certServiceClient.envVariables.cmpv2Country }}
127           - name: KEYSTORE_PATH
128             value: {{ .Values.global.platform.certServiceClient.envVariables.keystorePath }}
129           - name: KEYSTORE_PASSWORD
130             value: {{ .Values.global.platform.certServiceClient.envVariables.keystorePassword }}
131           - name: TRUSTSTORE_PATH
132             value: {{ .Values.global.platform.certServiceClient.envVariables.truststorePath }}
133           - name: TRUSTSTORE_PASSWORD
134             value: {{ .Values.global.platform.certServiceClient.envVariables.truststorePassword }}
135         terminationMessagePath: /dev/termination-log
136         terminationMessagePolicy: File
137         volumeMounts:
138           - mountPath: {{ .Values.global.platform.certServiceClient.envVariables.cert_path }}
139             name: certs
140           - mountPath: {{ .Values.global.platform.certServiceClient.secret.mountPath }}
141             name: certservice-tls-volume
142       {{ end }}
143
144       - name: {{ include "common.name" . }}-init-files
145         image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.global.busyboxImage | default .Values.busyboxImage }}
146         command:
147         - sh
148         args:
149         - -c
150         - |
151            mkdir {{ .Values.persistence.mdsalPath }}/daexim
152            mkdir {{ .Values.persistence.mdsalPath }}/journal
153            mkdir {{ .Values.persistence.mdsalPath }}/snapshots
154            mkdir {{ .Values.persistence.mdsalPath }}/daexim
155            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}
156 {{- if .Values.global.aafEnabled }}
157            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}
158 {{- end }}
159         volumeMounts:
160 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
161           - mountPath: {{ .Values.persistence.mdsalPath }}
162             name: {{ include "common.fullname" . }}-data
163       containers:
164         - name: {{ include "common.name" . }}
165           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
166           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
167           command: ["/bin/bash"]
168           args: ["-c", "/opt/onap/sdnc/bin/createLinks.sh ; /opt/onap/sdnc/bin/startODL.sh"]
169           ports:
170           - containerPort: {{ .Values.service.internalPort }}
171           - containerPort: {{ .Values.service.internalPort2 }}
172           - containerPort: {{ .Values.service.internalPort3 }}
173           - containerPort: {{ .Values.service.clusterPort }}
174           readinessProbe:
175             tcpSocket:
176               port: {{ .Values.service.internalPort }}
177             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
178             periodSeconds: {{ .Values.readiness.periodSeconds }}
179           env:
180           - name: MYSQL_ROOT_PASSWORD
181             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
182           - name: ODL_ADMIN_USERNAME
183             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
184           - name: ODL_ADMIN_PASSWORD
185             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
186           - name: SDNC_DB_USER
187             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
188           - name: SDNC_DB_PASSWORD
189             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
190           - name: SDNC_CONFIG_DIR
191             value: "{{ .Values.config.configDir }}"
192           - name: ENABLE_ODL_CLUSTER
193             value: "{{ .Values.config.enableClustering }}"
194           - name: MY_ODL_CLUSTER
195             value: "{{ .Values.config.myODLCluster }}"
196           - name: PEER_ODL_CLUSTER
197             value: "{{ .Values.config.peerODLCluster }}"
198           - name: IS_PRIMARY_CLUSTER
199             value: "{{ .Values.config.isPrimaryCluster }}"
200           - name: GEO_ENABLED
201             value: "{{ .Values.config.geoEnabled}}"
202           - name: SDNC_AAF_ENABLED
203             value: "{{ .Values.global.aafEnabled}}"
204           - name: SDNC_REPLICAS
205             value: "{{ .Values.replicaCount }}"
206           - name: MYSQL_HOST
207             value: {{ include "common.mariadbService" . }}
208           - name: MDSAL_PATH
209             value: {{ .Values.persistence.mdsalPath }}
210           - name: DAEXIM_PATH
211             value: {{ .Values.persistence.daeximPath }}
212           - name: JOURNAL_PATH
213             value: {{ .Values.persistence.journalPath }}
214           - name: SNAPSHOTS_PATH
215             value: {{ .Values.persistence.snapshotsPath }}
216           - name: JAVA_HOME
217             value: "{{ .Values.config.javaHome}}"
218           - name: JAVA_OPTS
219             value: "-Xms{{.Values.config.odl.javaOptions.minMemory}} -Xmx{{.Values.config.odl.javaOptions.maxMemory}}"
220           - name: KARAF_CONSOLE_LOG_LEVEL
221             value: "{{ include "common.log.level" . }}"
222           - name: SDNRWT
223             value: "{{ .Values.config.sdnr.enabled | default "false"}}"
224           {{- if eq .Values.config.sdnr.mode "web" }}
225           - name: SDNRDM
226             value: "true"
227           {{- end }}
228           - name: SDNRONLY
229             value: "{{ .Values.config.sdnr.sdnronly | default "false" }}"
230           - name: SDNRDBURL
231             {{- $prefix := ternary "https" "http" .Values.global.aafEnabled}}
232             value: "{{$prefix}}://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
233           {{- if .Values.config.sdnr.sdnrdbTrustAllCerts }}
234           - name: SDNRDBTRUSTALLCERTS
235             value: "true"
236           {{ end }}
237
238           volumeMounts:
239 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
240           - mountPath: /etc/localtime
241             name: localtime
242             readOnly: true
243           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
244             name: sdnc-logging-cfg-config
245             subPath: org.ops4j.pax.logging.cfg
246           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
247             name: bin
248             subPath: installSdncDb.sh
249           - mountPath: {{ .Values.config.binDir }}/createLinks.sh
250             name: bin
251             subPath: createLinks.sh
252           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
253             name: properties
254             subPath: aaiclient.properties
255           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
256             name: properties
257             subPath: aaiclient.properties
258           - mountPath: {{ .Values.config.configDir }}/dblib.properties
259             name: properties
260             subPath: dblib.properties
261           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
262             name: properties
263             subPath: lcm-dg.properties
264           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
265             name: properties
266             subPath: svclogic.properties
267           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
268             name: properties
269             subPath: svclogic.properties
270           - mountPath: {{ .Values.config.configDir }}/netbox.properties
271             name: properties
272             subPath: netbox.properties
273           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
274             name: properties
275             subPath: blueprints-processor-adaptor.properties
276           - mountPath: {{ .Values.persistence.mdsalPath }}
277             name: {{ include "common.fullname" . }}-data
278           - mountPath: /var/log/onap
279             name: logs
280           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
281             name: properties
282             subPath: akka.conf
283           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
284             name: properties
285             subPath: org.opendaylight.controller.cluster.datastore.cfg
286           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.aaa.filterchain.cfg
287             name: properties
288             subPath: org.opendaylight.aaa.filterchain.cfg
289           - mountPath: {{ .Values.config.odl.binDir }}/setenv
290             name: properties
291             subPath: setenv
292           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-registrar.properties
293             name: properties
294             subPath: mountpoint-registrar.properties
295           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-state-provider.properties
296             name: properties
297             subPath: mountpoint-state-provider.properties
298           {{ if .Values.global.cmpv2Enabled }}
299           - mountPath: {{ .Values.global.platform.certServiceClient.envVariables.cert_path }}
300             name: certs
301           {{- end }}
302           resources:
303 {{ include "common.resources" . | indent 12 }}
304         {{- if .Values.nodeSelector }}
305         nodeSelector:
306 {{ toYaml .Values.nodeSelector | indent 10 }}
307         {{- end -}}
308         {{- if .Values.affinity }}
309         affinity:
310 {{ toYaml .Values.affinity | indent 10 }}
311         {{- end }}
312
313         # side car containers
314         - name: filebeat-onap
315           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
316           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
317           volumeMounts:
318           - mountPath: /usr/share/filebeat/filebeat.yml
319             name: filebeat-conf
320             subPath: filebeat.yml
321           - mountPath: /var/log/onap
322             name: logs
323           - mountPath: /usr/share/filebeat/data
324             name: data-filebeat
325       imagePullSecrets:
326       - name: "{{ include "common.namespace" . }}-docker-registry-key"
327       volumes:
328         - name: localtime
329           hostPath:
330             path: /etc/localtime
331         - name: logs
332           emptyDir: {}
333         - name: data-filebeat
334           emptyDir: {}
335         - name: filebeat-conf
336           configMap:
337             name: {{ include "common.fullname" . }}-filebeat-configmap
338         - name: sdnc-logging-cfg-config
339           configMap:
340             name: {{ include "common.fullname" . }}-log-configmap
341         - name: bin
342           configMap:
343             name: {{ include "common.fullname" . }}-bin
344             defaultMode: 0755
345         - name: config-input
346           configMap:
347             name: {{ include "common.fullname" . }}-properties
348             defaultMode: 0644
349         - name: properties
350           emptyDir:
351             medium: Memory
352         {{ if .Values.global.cmpv2Enabled }}
353         - name: certs
354           emptyDir:
355             medium: Memory
356         - name: certservice-tls-volume
357           secret:
358             secretName: {{ .Values.global.platform.certServiceClient.secret.name }}
359         {{- end }}
360   {{ if not .Values.persistence.enabled }}
361         - name: {{ include "common.fullname" . }}-data
362           emptyDir: {}
363   {{ else }}
364 {{ include "common.certInitializer.volumes" . | nindent 8 }}
365   volumeClaimTemplates:
366   - metadata:
367       name: {{ include "common.fullname" . }}-data
368       labels:
369         name: {{ include "common.fullname" . }}
370         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
371         release: "{{ include "common.release" . }}"
372         heritage: "{{ .Release.Service }}"
373     spec:
374       accessModes:
375       - {{ .Values.persistence.accessMode }}
376       storageClassName: {{ include "common.storageClass" . }}
377       resources:
378         requests:
379           storage: {{ .Values.persistence.size }}
380   {{- end }}