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