Merge "Unable to boot SNDC pod without AAF"
[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:
103         - sh
104         args:
105         - -c
106         - chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}
107 {{- if .Values.global.aafEnabled }}
108         - chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certInitializer.credsPath }}
109 {{- end }}
110         volumeMounts:
111 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
112           - mountPath: {{ .Values.persistence.mdsalPath }}
113             name: {{ include "common.fullname" . }}-data
114       containers:
115         - name: {{ include "common.name" . }}
116           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
117           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
118           command: ["/bin/bash"]
119           args: ["-c", "/opt/onap/sdnc/bin/startODL.sh"]
120           ports:
121           - containerPort: {{ .Values.service.internalPort }}
122           - containerPort: {{ .Values.service.internalPort2 }}
123           - containerPort: {{ .Values.service.internalPort3 }}
124           - containerPort: {{ .Values.service.clusterPort }}
125           readinessProbe:
126             tcpSocket:
127               port: {{ .Values.service.internalPort }}
128             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
129             periodSeconds: {{ .Values.readiness.periodSeconds }}
130           env:
131           - name: MYSQL_ROOT_PASSWORD
132             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
133           - name: ODL_ADMIN_USERNAME
134             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
135           - name: ODL_ADMIN_PASSWORD
136             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
137           - name: SDNC_DB_USER
138             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
139           - name: SDNC_DB_PASSWORD
140             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
141           - name: SDNC_CONFIG_DIR
142             value: "{{ .Values.config.configDir }}"
143           - name: ENABLE_ODL_CLUSTER
144             value: "{{ .Values.config.enableClustering }}"
145           - name: MY_ODL_CLUSTER
146             value: "{{ .Values.config.myODLCluster }}"
147           - name: PEER_ODL_CLUSTER
148             value: "{{ .Values.config.peerODLCluster }}"
149           - name: IS_PRIMARY_CLUSTER
150             value: "{{ .Values.config.isPrimaryCluster }}"
151           - name: GEO_ENABLED
152             value: "{{ .Values.config.geoEnabled}}"
153           - name: SDNC_AAF_ENABLED
154             value: "{{ .Values.global.aafEnabled}}"
155           - name: SDNC_REPLICAS
156             value: "{{ .Values.replicaCount }}"
157           - name: MYSQL_HOST
158             value: {{ include "common.mariadbService" . }}
159           - name: JAVA_HOME
160             value: "{{ .Values.config.javaHome}}"
161           volumeMounts:
162 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
163           - mountPath: /etc/localtime
164             name: localtime
165             readOnly: true
166           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
167             name: sdnc-logging-cfg-config
168             subPath: org.ops4j.pax.logging.cfg
169           - mountPath: {{ .Values.config.binDir }}/startODL.sh
170             name: bin
171             subPath: startODL.sh
172           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
173             name: bin
174             subPath: installSdncDb.sh
175           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
176             name: properties
177             subPath: aaiclient.properties
178           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
179             name: properties
180             subPath: aaiclient.properties
181           - mountPath: {{ .Values.config.configDir }}/dblib.properties
182             name: properties
183             subPath: dblib.properties
184           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
185             name: properties
186             subPath: lcm-dg.properties
187           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
188             name: properties
189             subPath: svclogic.properties
190           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
191             name: properties
192             subPath: svclogic.properties
193           - mountPath: {{ .Values.config.configDir }}/netbox.properties
194             name: properties
195             subPath: netbox.properties
196           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
197             name: properties
198             subPath: blueprints-processor-adaptor.properties
199           - mountPath: {{ .Values.persistence.mdsalPath }}
200             name: {{ include "common.fullname" . }}-data
201           - mountPath: /var/log/onap
202             name: logs
203           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
204             name: properties
205             subPath: akka.conf
206           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
207             name: properties
208             subPath: org.opendaylight.controller.cluster.datastore.cfg
209           - mountPath: {{ .Values.config.odl.binDir }}/setenv
210             name: properties
211             subPath: setenv
212           resources:
213 {{ include "common.resources" . | indent 12 }}
214         {{- if .Values.nodeSelector }}
215         nodeSelector:
216 {{ toYaml .Values.nodeSelector | indent 10 }}
217         {{- end -}}
218         {{- if .Values.affinity }}
219         affinity:
220 {{ toYaml .Values.affinity | indent 10 }}
221         {{- end }}
222
223         # side car containers
224         - name: filebeat-onap
225           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
226           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
227           volumeMounts:
228           - mountPath: /usr/share/filebeat/filebeat.yml
229             name: filebeat-conf
230             subPath: filebeat.yml
231           - mountPath: /var/log/onap
232             name: logs
233           - mountPath: /usr/share/filebeat/data
234             name: data-filebeat
235       imagePullSecrets:
236       - name: "{{ include "common.namespace" . }}-docker-registry-key"
237       volumes:
238         - name: localtime
239           hostPath:
240             path: /etc/localtime
241         - name: logs
242           emptyDir: {}
243         - name: data-filebeat
244           emptyDir: {}
245         - name: filebeat-conf
246           configMap:
247             name: {{ include "common.fullname" . }}-filebeat-configmap
248         - name: sdnc-logging-cfg-config
249           configMap:
250             name: {{ include "common.fullname" . }}-log-configmap
251         - name: bin
252           configMap:
253             name: {{ include "common.fullname" . }}-bin
254             defaultMode: 0755
255         - name: config-input
256           configMap:
257             name: {{ include "common.fullname" . }}-properties
258             defaultMode: 0644
259         - name: properties
260           emptyDir:
261             medium: Memory
262   {{ if not .Values.persistence.enabled }}
263         - name: {{ include "common.fullname" . }}-data
264           emptyDir: {}
265   {{ else }}
266 {{ include "common.certInitializer.volumes" . | nindent 8 }}
267   volumeClaimTemplates:
268   - metadata:
269       name: {{ include "common.fullname" . }}-data
270       labels:
271         name: {{ include "common.fullname" . }}
272         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
273         release: "{{ include "common.release" . }}"
274         heritage: "{{ .Release.Service }}"
275     spec:
276       accessModes:
277       - {{ .Values.persistence.accessMode }}
278       storageClassName: {{ include "common.storageClass" . }}
279       resources:
280         requests:
281           storage: {{ .Values.persistence.size }}
282   {{- end }}