Merge "[Tree-wide] Remove pnda charts from OOM"
[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" . }}-chown
145         image: {{ .Values.global.busyboxRepository | default .Values.busyboxRepository }}/{{ .Values.global.busyboxImage | default .Values.busyboxImage }}
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 "common.repository" . }}/{{ .Values.image }}"
161           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
162           {{- if not .Values.config.sdnr.enabled }}
163           command: ["/bin/bash"]
164           args: ["-c", "/opt/onap/sdnc/bin/startODL.sh"]
165           {{ else }}
166           command: ["/bin/bash"]
167           args: ["-c", "{{ .Values.config.binDir }}/startODL.oom.sh"]
168           {{ end }}
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: JAVA_HOME
209             value: "{{ .Values.config.javaHome}}"
210           - name: JAVA_OPTS
211             value: "-Xms{{.Values.config.odl.javaOptions.minMemory}} -Xmx{{.Values.config.odl.javaOptions.maxMemory}}"
212           - name: KARAF_CONSOLE_LOG_LEVEL
213             value: "{{ include "common.log.level" . }}"
214           - name: SDNRWT
215             value: "{{ .Values.config.sdnr.enabled | default "false"}}"
216           {{- if eq .Values.config.sdnr.mode "web" }}
217           - name: SDNRDM
218             value: "true"
219           {{- end }}
220           - name: SDNRONLY
221             value: "{{ .Values.config.sdnr.sdnronly | default "false" }}"
222           - name: SDNRDBURL
223             {{- $prefix := ternary "https" "http" .Values.global.aafEnabled}}
224             value: "{{$prefix}}://{{ .Values.elasticsearch.service.name | default "sdnrdb"}}.{{.Release.Namespace}}:{{.Values.elasticsearch.service.port | default "9200"}}"
225           {{- if .Values.config.sdnr.sdnrdbTrustAllCerts }}
226           - name: SDNRDBTRUSTALLCERTS
227             value: "true"
228           {{ end }}
229
230           volumeMounts:
231 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
232           - mountPath: /etc/localtime
233             name: localtime
234             readOnly: true
235           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
236             name: sdnc-logging-cfg-config
237             subPath: org.ops4j.pax.logging.cfg
238           - mountPath: {{ .Values.config.binDir }}/startODL.sh
239             name: bin
240             subPath: startODL.sh
241           - mountPath: {{ .Values.config.binDir }}/startODL.oom.sh
242             name: bin
243             subPath: startODL.oom.sh
244           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
245             name: bin
246             subPath: installSdncDb.sh
247           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
248             name: properties
249             subPath: aaiclient.properties
250           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
251             name: properties
252             subPath: aaiclient.properties
253           - mountPath: {{ .Values.config.configDir }}/dblib.properties
254             name: properties
255             subPath: dblib.properties
256           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
257             name: properties
258             subPath: lcm-dg.properties
259           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
260             name: properties
261             subPath: svclogic.properties
262           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
263             name: properties
264             subPath: svclogic.properties
265           - mountPath: {{ .Values.config.configDir }}/netbox.properties
266             name: properties
267             subPath: netbox.properties
268           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
269             name: properties
270             subPath: blueprints-processor-adaptor.properties
271           - mountPath: {{ .Values.persistence.mdsalPath }}
272             name: {{ include "common.fullname" . }}-data
273           - mountPath: /var/log/onap
274             name: logs
275           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
276             name: properties
277             subPath: akka.conf
278           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
279             name: properties
280             subPath: org.opendaylight.controller.cluster.datastore.cfg
281           - mountPath: {{ .Values.config.odl.binDir }}/setenv
282             name: properties
283             subPath: setenv
284           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-registrar.properties
285             name: properties
286             subPath: mountpoint-registrar.properties
287           - mountPath: {{ .Values.config.odl.etcDir }}/mountpoint-state-provider.properties
288             name: properties
289             subPath: mountpoint-state-provider.properties
290           {{ if .Values.global.cmpv2Enabled }}
291           - mountPath: {{ .Values.global.platform.certServiceClient.envVariables.cert_path }}
292             name: certs
293           {{- end }}
294           resources:
295 {{ include "common.resources" . | indent 12 }}
296         {{- if .Values.nodeSelector }}
297         nodeSelector:
298 {{ toYaml .Values.nodeSelector | indent 10 }}
299         {{- end -}}
300         {{- if .Values.affinity }}
301         affinity:
302 {{ toYaml .Values.affinity | indent 10 }}
303         {{- end }}
304
305         # side car containers
306         - name: filebeat-onap
307           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
308           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
309           volumeMounts:
310           - mountPath: /usr/share/filebeat/filebeat.yml
311             name: filebeat-conf
312             subPath: filebeat.yml
313           - mountPath: /var/log/onap
314             name: logs
315           - mountPath: /usr/share/filebeat/data
316             name: data-filebeat
317       imagePullSecrets:
318       - name: "{{ include "common.namespace" . }}-docker-registry-key"
319       volumes:
320         - name: localtime
321           hostPath:
322             path: /etc/localtime
323         - name: logs
324           emptyDir: {}
325         - name: data-filebeat
326           emptyDir: {}
327         - name: filebeat-conf
328           configMap:
329             name: {{ include "common.fullname" . }}-filebeat-configmap
330         - name: sdnc-logging-cfg-config
331           configMap:
332             name: {{ include "common.fullname" . }}-log-configmap
333         - name: bin
334           configMap:
335             name: {{ include "common.fullname" . }}-bin
336             defaultMode: 0755
337         - name: config-input
338           configMap:
339             name: {{ include "common.fullname" . }}-properties
340             defaultMode: 0644
341         - name: properties
342           emptyDir:
343             medium: Memory
344         {{ if .Values.global.cmpv2Enabled }}
345         - name: certs
346           emptyDir:
347             medium: Memory
348         - name: certservice-tls-volume
349           secret:
350             secretName: {{ .Values.global.platform.certServiceClient.secret.name }}
351         {{- end }}
352   {{ if not .Values.persistence.enabled }}
353         - name: {{ include "common.fullname" . }}-data
354           emptyDir: {}
355   {{ else }}
356 {{ include "common.certInitializer.volumes" . | nindent 8 }}
357   volumeClaimTemplates:
358   - metadata:
359       name: {{ include "common.fullname" . }}-data
360       labels:
361         name: {{ include "common.fullname" . }}
362         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
363         release: "{{ include "common.release" . }}"
364         heritage: "{{ .Release.Service }}"
365     spec:
366       accessModes:
367       - {{ .Values.persistence.accessMode }}
368       storageClassName: {{ include "common.storageClass" . }}
369       resources:
370         requests:
371           storage: {{ .Values.persistence.size }}
372   {{- end }}