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