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