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