Merge "[DMAAP] DMaaP ServiceMesh compatibility"
[oom.git] / kubernetes / appc / templates / statefulset.yaml
1 {{/*
2 # Copyright © 2018  AT&T, Amdocs, Bell Canada Intellectual Property.  All rights reserved.
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/v1
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   selector:
29     matchLabels:
30       app: {{ include "common.name" . }}
31   serviceName: "{{ .Values.service.name }}-cluster"
32   replicas: {{ .Values.replicaCount }}
33   podManagementPolicy: Parallel
34   template:
35     metadata:
36       labels:
37         app: {{ include "common.name" . }}
38         release: {{ include "common.release" . }}
39     spec:
40       initContainers:
41       - command:
42         - sh
43         args:
44         - -c
45         - "cd /config-input && for PFILE in `find . -not -type d | grep -v -F ..`; do envsubst <${PFILE} >/config/${PFILE}; chmod 0755 /config/${PFILE}; done"
46         env:
47         - name: APPC_DB_USER
48           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "login") | indent 10 }}
49         - name: APPC_DB_PASSWD
50           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "password") | indent 10 }}
51         - name: SDNC_DB_USER
52           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "login") | indent 10 }}
53         - name: SDNC_DB_PASSWD
54           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "password") | indent 10 }}
55         volumeMounts:
56         - mountPath: /config-input/appc-data-properties
57           name: onap-appc-data-properties-input
58         - mountPath: /config-input/appc-svclogic-config
59           name: onap-appc-svclogic-config-input
60         - mountPath: /config-input/sdnc-data-properties
61           name: onap-sdnc-data-properties-input
62         - mountPath: /config-input/sdnc-svclogic-config
63           name: onap-sdnc-svclogic-config-input
64         - mountPath: /config/appc-data-properties
65           name: onap-appc-data-properties
66         - mountPath: /config/appc-svclogic-config
67           name: onap-appc-svclogic-config
68         - mountPath: /config/sdnc-data-properties
69           name: onap-sdnc-data-properties
70         - mountPath: /config/sdnc-svclogic-config
71           name: onap-sdnc-svclogic-config
72         image: {{ include "repositoryGenerator.image.envsubst" . }}
73         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74         name: {{ include "common.name" . }}-update-config
75
76       - name: {{ include "common.name" . }}-readiness
77         command:
78         - /app/ready.py
79         args:
80         - --container-name
81         - {{.Values.config.mariadbGaleraContName}}
82         env:
83         - name: NAMESPACE
84           valueFrom:
85             fieldRef:
86               apiVersion: v1
87               fieldPath: metadata.namespace
88         image: {{ include "repositoryGenerator.image.readiness" . }}
89         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
90       - name: {{ include "common.name" . }}-chown
91         image: {{ include "repositoryGenerator.image.busybox" . }}
92         command: ["sh", "-c", "chown -R {{ .Values.config.odlUid }}:{{ .Values.config.odlGid}} {{ .Values.persistence.mdsalPath }}"]
93         volumeMounts:
94           - mountPath: {{ .Values.persistence.mdsalPath }}
95             name: {{ include "common.fullname" . }}-data
96       containers:
97         - name: {{ include "common.name" . }}
98           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
99           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
100           command:
101           - /opt/appc/bin/startODL.sh
102           ports:
103           - containerPort: {{ .Values.service.internalPort }}
104           - containerPort: {{ .Values.service.externalPort2 }}
105           readinessProbe:
106             tcpSocket:
107                port: {{ .Values.service.internalPort }}
108             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
109             periodSeconds: {{ .Values.readiness.periodSeconds }}
110           env:
111             - name: MYSQL_ROOT_PASSWORD
112               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-pass" "key" "password") | indent 14}}
113             - name: APPC_DB_USER
114               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "login") | indent 14 }}
115             - name: APPC_DB_PASSWD
116               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "appcdb-user-creds" "key" "password") | indent 14 }}
117             - name: SDNC_DB_USER
118               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "login") | indent 14 }}
119             - name: SDNC_DB_PASSWD
120               {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdncdb-user-creds" "key" "password") | indent 14 }}
121             - name: SDNC_CONFIG_DIR
122               value: "{{ .Values.config.configDir }}"
123             - name: APPC_CONFIG_DIR
124               value: "{{ .Values.config.configDir }}"
125             - name: DMAAP_TOPIC_ENV
126               value: "{{ .Values.config.dmaapTopic }}"
127             - name: ENABLE_AAF
128               value: "{{ .Values.config.enableAAF }}"
129             - name: ENABLE_ODL_CLUSTER
130               value: "{{ .Values.config.enableClustering }}"
131             - name: APPC_REPLICAS
132               value: "{{ .Values.replicaCount }}"
133           volumeMounts:
134           - mountPath: /etc/localtime
135             name: localtime
136             readOnly: true
137           - mountPath: /opt/onap/appc/data/properties/dblib.properties
138             name: onap-appc-data-properties
139             subPath: dblib.properties
140           - mountPath: /opt/onap/appc/data/properties/svclogic.properties
141             name: onap-appc-data-properties
142             subPath: svclogic.properties
143           - mountPath: /opt/onap/appc/data/properties/appc.properties
144             name: onap-appc-data-properties
145             subPath: appc.properties
146           - mountPath: /opt/onap/appc/data/properties/aaiclient.properties
147             name: onap-appc-data-properties
148             subPath: aaiclient.properties
149           - mountPath: /opt/onap/appc/data/properties/cadi.properties
150             name: onap-appc-data-properties
151             subPath: cadi.properties
152           - mountPath: /opt/onap/appc/data/properties/aaa-app-config.xml
153             name: onap-appc-data-properties-input
154             subPath: aaa-app-config.xml
155           - mountPath: /opt/onap/appc/data/properties/bath_config.csv
156             name: onap-appc-data-properties
157             subPath: bath_config.csv
158           - mountPath: /opt/onap/appc/svclogic/config/svclogic.properties
159             name: onap-appc-svclogic-config
160             subPath: svclogic.properties
161           - mountPath: /opt/onap/appc/svclogic/bin/showActiveGraphs.sh
162             name: onap-appc-svclogic-bin
163             subPath: showActiveGraphs.sh
164           - mountPath: /opt/onap/appc/bin/startODL.sh
165             name: onap-appc-bin
166             subPath: startODL.sh
167           - mountPath: /opt/onap/appc/bin/installAppcDb.sh
168             name: onap-appc-bin
169             subPath: installAppcDb.sh
170           - mountPath: /opt/onap/appc/bin/health_check.sh
171             name: onap-appc-bin
172             subPath: health_check.sh
173           - mountPath: /opt/onap/ccsdk/data/properties/dblib.properties
174             name: onap-sdnc-data-properties
175             subPath: dblib.properties
176           - mountPath: /opt/onap/ccsdk/data/properties/svclogic.properties
177             name: onap-sdnc-data-properties
178             subPath: svclogic.properties
179           - mountPath: /opt/onap/ccsdk/data/properties/aaiclient.properties
180             name: onap-sdnc-data-properties
181             subPath: aaiclient.properties
182           - mountPath: /opt/onap/ccsdk/svclogic/config/svclogic.properties
183             name: onap-sdnc-svclogic-config
184             subPath: svclogic.properties
185           - mountPath: /opt/onap/ccsdk/svclogic/bin/showActiveGraphs.sh
186             name: onap-sdnc-svclogic-bin
187             subPath: showActiveGraphs.sh
188           - mountPath: /opt/onap/ccsdk/bin/installSdncDb.sh
189             name: onap-sdnc-bin
190             subPath: installSdncDb.sh
191           - mountPath: {{ .Values.persistence.mdsalPath }}
192             name: {{ include "common.fullname" . }}-data
193           - mountPath: {{ .Values.log.path }}
194             name: logs
195           - mountPath: /opt/onap/appc/data/org.ops4j.pax.logging.cfg
196             name: log-config
197             subPath: org.ops4j.pax.logging.cfg
198           - mountPath: /opt/onap/appc/data/stores/org.onap.appc.p12
199             name: p12-certs
200             subPath: org.onap.appc.p12
201           - mountPath: /opt/onap/appc/data/stores/org.onap.appc.keyfile
202             name: keyfile-certs
203             subPath: org.onap.appc.keyfile
204           resources:
205 {{ include "common.resources" . | indent 12 }}
206         {{- if .Values.nodeSelector }}
207         nodeSelector:
208 {{ toYaml .Values.nodeSelector | indent 10 }}
209         {{- end -}}
210         {{- if .Values.affinity }}
211         affinity:
212 {{ toYaml .Values.affinity | indent 10 }}
213         {{- end }}
214
215         # side car containers
216         {{ include "common.log.sidecar" . | nindent 8 }}
217       volumes:
218         - name: keyfile-certs
219           secret:
220             secretName: {{ include "common.fullname" . }}-certs
221         - name: p12-certs
222           secret:
223             secretName: {{ include "common.fullname" . }}-certs
224         - name: localtime
225           hostPath:
226             path: /etc/localtime
227         - name: log-config
228           configMap:
229             name: {{ include "common.fullname" . }}-logging-cfg
230         - name: logs
231           emptyDir: {}
232         {{ include "common.log.volumes" . | nindent 8 }}
233         - name: onap-appc-data-properties-input
234           configMap:
235             name: {{ include "common.fullname" . }}-onap-appc-data-properties
236         - name: onap-appc-svclogic-config-input
237           configMap:
238             name: {{ include "common.fullname" . }}-onap-appc-svclogic-config
239         - name: onap-appc-svclogic-bin
240           configMap:
241             name: {{ include "common.fullname" . }}-onap-appc-svclogic-bin
242             defaultMode: 0755
243         - name: onap-appc-bin
244           configMap:
245             name: {{ include "common.fullname" . }}-onap-appc-bin
246             defaultMode: 0755
247         - name: onap-sdnc-data-properties-input
248           configMap:
249             name: {{ include "common.fullname" . }}-onap-sdnc-data-properties
250         - name: onap-sdnc-svclogic-config-input
251           configMap:
252             name: {{ include "common.fullname" . }}-onap-sdnc-svclogic-config
253         - name: onap-sdnc-svclogic-bin
254           configMap:
255             name: {{ include "common.fullname" . }}-onap-sdnc-svclogic-bin
256             defaultMode: 0755
257         - name: onap-sdnc-bin
258           configMap:
259             name: {{ include "common.fullname" . }}-onap-sdnc-bin
260             defaultMode: 0755
261         - name: onap-appc-data-properties
262           emptyDir:
263             medium: Memory
264         - name: onap-appc-svclogic-config
265           emptyDir:
266             medium: Memory
267         - name: onap-sdnc-data-properties
268           emptyDir:
269             medium: Memory
270         - name: onap-sdnc-svclogic-config
271           emptyDir:
272             medium: Memory
273 {{ if not .Values.persistence.enabled }}
274         - name: {{ include "common.fullname" . }}-data
275           emptyDir: {}
276 {{ else }}
277   volumeClaimTemplates:
278   - metadata:
279       name: {{ include "common.fullname" . }}-data
280       labels:
281         name: {{ include "common.fullname" . }}
282         chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
283         release: "{{ include "common.release" . }}"
284         heritage: "{{ .Release.Service }}"
285     spec:
286       accessModes:
287       - {{ .Values.persistence.accessMode }}
288       storageClassName: {{ include "common.storageClass" . }}
289       resources:
290         requests:
291           storage: {{ .Values.persistence.size }}
292 {{ end }}