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