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