[COMMON] Make imagePullSecrets configurable
[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 # Modification Copyright © 2022-2023 Nordix Foundation
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 */}}
18
19 apiVersion: apps/v1
20 kind: Deployment
21 metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
22 spec:
23   selector: {{- include "common.selectors" . | nindent 4 }}
24   replicas: {{ .Values.replicaCount }}
25   strategy:
26     type: RollingUpdate
27     rollingUpdate:
28       # This allows a new pod to be ready before terminating the old one
29       # causing no downtime when replicas is set to 1
30       maxUnavailable: 0
31       # maxSurge to 1 is very important for the hazelcast integration
32       # we only want one pod at a time to restart not multiple
33       # and break the hazelcast cluster. We should not use % maxSurge value
34       # ref : https://hazelcast.com/blog/rolling-upgrade-hazelcast-imdg-on-kubernetes/
35       maxSurge: 1
36   template:
37     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
38     spec:
39       initContainers:
40       {{- if .Values.global.mariadbGalera.localCluster }}
41       {{-   if .Values.global.mariadbGalera.useOperator }}
42       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_local_operator ) | indent 6 | trim }}
43       {{    else }}
44       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_local ) | indent 6 | trim }}
45       {{-   end }}
46       {{ else }}
47       {{-   if .Values.global.mariadbGalera.useOperator }}
48       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_global_operator ) | indent 6 | trim }}
49       {{   else }}
50       {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_global ) | indent 6 | trim }}
51       {{-   end }}
52       {{- end }}
53       - command:
54         - sh
55         args:
56         - -c
57         - "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"
58         env:
59         - name: CDS_DB_USERNAME
60           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "login") | indent 10}}
61         - name: CDS_DB_PASSWORD
62           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "password") | indent 10}}
63         - name: SDNC_DB_USERNAME
64           value: root
65         - name: SDNC_DB_PASSWORD
66           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdnc-db-root-pass" "key" "password") | indent 10}}
67         volumeMounts:
68         - mountPath: /config-input/application.properties
69           name: {{ include "common.fullname" . }}-config
70           subPath: application.properties
71         - mountPath: /config
72           name: processed-config
73         image: {{ include "repositoryGenerator.image.envsubst" . }}
74         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
75         name: {{ include "common.name" . }}-update-config
76
77       - command:
78         - chown
79         - -R
80         - 1000:1000
81         - /opt/app/onap/blueprints/deploy
82         image: {{ include "repositoryGenerator.image.busybox" . }}
83         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
84         volumeMounts:
85         - mountPath: {{ .Values.persistence.deployedBlueprint }}
86           name: {{ include "common.fullname" . }}-blueprints
87         name: fix-permission
88
89       containers:
90         - name: {{ include "common.name" . }}
91           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
92           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
93           env:
94           - name: APP_CONFIG_HOME
95             value: {{ .Values.config.appConfigDir }}
96           - name: CLUSTER_ENABLED
97             value: {{ if (gt (int (.Values.replicaCount)) 2) }} {{ .Values.cluster.enabled | quote }} {{ else }} "false" {{ end }}
98           - name: CLUSTER_ID
99             value: {{ .Values.cluster.clusterName }}
100           - name: CLUSTER_NODE_ID
101             valueFrom:
102               fieldRef:
103                 fieldPath: metadata.name
104           - name: CLUSTER_CONFIG_FILE
105             value: {{ .Values.config.appConfigDir }}/hazelcast.yaml
106           - name: CPS_USER
107             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cps-creds" "key" "login") | indent 12 }}
108           - name: CPS_PASS_PLAIN
109             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cps-creds" "key" "password") | indent 12 }}
110           - name: SASL_JAAS_PASS
111             valueFrom:
112               secretKeyRef:
113                 name: {{ include "common.name" . }}-ku
114                 key: password
115           ports:
116           - containerPort: {{ .Values.service.http.internalPort }}
117           - containerPort: {{ .Values.service.grpc.internalPort }}
118           - containerPort: {{ .Values.service.cluster.internalPort }}
119           startupProbe:
120             httpGet:
121               path: /api/v1/execution-service/health-check
122               port: {{ .Values.startup.port }}
123               httpHeaders:
124                 - name: Authorization
125                   value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
126             initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
127             failureThreshold: {{ .Values.startup.failureThreshold }}
128             periodSeconds: {{ .Values.startup.periodSeconds }}
129           # disable liveness probe when breakpoints set in debugger
130           # so K8s doesn't restart unresponsive container
131           {{ if .Values.liveness.enabled }}
132           livenessProbe:
133             httpGet:
134               path: /api/v1/execution-service/health-check
135               port: {{ .Values.liveness.port }}
136               httpHeaders:
137               - name: Authorization
138                 value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
139             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
140             periodSeconds: {{ .Values.liveness.periodSeconds }}
141             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
142           {{ end }}
143           readinessProbe:
144             httpGet:
145               path: /api/v1/execution-service/health-check
146               port: {{ .Values.readiness.port }}
147               httpHeaders:
148               - name: Authorization
149                 value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
150             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
151             periodSeconds: {{ .Values.readiness.periodSeconds }}
152             timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
153           volumeMounts:
154           - mountPath: /etc/localtime
155             name: localtime
156             readOnly: true
157           - mountPath: {{ .Values.config.appConfigDir }}/application.properties
158             name: processed-config
159             subPath: application.properties
160           - mountPath: {{ .Values.config.appConfigDir }}/error-messages_en.properties
161             name: {{ include "common.fullname" . }}-config
162             subPath: error-messages_en.properties
163           - mountPath: {{ .Values.config.appConfigDir }}/logback.xml
164             name: {{ include "common.fullname" . }}-config
165             subPath: logback.xml
166           - mountPath: {{ .Values.config.appConfigDir }}/hazelcast.yaml
167             name: {{ include "common.fullname" . }}-config
168             subPath: hazelcast.yaml
169           - mountPath: {{ .Values.persistence.deployedBlueprint }}
170             name: {{ include "common.fullname" . }}-blueprints
171           resources: {{ include "common.resources" . | nindent 12 }}
172         {{- if .Values.nodeSelector }}
173         nodeSelector:
174 {{ toYaml .Values.nodeSelector | indent 10 }}
175         {{- end -}}
176         {{- if .Values.affinity }}
177         affinity:
178 {{ toYaml .Values.affinity | indent 10 }}
179         {{- end }}
180       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
181       volumes:
182         - name: localtime
183           hostPath:
184             path: /etc/localtime
185         - name: {{ include "common.fullname" . }}-config
186           configMap:
187             name: {{ include "common.fullname" . }}-configmap
188             items:
189             - key: application.properties
190               path: application.properties
191             - key: error-messages_en.properties
192               path: error-messages_en.properties
193             - key: logback.xml
194               path: logback.xml
195             - key: hazelcast.yaml
196               path: hazelcast.yaml
197         - name: {{ include "common.fullname" . }}-blueprints
198           persistentVolumeClaim:
199             claimName: {{ include "common.release" . }}-cds-blueprints
200         - name: processed-config
201           emptyDir:
202             medium: Memory
203       {{- include "common.imagePullSecrets" . | nindent 6 }}