Merge "[SDNC] Set STDOUT Log level"
[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           - name: KARAF_CONSOLE_LOG_LEVEL
162             value: "{{ include "common.log.level" . }}"
163           volumeMounts:
164 {{ include "common.certInitializer.volumeMount" . | indent 10 }}
165           - mountPath: /etc/localtime
166             name: localtime
167             readOnly: true
168           - mountPath: /opt/opendaylight/current/etc/org.ops4j.pax.logging.cfg
169             name: sdnc-logging-cfg-config
170             subPath: org.ops4j.pax.logging.cfg
171           - mountPath: {{ .Values.config.binDir }}/startODL.sh
172             name: bin
173             subPath: startODL.sh
174           - mountPath: {{ .Values.config.binDir }}/installSdncDb.sh
175             name: bin
176             subPath: installSdncDb.sh
177           - mountPath: {{ .Values.config.ccsdkConfigDir }}/aaiclient.properties
178             name: properties
179             subPath: aaiclient.properties
180           - mountPath: {{ .Values.config.configDir }}/aaiclient.properties
181             name: properties
182             subPath: aaiclient.properties
183           - mountPath: {{ .Values.config.configDir }}/dblib.properties
184             name: properties
185             subPath: dblib.properties
186           - mountPath: {{ .Values.config.configDir }}/lcm-dg.properties
187             name: properties
188             subPath: lcm-dg.properties
189           - mountPath: {{ .Values.config.configDir }}/svclogic.properties
190             name: properties
191             subPath: svclogic.properties
192           - mountPath: /opt/onap/sdnc/svclogic/config/svclogic.properties
193             name: properties
194             subPath: svclogic.properties
195           - mountPath: {{ .Values.config.configDir }}/netbox.properties
196             name: properties
197             subPath: netbox.properties
198           - mountPath: {{ .Values.config.configDir }}/blueprints-processor-adaptor.properties
199             name: properties
200             subPath: blueprints-processor-adaptor.properties
201           - mountPath: {{ .Values.persistence.mdsalPath }}
202             name: {{ include "common.fullname" . }}-data
203           - mountPath: /var/log/onap
204             name: logs
205           - mountPath: {{ .Values.config.odl.salConfigDir }}/{{ .Values.config.odl.salConfigVersion}}/sal-clustering-config-{{ .Values.config.odl.salConfigVersion}}-akkaconf.xml
206             name: properties
207             subPath: akka.conf
208           - mountPath: {{ .Values.config.odl.etcDir }}/org.opendaylight.controller.cluster.datastore.cfg
209             name: properties
210             subPath: org.opendaylight.controller.cluster.datastore.cfg
211           - mountPath: {{ .Values.config.odl.binDir }}/setenv
212             name: properties
213             subPath: setenv
214           resources:
215 {{ include "common.resources" . | indent 12 }}
216         {{- if .Values.nodeSelector }}
217         nodeSelector:
218 {{ toYaml .Values.nodeSelector | indent 10 }}
219         {{- end -}}
220         {{- if .Values.affinity }}
221         affinity:
222 {{ toYaml .Values.affinity | indent 10 }}
223         {{- end }}
224
225         # side car containers
226         - name: filebeat-onap
227           image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
228           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
229           volumeMounts:
230           - mountPath: /usr/share/filebeat/filebeat.yml
231             name: filebeat-conf
232             subPath: filebeat.yml
233           - mountPath: /var/log/onap
234             name: logs
235           - mountPath: /usr/share/filebeat/data
236             name: data-filebeat
237       imagePullSecrets:
238       - name: "{{ include "common.namespace" . }}-docker-registry-key"
239       volumes:
240         - name: localtime
241           hostPath:
242             path: /etc/localtime
243         - name: logs
244           emptyDir: {}
245         - name: data-filebeat
246           emptyDir: {}
247         - name: filebeat-conf
248           configMap:
249             name: {{ include "common.fullname" . }}-filebeat-configmap
250         - name: sdnc-logging-cfg-config
251           configMap:
252             name: {{ include "common.fullname" . }}-log-configmap
253         - name: bin
254           configMap:
255             name: {{ include "common.fullname" . }}-bin
256             defaultMode: 0755
257         - name: config-input
258           configMap:
259             name: {{ include "common.fullname" . }}-properties
260             defaultMode: 0644
261         - name: properties
262           emptyDir:
263             medium: Memory
264   {{ if not .Values.persistence.enabled }}
265         - name: {{ include "common.fullname" . }}-data
266           emptyDir: {}
267   {{ else }}
268 {{ include "common.certInitializer.volumes" . | nindent 8 }}
269   volumeClaimTemplates:
270   - metadata:
271       name: {{ include "common.fullname" . }}-data
272       labels:
273         name: {{ include "common.fullname" . }}
274         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
275         release: "{{ include "common.release" . }}"
276         heritage: "{{ .Release.Service }}"
277     spec:
278       accessModes:
279       - {{ .Values.persistence.accessMode }}
280       storageClassName: {{ include "common.storageClass" . }}
281       resources:
282         requests:
283           storage: {{ .Values.persistence.size }}
284   {{- end }}