[SDNC] Make SDNC compatible with Kubernetes v1.17
[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:
21   name: {{ include "common.fullname" . }}
22   namespace: {{ include "common.namespace" . }}
23   labels:
24     app: {{ include "common.name" . }}
25     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
26     release: {{ include "common.release" . }}
27     heritage: {{ .Release.Service }}
28 spec:
29   selector:
30     matchLabels:
31       app: {{ include "common.name" . }}
32   serviceName: {{ include "common.servicename" . }}-cluster
33   replicas: {{ .Values.replicaCount }}
34   podManagementPolicy: Parallel
35   template:
36     metadata:
37       labels:
38         app: {{ include "common.name" . }}
39         release: {{ include "common.release" . }}
40     spec:
41       initContainers:
42       - command:
43         - sh
44         args:
45         - -c
46         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
47         env:
48         - name: AAI_CLIENT_NAME
49           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "login") | indent 10 }}
50         - name: AAI_CLIENT_PASSWORD
51           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "password") | indent 10 }}
52         - name: MODELSERVICE_USER
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "login") | indent 10 }}
54         - name: MODELSERVICE_PASSWORD
55           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "password") | indent 10 }}
56         - name: RESTCONF_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "login") | indent 10 }}
58         - name: RESTCONF_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "password") | indent 10 }}
60         - name: ANSIBLE_USER
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "login") | indent 10 }}
62         - name: ANSIBLE_PASSWORD
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "password") | indent 10 }}
64         - name: SCALEOUT_USER
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "login") | indent 10 }}
66         - name: SCALEOUT_PASSWORD
67           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "password") | indent 10 }}
68         - name: NETBOX_APIKEY
69           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "netbox-apikey" "key" "password") | indent 10 }}
70         - name: SDNC_DB_USER
71           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
72         - name: SDNC_DB_PASSWORD
73           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
74         volumeMounts:
75         - mountPath: /config-input
76           name: config-input
77         - mountPath: /config
78           name: properties
79         image: "{{ .Values.global.envsubstImage }}"
80         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
81         name: {{ include "common.name" . }}-update-config
82
83       - command:
84         - /root/ready.py
85         args:
86         - --container-name
87         - {{ include "common.mariadbService" . }}
88         env:
89         - name: NAMESPACE
90           valueFrom:
91             fieldRef:
92               apiVersion: v1
93               fieldPath: metadata.namespace
94         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
95         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
96         name: {{ include "common.name" . }}-readiness
97
98 {{ include "common.certInitializer.initContainer" . | indent 6 }}
99
100       - name: {{ include "common.name" . }}-chown
101         image: "busybox"
102         command: ["sh", "-c", "chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }} ; chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}"]
103         volumeMounts:
104 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
105           - mountPath: {{ .Values.persistence.mdsalPath }}
106             name: {{ include "common.fullname" . }}-data
107       containers:
108         - name: {{ include "common.name" . }}
109           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
110           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
111           command: ["/bin/bash"]
112           args: ["-c", "/opt/onap/sdnc/bin/startODL.sh"]
113           ports:
114           - containerPort: {{ .Values.service.internalPort }}
115           - containerPort: {{ .Values.service.internalPort2 }}
116           - containerPort: {{ .Values.service.internalPort3 }}
117           - containerPort: {{ .Values.service.clusterPort }}
118           readinessProbe:
119             tcpSocket:
120               port: {{ .Values.service.internalPort }}
121             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
122             periodSeconds: {{ .Values.readiness.periodSeconds }}
123           env:
124           - name: MYSQL_ROOT_PASSWORD
125             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
126           - name: ODL_ADMIN_USERNAME
127             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
128           - name: ODL_ADMIN_PASSWORD
129             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
130           - name: SDNC_DB_USER
131             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
132           - name: SDNC_DB_PASSWORD
133             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
134           - name: SDNC_CONFIG_DIR
135             value: "{{ .Values.config.configDir }}"
136           - name: ENABLE_ODL_CLUSTER
137             value: "{{ .Values.config.enableClustering }}"
138           - name: MY_ODL_CLUSTER
139             value: "{{ .Values.config.myODLCluster }}"
140           - name: PEER_ODL_CLUSTER
141             value: "{{ .Values.config.peerODLCluster }}"
142           - name: IS_PRIMARY_CLUSTER
143             value: "{{ .Values.config.isPrimaryCluster }}"
144           - name: GEO_ENABLED
145             value: "{{ .Values.config.geoEnabled}}"
146           - name: SDNC_AAF_ENABLED
147             value: "{{ .Values.global.aafEnabled}}"
148           - name: SDNC_REPLICAS
149             value: "{{ .Values.replicaCount }}"
150           - name: MYSQL_HOST
151             value: {{ include "common.mariadbService" . }}
152           - name: JAVA_HOME
153             value: "{{ .Values.config.javaHome}}"
154           volumeMounts:
155 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
156           - mountPath: /etc/localtime
157             name: localtime
158             readOnly: true
159           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
160             name: sdnc-logging-cfg-config
161             subPath: org.ops4j.pax.logging.cfg
162           - mountPath: {{ .Values.config.binDir }}/startODL.sh
163             name: bin
164             subPath: startODL.sh
165           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
166             name: bin
167             subPath: installSdncDb.sh
168           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
169             name: properties
170             subPath: aaiclient.properties
171           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
172             name: properties
173             subPath: aaiclient.properties
174           - mountPath: {{ .Values.config.configDir }}/dblib.properties
175             name: properties
176             subPath: dblib.properties
177           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
178             name: properties
179             subPath: lcm-dg.properties
180           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
181             name: properties
182             subPath: svclogic.properties
183           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
184             name: properties
185             subPath: svclogic.properties
186           - mountPath: {{ .Values.config.configDir }}/netbox.properties
187             name: properties
188             subPath: netbox.properties
189           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
190             name: properties
191             subPath: blueprints-processor-adaptor.properties
192           - mountPath: {{ .Values.persistence.mdsalPath }}
193             name: {{ include "common.fullname" . }}-data
194           - mountPath: /var/log/onap
195             name: logs
196           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
197             name: properties
198             subPath: akka.conf
199           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
200             name: properties
201             subPath: org.opendaylight.controller.cluster.datastore.cfg
202           - mountPath: {{ .Values.config.odl.binDir }}/setenv
203             name: properties
204             subPath: setenv
205           resources:
206 {{ include "common.resources" . | indent 12 }}
207         {{- if .Values.nodeSelector }}
208         nodeSelector:
209 {{ toYaml .Values.nodeSelector | indent 10 }}
210         {{- end -}}
211         {{- if .Values.affinity }}
212         affinity:
213 {{ toYaml .Values.affinity | indent 10 }}
214         {{- end }}
215
216         # side car containers
217         - name: filebeat-onap
218           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
219           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
220           volumeMounts:
221           - mountPath: /usr/share/filebeat/filebeat.yml
222             name: filebeat-conf
223             subPath: filebeat.yml
224           - mountPath: /var/log/onap
225             name: logs
226           - mountPath: /usr/share/filebeat/data
227             name: data-filebeat
228       imagePullSecrets:
229       - name: "{{ include "common.namespace" . }}-docker-registry-key"
230       volumes:
231         - name: localtime
232           hostPath:
233             path: /etc/localtime
234         - name: logs
235           emptyDir: {}
236         - name: data-filebeat
237           emptyDir: {}
238         - name: filebeat-conf
239           configMap:
240             name: {{ include "common.fullname" . }}-filebeat-configmap
241         - name: sdnc-logging-cfg-config
242           configMap:
243             name: {{ include "common.fullname" . }}-log-configmap
244         - name: bin
245           configMap:
246             name: {{ include "common.fullname" . }}-bin
247             defaultMode: 0755
248         - name: config-input
249           configMap:
250             name: {{ include "common.fullname" . }}-properties
251             defaultMode: 0644
252         - name: properties
253           emptyDir:
254             medium: Memory
255   {{ if not .Values.persistence.enabled }}
256         - name: {{ include "common.fullname" . }}-data
257           emptyDir: {}
258   {{ else }}
259 {{ include "common.certInitializer.volumes" . | nindent 8 }}
260   volumeClaimTemplates:
261   - metadata:
262       name: {{ include "common.fullname" . }}-data
263       labels:
264         name: {{ include "common.fullname" . }}
265         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
266         release: "{{ include "common.release" . }}"
267         heritage: "{{ .Release.Service }}"
268     spec:
269       accessModes:
270       - {{ .Values.persistence.accessMode }}
271       storageClassName: {{ include "common.storageClass" . }}
272       resources:
273         requests:
274           storage: {{ .Values.persistence.size }}
275   {{- end }}