a6e3a52bf75bb05f5aa2cb1186c8aa7c9bdb3e54
[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       {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
41       - command:
42         - sh
43         args:
44         - -c
45         - "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"
46         env:
47         - name: CDS_DB_USERNAME
48           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "login") | indent 10}}
49         - name: CDS_DB_PASSWORD
50           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cds-db-user-creds" "key" "password") | indent 10}}
51         - name: SDNC_DB_USERNAME
52           value: root
53         - name: SDNC_DB_PASSWORD
54           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "sdnc-db-root-pass" "key" "password") | indent 10}}
55         volumeMounts:
56         - mountPath: /config-input/application.properties
57           name: {{ include "common.fullname" . }}-config
58           subPath: application.properties
59         - mountPath: /config
60           name: processed-config
61         image: {{ include "repositoryGenerator.image.envsubst" . }}
62         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
63         name: {{ include "common.name" . }}-update-config
64
65       - command:
66         - chown
67         - -R
68         - 1000:1000
69         - /opt/app/onap/blueprints/deploy
70         image: {{ include "repositoryGenerator.image.busybox" . }}
71         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
72         volumeMounts:
73         - mountPath: {{ .Values.persistence.deployedBlueprint }}
74           name: {{ include "common.fullname" . }}-blueprints
75         name: fix-permission
76
77       containers:
78         - name: {{ include "common.name" . }}
79           image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
80           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
81           env:
82           - name: APP_CONFIG_HOME
83             value: {{ .Values.config.appConfigDir }}
84           - name: CLUSTER_ENABLED
85             value: {{ if (gt (int (.Values.replicaCount)) 2) }} {{ .Values.cluster.enabled | quote }} {{ else }} "false" {{ end }}
86           - name: CLUSTER_ID
87             value: {{ .Values.cluster.clusterName }}
88           - name: CLUSTER_NODE_ID
89             valueFrom:
90               fieldRef:
91                 fieldPath: metadata.name
92           - name: CLUSTER_CONFIG_FILE
93             value: {{ .Values.config.appConfigDir }}/hazelcast.yaml
94           - name: CPS_USER
95             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cps-creds" "key" "login") | indent 12 }}
96           - name: CPS_PASS_PLAIN
97             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "cps-creds" "key" "password") | indent 12 }}
98           - name: SASL_JAAS_PASS
99             valueFrom:
100               secretKeyRef:
101                 name: {{ include "common.name" . }}-ku
102                 key: password
103           ports:
104           - containerPort: {{ .Values.service.http.internalPort }}
105           - containerPort: {{ .Values.service.grpc.internalPort }}
106           - containerPort: {{ .Values.service.cluster.internalPort }}
107           startupProbe:
108             httpGet:
109               path: /api/v1/execution-service/health-check
110               port: {{ .Values.startup.port }}
111               httpHeaders:
112                 - name: Authorization
113                   value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
114             initialDelaySeconds: {{ .Values.startup.initialDelaySeconds }}
115             failureThreshold: {{ .Values.startup.failureThreshold }}
116             periodSeconds: {{ .Values.startup.periodSeconds }}
117           # disable liveness probe when breakpoints set in debugger
118           # so K8s doesn't restart unresponsive container
119           {{ if .Values.liveness.enabled }}
120           livenessProbe:
121             httpGet:
122               path: /api/v1/execution-service/health-check
123               port: {{ .Values.liveness.port }}
124               httpHeaders:
125               - name: Authorization
126                 value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
127             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
128             periodSeconds: {{ .Values.liveness.periodSeconds }}
129             timeoutSeconds: {{ .Values.liveness.timeoutSeconds }}
130           {{ end }}
131           readinessProbe:
132             httpGet:
133               path: /api/v1/execution-service/health-check
134               port: {{ .Values.readiness.port }}
135               httpHeaders:
136               - name: Authorization
137                 value: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==
138             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
139             periodSeconds: {{ .Values.readiness.periodSeconds }}
140             timeoutSeconds: {{ .Values.readiness.timeoutSeconds }}
141           volumeMounts:
142           - mountPath: /etc/localtime
143             name: localtime
144             readOnly: true
145           - mountPath: {{ .Values.config.appConfigDir }}/application.properties
146             name: processed-config
147             subPath: application.properties
148           - mountPath: {{ .Values.config.appConfigDir }}/error-messages_en.properties
149             name: {{ include "common.fullname" . }}-config
150             subPath: error-messages_en.properties
151           - mountPath: {{ .Values.config.appConfigDir }}/logback.xml
152             name: {{ include "common.fullname" . }}-config
153             subPath: logback.xml
154           - mountPath: {{ .Values.config.appConfigDir }}/hazelcast.yaml
155             name: {{ include "common.fullname" . }}-config
156             subPath: hazelcast.yaml
157           - mountPath: {{ .Values.persistence.deployedBlueprint }}
158             name: {{ include "common.fullname" . }}-blueprints
159           resources: {{ include "common.resources" . | nindent 12 }}
160         {{- if .Values.nodeSelector }}
161         nodeSelector:
162 {{ toYaml .Values.nodeSelector | indent 10 }}
163         {{- end -}}
164         {{- if .Values.affinity }}
165         affinity:
166 {{ toYaml .Values.affinity | indent 10 }}
167         {{- end }}
168       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
169       volumes:
170         - name: localtime
171           hostPath:
172             path: /etc/localtime
173         - name: {{ include "common.fullname" . }}-config
174           configMap:
175             name: {{ include "common.fullname" . }}-configmap
176             items:
177             - key: application.properties
178               path: application.properties
179             - key: error-messages_en.properties
180               path: error-messages_en.properties
181             - key: logback.xml
182               path: logback.xml
183             - key: hazelcast.yaml
184               path: hazelcast.yaml
185         - name: {{ include "common.fullname" . }}-blueprints
186           persistentVolumeClaim:
187             claimName: {{ include "common.release" . }}-cds-blueprints
188         - name: processed-config
189           emptyDir:
190             medium: Memory
191       imagePullSecrets:
192       - name: "{{ include "common.namespace" . }}-docker-registry-key"