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