[COMMON] Add template for CertServiceClient
[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
71         volumeMounts:
72         - mountPath: /config-input
73           name: config-input
74         - mountPath: /config
75           name: properties
76         image: {{ include "repositoryGenerator.image.envsubst" . }}
77         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
78         name: {{ include "common.name" . }}-update-config
79       {{ if .Values.dgbuilder.enabled -}}
80       - command:
81         - /app/ready.py
82         args:
83         {{ if or .Values.dgbuilder.enabled .Values.config.sdnr.enabled -}}
84         - --container-name
85         - {{ include "common.mariadbService" . }}
86         {{ end -}}
87         {{ if .Values.config.sdnr.enabled -}}
88         - --container-name
89         - {{ include "common.name" . }}-sdnrdb-init-job
90         {{ end -}}
91         env:
92         - name: NAMESPACE
93           valueFrom:
94             fieldRef:
95               apiVersion: v1
96               fieldPath: metadata.namespace
97         image: {{ include "repositoryGenerator.image.readiness" . }}
98         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
99         name: {{ include "common.name" . }}-readiness
100         {{ end -}}
101 {{ include "common.certInitializer.initContainer" . | indent 6 }}
102 {{ include "common.certServiceClient.initContainer" . | indent 6 }}
103       - name: {{ include "common.name" . }}-chown
104         image: {{ include "repositoryGenerator.image.busybox" . }}
105         command:
106         - sh
107         args:
108         - -c
109         - |
110            mkdir {{ .Values.persistence.mdsalPath }}/daexim
111            mkdir {{ .Values.persistence.mdsalPath }}/journal
112            mkdir {{ .Values.persistence.mdsalPath }}/snapshots
113            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}
114 {{- if .Values.global.aafEnabled }}
115            chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}
116 {{- end }}
117         volumeMounts:
118 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
119           - mountPath: {{ .Values.persistence.mdsalPath }}
120             name: {{ include "common.fullname" . }}-data
121       containers:
122         - name: {{ include "common.name" . }}
123           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
124           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
125           command: ["/bin/bash"]
126           args: ["-c", "/opt/onap/sdnc/bin/createLinks.sh ; /opt/onap/sdnc/bin/startODL.sh"]
127           ports:
128           - containerPort: {{ .Values.service.internalPort }}
129           - containerPort: {{ .Values.service.internalPort2 }}
130           - containerPort: {{ .Values.service.internalPort3 }}
131           - containerPort: {{ .Values.service.clusterPort }}
132           readinessProbe:
133             tcpSocket:
134               port: {{ .Values.service.internalPort }}
135             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
136             periodSeconds: {{ .Values.readiness.periodSeconds }}
137           env:
138           - name: MYSQL_ROOT_PASSWORD
139             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
140           - name: ODL_ADMIN_USERNAME
141             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
142           - name: ODL_ADMIN_PASSWORD
143             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
144           - name: SDNC_DB_USER
145             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
146           - name: SDNC_DB_PASSWORD
147             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
148           - name: SDNC_CONFIG_DIR
149             value: "{{ .Values.config.configDir }}"
150           - name: ENABLE_ODL_CLUSTER
151             value: "{{ .Values.config.enableClustering }}"
152           - name: MY_ODL_CLUSTER
153             value: "{{ .Values.config.myODLCluster }}"
154           - name: PEER_ODL_CLUSTER
155             value: "{{ .Values.config.peerODLCluster }}"
156           - name: IS_PRIMARY_CLUSTER
157             value: "{{ .Values.config.isPrimaryCluster }}"
158           - name: GEO_ENABLED
159             value: "{{ .Values.config.geoEnabled}}"
160           - name: SDNC_AAF_ENABLED
161             value: "{{ .Values.global.aafEnabled}}"
162           - name: SDNC_REPLICAS
163             value: "{{ .Values.replicaCount }}"
164           - name: MYSQL_HOST
165             value: {{ include "common.mariadbService" . }}
166           - name: MDSAL_PATH
167             value: {{ .Values.persistence.mdsalPath }}
168           - name: DAEXIM_PATH
169             value: {{ .Values.persistence.daeximPath }}
170           - name: JOURNAL_PATH
171             value: {{ .Values.persistence.journalPath }}
172           - name: SNAPSHOTS_PATH
173             value: {{ .Values.persistence.snapshotsPath }}
174           - name: JAVA_HOME
175             value: "{{ .Values.config.javaHome}}"
176           - name: JAVA_OPTS
177             value: "-Xms{{.Values.config.odl.javaOptions.minMemory}} -Xmx{{.Values.config.odl.javaOptions.maxMemory}}"
178           - name: KARAF_CONSOLE_LOG_LEVEL
179             value: "{{ include "common.log.level" . }}"
180           - name: SDNRWT
181             value: "{{ .Values.config.sdnr.enabled | default "false"}}"
182           {{- if eq .Values.config.sdnr.mode "web" }}
183           - name: SDNRDM
184             value: "true"
185           {{- end }}
186           - name: SDNRONLY
187             value: "{{ .Values.config.sdnr.sdnronly | default "false" }}"
188           - name: SDNRDBURL
189             {{- $prefix := ternary "https" "http" .Values.global.aafEnabled}}
190             value: "{{$prefix}}://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
191           {{- if .Values.config.sdnr.sdnrdbTrustAllCerts }}
192           - name: SDNRDBTRUSTALLCERTS
193             value: "true"
194           {{ end }}
195
196           volumeMounts:
197 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
198 {{ include "common.certServiceClient.volumeMounts" . | indent 10 }}
199           - mountPath: /etc/localtime
200             name: localtime
201             readOnly: true
202           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
203             name: sdnc-logging-cfg-config
204             subPath: org.ops4j.pax.logging.cfg
205           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
206             name: bin
207             subPath: installSdncDb.sh
208           - mountPath: {{ .Values.config.binDir }}/createLinks.sh
209             name: bin
210             subPath: createLinks.sh
211           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
212             name: properties
213             subPath: aaiclient.properties
214           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
215             name: properties
216             subPath: aaiclient.properties
217           - mountPath: {{ .Values.config.configDir }}/dblib.properties
218             name: properties
219             subPath: dblib.properties
220           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
221             name: properties
222             subPath: lcm-dg.properties
223           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
224             name: properties
225             subPath: svclogic.properties
226           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
227             name: properties
228             subPath: svclogic.properties
229           - mountPath: {{ .Values.config.configDir }}/netbox.properties
230             name: properties
231             subPath: netbox.properties
232           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
233             name: properties
234             subPath: blueprints-processor-adaptor.properties
235           - mountPath: {{ .Values.persistence.mdsalPath }}
236             name: {{ include "common.fullname" . }}-data
237           - mountPath: /var/log/onap
238             name: logs
239           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
240             name: properties
241             subPath: akka.conf
242           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
243             name: properties
244             subPath: org.opendaylight.controller.cluster.datastore.cfg
245           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.aaa.filterchain.cfg
246             name: properties
247             subPath: org.opendaylight.aaa.filterchain.cfg
248           - mountPath: {{ .Values.config.odl.binDir }}/setenv
249             name: properties
250             subPath: setenv
251           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-registrar.properties
252             name: properties
253             subPath: mountpoint-registrar.properties
254           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-state-provider.properties
255             name: properties
256             subPath: mountpoint-state-provider.properties
257           resources:
258 {{ include "common.resources" . | indent 12 }}
259         {{- if .Values.nodeSelector }}
260         nodeSelector:
261 {{ toYaml .Values.nodeSelector | indent 10 }}
262         {{- end -}}
263         {{- if .Values.affinity }}
264         affinity:
265 {{ toYaml .Values.affinity | indent 10 }}
266         {{- end }}
267
268         # side car containers
269         - name: filebeat-onap
270           image: {{ include "repositoryGenerator.image.logging" . }}
271           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
272           volumeMounts:
273           - mountPath: /usr/share/filebeat/filebeat.yml
274             name: filebeat-conf
275             subPath: filebeat.yml
276           - mountPath: /var/log/onap
277             name: logs
278           - mountPath: /usr/share/filebeat/data
279             name: data-filebeat
280       imagePullSecrets:
281       - name: "{{ include "common.namespace" . }}-docker-registry-key"
282       volumes:
283         - name: localtime
284           hostPath:
285             path: /etc/localtime
286         - name: logs
287           emptyDir: {}
288         - name: data-filebeat
289           emptyDir: {}
290         - name: filebeat-conf
291           configMap:
292             name: {{ include "common.fullname" . }}-filebeat-configmap
293         - name: sdnc-logging-cfg-config
294           configMap:
295             name: {{ include "common.fullname" . }}-log-configmap
296         - name: bin
297           configMap:
298             name: {{ include "common.fullname" . }}-bin
299             defaultMode: 0755
300         - name: config-input
301           configMap:
302             name: {{ include "common.fullname" . }}-properties
303             defaultMode: 0644
304         - name: properties
305           emptyDir:
306             medium: Memory
307   {{ if not .Values.persistence.enabled }}
308         - name: {{ include "common.fullname" . }}-data
309           emptyDir: {}
310   {{ else }}
311 {{ include "common.certInitializer.volumes" . | nindent 8 }}
312 {{ include "common.certServiceClient.volumes" . | nindent 8 }}
313   volumeClaimTemplates:
314   - metadata:
315       name: {{ include "common.fullname" . }}-data
316       labels:
317         name: {{ include "common.fullname" . }}
318         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
319         release: "{{ include "common.release" . }}"
320         heritage: "{{ .Release.Service }}"
321     spec:
322       accessModes:
323       - {{ .Values.persistence.accessMode }}
324       storageClassName: {{ include "common.storageClass" . }}
325       resources:
326         requests:
327           storage: {{ .Values.persistence.size }}
328   {{- end }}