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