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