[DMAAP] DMaaP ServiceMesh compatibility
[oom.git] / kubernetes / cds / components / cds-blueprints-processor / templates / deployment.yaml
1 {{/*
2 # Copyright (c) 2019 IBM, Bell Canada
3 # Copyright (c) 2020 Samsung Electronics
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: Deployment
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   replicas: {{ .Values.replicaCount }}
33   strategy:
34     type: RollingUpdate
35     rollingUpdate:
36       # This allow a new pod to be ready before terminating the old one
37       # causing no downtime when replicas is set to 1
38       maxUnavailable: 0
39
40       # maxSurge to 1 is very important for the hazelcast integration
41       # we only want one pod at a time to restart not multiple
42       # and break the hazelcast cluster. We should not use % maxSurge value
43       # ref : https://hazelcast.com/blog/rolling-upgrade-hazelcast-imdg-on-kubernetes/
44       maxSurge: 1
45   template:
46     metadata:
47       labels:
48         app: {{ include "common.name" . }}
49         release: {{ include "common.release" . }}
50     spec:
51       initContainers: {{ include "common.certInitializer.initContainer" . | nindent 6 }}
52       - command:
53         - sh
54         args:
55         - -c
56         - "cd /config-input && for PFILE in `ls -1 .`; do envsubst '${CDS_DB_USERNAME},${CDS_DB_PASSWORD},${SDNC_DB_USERNAME},${SDNC_DB_PASSWORD}' <${PFILE} >/config/${PFILE}; done"
57         env:
58         - name: CDS_DB_USERNAME
59           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "login") | indent 10}}
60         - name: CDS_DB_PASSWORD
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "password") | indent 10}}
62         - name: SDNC_DB_USERNAME
63           value: root
64         - name: SDNC_DB_PASSWORD
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdnc-db-root-pass" "key" "password") | indent 10}}
66         volumeMounts:
67         - mountPath: /config-input/application.properties
68           name: {{ include "common.fullname" . }}-config
69           subPath: application.properties
70         - mountPath: /config
71           name: processed-config
72         image: {{ include "repositoryGenerator.image.envsubst" . }}
73         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74         name: {{ include "common.name" . }}-update-config
75
76       - command:
77         - /app/ready.py
78         args:
79         - --container-name
80         - cds-db
81         {{- if .Values.dmaapEnabled  }}
82         - --container-name
83         - message-router
84         {{ end }}
85         env:
86         - name: NAMESPACE
87           valueFrom:
88             fieldRef:
89               apiVersion: v1
90               fieldPath: metadata.namespace
91         image: {{ include "repositoryGenerator.image.readiness" . }}
92         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
93         name: {{ include "common.name" . }}-readiness
94       - name: fix-permission
95         command:
96         - chown
97         - -R
98         - 1000:1000
99         - /opt/app/onap/blueprints/deploy
100         image: {{ include "repositoryGenerator.image.busybox" . }}
101         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
102         volumeMounts:
103         - mountPath: {{ .Values.persistence.deployedBlueprint }}
104           name: {{ include "common.fullname" . }}-blueprints
105       containers:
106         - name: {{ include "common.name" . }}
107           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
108           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
109           env:
110           - name: APP_CONFIG_HOME
111             value: {{ .Values.config.appConfigDir }}
112           - name: CLUSTER_ENABLED
113             value: {{ if (gt (int (.Values.replicaCount)) 2) }} {{ .Values.cluster.enabled | quote }} {{ else }} "false" {{ end }}
114           - name: CLUSTER_ID
115             value: {{ .Values.cluster.clusterName }}
116           - name: AAF_CREDSPATH
117             value: {{ .Values.certInitializer.credsPath }}
118           - name: CLUSTER_NODE_ID
119             valueFrom:
120               fieldRef:
121                 fieldPath: metadata.name
122           - name: CLUSTER_CONFIG_FILE
123             value: {{ .Values.config.appConfigDir }}/hazelcast.yaml
124           ports:
125           - containerPort: {{ .Values.service.http.internalPort }}
126           - containerPort: {{ .Values.service.grpc.internalPort }}
127           - containerPort: {{ .Values.service.cluster.internalPort }}
128           startupProbe:
129             httpGet:
130               path: /api/v1/execution-service/health-check
131               port: {{ .Values.service.http.internalPort }}
132               httpHeaders:
133                 - name: Authorization
134                   value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
135             initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
136             failureThreshold: {{ .Values.startup.failureThreshold }}
137             periodSeconds: {{ .Values.startup.periodSeconds }}
138           # disable liveness probe when breakpoints set in debugger
139           # so K8s doesn't restart unresponsive container
140           {{ if .Values.liveness.enabled }}
141           livenessProbe:
142             httpGet:
143               path: /api/v1/execution-service/health-check
144               port: {{ .Values.service.http.internalPort }}
145               httpHeaders:
146               - name: Authorization
147                 value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
148             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
149             periodSeconds: {{ .Values.liveness.periodSeconds }}
150             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
151           {{ end }}
152           readinessProbe:
153             httpGet:
154               path: /api/v1/execution-service/health-check
155               port: {{ .Values.service.http.internalPort }}
156               httpHeaders:
157               - name: Authorization
158                 value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
159             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
160             periodSeconds: {{ .Values.readiness.periodSeconds }}
161             timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
162           volumeMounts: {{ include "common.certInitializer.volumeMount" . | nindent 10 }}
163           - mountPath: /etc/localtime
164             name: localtime
165             readOnly: true
166           - mountPath: {{ .Values.config.appConfigDir }}/application.properties
167             name: processed-config
168             subPath: application.properties
169           - mountPath: {{ .Values.config.appConfigDir }}/error-messages_en.properties
170             name: {{ include "common.fullname" . }}-config
171             subPath: error-messages_en.properties
172           - mountPath: {{ .Values.config.appConfigDir }}/logback.xml
173             name: {{ include "common.fullname" . }}-config
174             subPath: logback.xml
175           - mountPath: {{ .Values.config.appConfigDir }}/hazelcast.yaml
176             name: {{ include "common.fullname" . }}-config
177             subPath: hazelcast.yaml
178
179           - mountPath: {{ .Values.config.appConfigDir }}/ONAP_RootCA.cer
180             name: {{ include "common.fullname" . }}-config
181             subPath: ONAP_RootCA.cer
182
183           - mountPath: {{ .Values.persistence.deployedBlueprint }}
184             name: {{ include "common.fullname" . }}-blueprints
185           resources:
186 {{ include "common.resources" . | indent 12 }}
187         {{- if .Values.nodeSelector }}
188         nodeSelector:
189 {{ toYaml .Values.nodeSelector | indent 10 }}
190         {{- end -}}
191         {{- if .Values.affinity }}
192         affinity:
193 {{ toYaml .Values.affinity | indent 10 }}
194         {{- end }}
195       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
196       volumes: {{ include "common.certInitializer.volumes" . | nindent 8 }}
197         - name: localtime
198           hostPath:
199             path: /etc/localtime
200         - name: {{ include "common.fullname" . }}-config
201           configMap:
202             name: {{ include "common.fullname" . }}-configmap
203             items:
204             - key: application.properties
205               path: application.properties
206             - key: error-messages_en.properties
207               path: error-messages_en.properties
208             - key: logback.xml
209               path: logback.xml
210             - key: hazelcast.yaml
211               path: hazelcast.yaml
212             - key: ONAP_RootCA.cer
213               path: ONAP_RootCA.cer
214         - name: {{ include "common.fullname" . }}-blueprints
215           persistentVolumeClaim:
216             claimName: {{ include "common.release" . }}-cds-blueprints
217         - name: processed-config
218           emptyDir:
219             medium: Memory
220       imagePullSecrets:
221       - name: "{{ include "common.namespace" . }}-docker-registry-key"