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