Merge "address known Zookeeper bugs"
[oom.git] / kubernetes / sdnc / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16
17 apiVersion: apps/v1beta1
18 kind: StatefulSet
19 metadata:
20   name: {{ include "common.fullname" . }}
21   namespace: {{ include "common.namespace" . }}
22   labels:
23     app: {{ include "common.name" . }}
24     chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
25     release: {{ include "common.release" . }}
26     heritage: {{ .Release.Service }}
27 spec:
28   serviceName: {{ include "common.servicename" . }}-cluster
29   replicas: {{ .Values.replicaCount }}
30   podManagementPolicy: Parallel
31   template:
32     metadata:
33       labels:
34         app: {{ include "common.name" . }}
35         release: {{ include "common.release" . }}
36     spec:
37       initContainers:
38       - command:
39         - sh
40         args:
41         - -c
42         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done"
43         env:
44         - name: AAI_CLIENT_NAME
45           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "login") | indent 10 }}
46         - name: AAI_CLIENT_PASSWORD
47           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aai-user-creds" "key" "password") | indent 10 }}
48         - name: MODELSERVICE_USER
49           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "login") | indent 10 }}
50         - name: MODELSERVICE_PASSWORD
51           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "modeling-user-creds" "key" "password") | indent 10 }}
52         - name: RESTCONF_USER
53           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "login") | indent 10 }}
54         - name: RESTCONF_PASSWORD
55           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "restconf-creds" "key" "password") | indent 10 }}
56         - name: ANSIBLE_USER
57           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "login") | indent 10 }}
58         - name: ANSIBLE_PASSWORD
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "ansible-creds" "key" "password") | indent 10 }}
60         - name: SCALEOUT_USER
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "login") | indent 10 }}
62         - name: SCALEOUT_PASSWORD
63           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "scaleout-creds" "key" "password") | indent 10 }}
64         - name: NETBOX_APIKEY
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "netbox-apikey" "key" "password") | indent 10 }}
66         - name: SDNC_DB_USER
67           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
68         - name: SDNC_DB_PASSWORD
69           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
70         volumeMounts:
71         - mountPath: /config-input
72           name: config-input
73         - mountPath: /config
74           name: properties
75         image: "{{ .Values.global.envsubstImage }}"
76         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
77         name: {{ include "common.name" . }}-update-config
78
79       - command:
80         - /root/ready.py
81         args:
82         - --container-name
83         - {{ include "common.mariadbService" . }}
84         env:
85         - name: NAMESPACE
86           valueFrom:
87             fieldRef:
88               apiVersion: v1
89               fieldPath: metadata.namespace
90         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
91         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
92         name: {{ include "common.name" . }}-readiness
93       {{ if .Values.global.aafEnabled }}
94       - name: {{ include "common.name" . }}-aaf-readiness
95         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
96         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
97         command:
98         - /root/ready.py
99         args:
100         - --container-name
101         - aaf-locate
102         env:
103         - name: NAMESPACE
104           valueFrom:
105             fieldRef:
106               apiVersion: v1
107               fieldPath: metadata.namespace
108       - name: {{ include "common.name" . }}-aaf
109         image: {{ .Values.global.repository }}/{{ .Values.aaf_init.agentImage }}
110         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
111         volumeMounts:
112           - mountPath: {{ .Values.certpersistence.certPath }}
113             name: {{ include "common.fullname" . }}-certs
114         command:
115         - bash
116         - -c
117         - |
118           /opt/app/aaf_config/bin/agent.sh &&
119           cd /opt/app/osaaf/local &&
120           /opt/app/aaf_config/bin/agent.sh local showpass | grep cadi_keystore_password= | cut -d= -f 2 > /opt/app/osaaf/local/.pass 2>&1
121         env:
122           - name: APP_FQI
123             value: "{{ .Values.aaf_init.fqi }}"
124           - name: aaf_locate_url
125             value: "https://aaf-locate.{{ .Release.Namespace}}:8095"
126           - name: aaf_locator_container
127             value: "oom"
128           - name: aaf_locator_container_ns
129             value: "{{ .Release.Namespace }}"
130           - name: aaf_locator_fqdn
131             value: "{{ .Values.aaf_init.fqdn }}"
132           - name: aaf_locator_app_ns
133             value: "{{ .Values.aaf_init.app_ns }}"
134           - name: DEPLOY_FQI
135             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aaf-creds" "key" "login") | indent 12 }}
136           - name: DEPLOY_PASSWORD
137             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "aaf-creds" "key" "password") | indent 12 }}
138           - name: cadi_longitude
139             value: "{{ .Values.aaf_init.cadi_longitude }}"
140           - name: cadi_latitude
141             value: "{{ .Values.aaf_init.cadi_latitude }}"
142       {{ end }}
143       - name: {{ include "common.name" . }}-chown
144         image: "busybox"
145         command: ["sh", "-c", "chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }} ; chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.certpersistence.certPath }}"]
146         volumeMounts:
147           - mountPath: {{ .Values.persistence.mdsalPath }}
148             name: {{ include "common.fullname" . }}-data
149           - mountPath: {{ .Values.certpersistence.certPath }}
150             name: {{ include "common.fullname" . }}-certs
151       containers:
152         - name: {{ include "common.name" . }}
153           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
154           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
155           command: ["/bin/bash"]
156           args: ["-c", "/opt/sdnc/bin/startODL.sh"]
157           ports:
158           - containerPort: {{ .Values.service.internalPort }}
159           - containerPort: {{ .Values.service.internalPort2 }}
160           - containerPort: {{ .Values.service.internalPort3 }}
161           - containerPort: {{ .Values.service.clusterPort }}
162           readinessProbe:
163             tcpSocket:
164               port: {{ .Values.service.internalPort }}
165             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
166             periodSeconds: {{ .Values.readiness.periodSeconds }}
167           env:
168           - name: MYSQL_ROOT_PASSWORD
169             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
170           - name: ODL_ADMIN_USERNAME
171             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "login") | indent 12 }}
172           - name: ODL_ADMIN_PASSWORD
173             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "odl-creds" "key" "password") | indent 12 }}
174           - name: SDNC_DB_USER
175             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
176           - name: SDNC_DB_PASSWORD
177             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
178           - name: SDNC_CONFIG_DIR
179             value: "{{ .Values.config.configDir }}"
180           - name: ENABLE_ODL_CLUSTER
181             value: "{{ .Values.config.enableClustering }}"
182           - name: MY_ODL_CLUSTER
183             value: "{{ .Values.config.myODLCluster }}"
184           - name: PEER_ODL_CLUSTER
185             value: "{{ .Values.config.peerODLCluster }}"
186           - name: IS_PRIMARY_CLUSTER
187             value: "{{ .Values.config.isPrimaryCluster }}"
188           - name: GEO_ENABLED
189             value: "{{ .Values.config.geoEnabled}}"
190           - name: SDNC_AAF_ENABLED
191             value: "{{ .Values.global.aafEnabled}}"
192           - name: SDNC_REPLICAS
193             value: "{{ .Values.replicaCount }}"
194           - name: MYSQL_HOST
195             value: {{ include "common.mariadbService" . }}
196           - name: JAVA_HOME
197             value: "{{ .Values.config.javaHome}}"
198           volumeMounts:
199           - mountPath: /etc/localtime
200             name: localtime
201             readOnly: true
202           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
203             name: sdnc-logging-cfg-config
204             subPath: org.ops4j.pax.logging.cfg
205           - mountPath: {{ .Values.config.binDir }}/startODL.sh
206             name: bin
207             subPath: startODL.sh
208           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
209             name: bin
210             subPath: installSdncDb.sh
211           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
212             name: properties
213             subPath: aaiclient.properties
214           - mountPath: {{ .Values.config.configDir }}/dblib.properties
215             name: properties
216             subPath: dblib.properties
217           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
218             name: properties
219             subPath: lcm-dg.properties
220           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
221             name: properties
222             subPath: svclogic.properties
223           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
224             name: properties
225             subPath: svclogic.properties
226           - mountPath: {{ .Values.config.configDir }}/netbox.properties
227             name: properties
228             subPath: netbox.properties
229           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
230             name: properties
231             subPath: blueprints-processor-adaptor.properties
232           - mountPath: {{ .Values.persistence.mdsalPath }}
233             name: {{ include "common.fullname" . }}-data
234           - mountPath: /var/log/onap
235             name: logs
236           - mountPath: {{ .Values.certpersistence.certPath }}
237             name: {{ include "common.fullname" . }}-certs
238           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
239             name: properties
240             subPath: akka.conf
241           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
242             name: properties
243             subPath: org.opendaylight.controller.cluster.datastore.cfg
244           - mountPath: {{ .Values.config.odl.binDir }}/setenv
245             name: properties
246             subPath: setenv
247           resources:
248 {{ include "common.resources" . | indent 12 }}
249         {{- if .Values.nodeSelector }}
250         nodeSelector:
251 {{ toYaml .Values.nodeSelector | indent 10 }}
252         {{- end -}}
253         {{- if .Values.affinity }}
254         affinity:
255 {{ toYaml .Values.affinity | indent 10 }}
256         {{- end }}
257
258         # side car containers
259         - name: filebeat-onap
260           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
261           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
262           volumeMounts:
263           - mountPath: /usr/share/filebeat/filebeat.yml
264             name: filebeat-conf
265             subPath: filebeat.yml
266           - mountPath: /var/log/onap
267             name: logs
268           - mountPath: /usr/share/filebeat/data
269             name: data-filebeat
270       imagePullSecrets:
271       - name: "{{ include "common.namespace" . }}-docker-registry-key"
272       volumes:
273         - name: localtime
274           hostPath:
275             path: /etc/localtime
276         - name: logs
277           emptyDir: {}
278         - name: data-filebeat
279           emptyDir: {}
280         - name: filebeat-conf
281           configMap:
282             name: {{ include "common.fullname" . }}-filebeat-configmap
283         - name: sdnc-logging-cfg-config
284           configMap:
285             name: {{ include "common.fullname" . }}-log-configmap
286         - name: bin
287           configMap:
288             name: {{ include "common.fullname" . }}-bin
289             defaultMode: 0755
290         - name: config-input
291           configMap:
292             name: {{ include "common.fullname" . }}-properties
293             defaultMode: 0644
294         - name: properties
295           emptyDir:
296             medium: Memory
297         - name: {{ include "common.fullname" . }}-certs
298   {{ if .Values.certpersistence.enabled }}
299           persistentVolumeClaim:
300             claimName: {{ include "common.fullname" . }}-certs
301   {{ else }}
302           emptyDir: {}
303   {{ end }}
304   {{ if not .Values.persistence.enabled }}
305         - name: {{ include "common.fullname" . }}-data
306           emptyDir: {}
307   {{ else }}
308   volumeClaimTemplates:
309   - metadata:
310       name: {{ include "common.fullname" . }}-data
311       labels:
312         name: {{ include "common.fullname" . }}
313         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
314         release: "{{ include "common.release" . }}"
315         heritage: "{{ .Release.Service }}"
316     spec:
317       accessModes:
318       - {{ .Values.persistence.accessMode }}
319       storageClassName: {{ include "common.storageClass" . }}
320       resources:
321         requests:
322           storage: {{ .Values.persistence.size }}
323   {{- end }}