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