Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / cps / components / cps-core / templates / deployment.yaml
1 {{/*
2 # Copyright (C) 2021 Pantheon.tech, Orange
3 # Modifications Copyright (C) 2021 Bell Canada.
4 # Modifications Copyright (C) 2021-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   replicas: {{ .Values.replicaCount }}
24   minReadySeconds: {{ index .Values.minReadySeconds }}
25   strategy:
26     type: {{ index .Values.updateStrategy.type }}
27     rollingUpdate:
28       maxUnavailable: {{ index .Values.updateStrategy.maxUnavailable }}
29       maxSurge: {{ index .Values.updateStrategy.maxSurge }}
30   selector: {{- include "common.selectors" . | nindent 4 }}
31   template:
32     metadata: {{- include "common.templateMetadata" . | nindent 6 }}
33     spec:
34       {{ include "common.podSecurityContext" . | indent 6 | trim}}
35       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . ) }}
36       initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
37       - name: {{ include "common.name" . }}-update-config
38         image: {{ include "repositoryGenerator.image.envsubst" . }}
39         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
40         command:
41             - sh
42         args:
43           - -c
44           - "cd /config-input && for PFILE in `find . -not -type d | grep -v -F ..`; do envsubst <${PFILE} >/config/${PFILE}; done"
45         env:
46           - name: DB_USERNAME
47             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 12 }}
48           - name: DB_PASSWORD
49             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 12 }}
50           - name: LIQUIBASE_LABELS
51             value: {{ .Values.config.liquibaseLabels }}
52           - name: CPS_USERNAME
53             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-user-creds" "key" "login") | indent 12 }}
54           - name: CPS_PASSWORD
55             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-user-creds" "key" "password") | indent 12 }}
56           - name: DMI_USERNAME
57             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "dmi-plugin-user-creds" "key" "login") | indent 12 }}
58           - name: DMI_PASSWORD
59             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "dmi-plugin-user-creds" "key" "password") | indent 12 }}
60           - name: SASL_JAAS_CONFIG
61             valueFrom:
62               secretKeyRef:
63                 name: {{ include "common.name" . }}-ku
64                 key: sasl.jaas.config
65         volumeMounts:
66           - mountPath: /config-input
67             name: init-data-input
68           - mountPath: /config
69             name: init-data
70       containers:
71       - name: {{ include "common.name" . }}
72         image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
73         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
74         ports: {{ include "common.containerPorts" . | nindent 10  }}
75         {{ include "common.containerSecurityContext" . | indent 8 | trim }}
76         # disable liveness probe when breakpoints set in debugger
77         # so K8s doesn't restart unresponsive container
78         {{- if eq .Values.liveness.enabled true }}
79         livenessProbe:
80           httpGet:
81             port: {{ .Values.liveness.port }}
82             path: {{ .Values.liveness.path }}
83           initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
84           periodSeconds: {{ .Values.liveness.periodSeconds }}
85         {{ end -}}
86         readinessProbe:
87           httpGet:
88             port: {{ .Values.readiness.port }}
89             path: {{ .Values.readiness.path }}
90           initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
91           periodSeconds: {{ .Values.readiness.periodSeconds }}
92         startupProbe:
93           httpGet:
94             path: {{ .Values.startup.path }}
95             port: {{ .Values.startup.port }}
96           failureThreshold: {{ .Values.startup.failureThreshold }}
97           periodSeconds: {{ .Values.startup.periodSeconds }}
98         env:
99           - name: SPRING_PROFILES_ACTIVE
100             value: {{ .Values.config.spring.profile }}
101           - name: DB_USERNAME
102             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 12 }}
103           - name: DB_PASSWORD
104             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 12 }}
105           - name: LIQUIBASE_LABELS
106             value: {{ .Values.config.liquibaseLabels }}
107           - name: CPS_USERNAME
108             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-user-creds" "key" "login") | indent 12 }}
109           - name: CPS_PASSWORD
110             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "app-user-creds" "key" "password") | indent 12 }}
111           - name: DMI_USERNAME
112             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "dmi-plugin-user-creds" "key" "login") | indent 12 }}
113           - name: DMI_PASSWORD
114             {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "dmi-plugin-user-creds" "key" "password") | indent 12 }}
115           - name: SASL_JAAS_CONFIG
116             valueFrom:
117               secretKeyRef:
118                 name: {{ include "common.name" . }}-ku
119                 key: sasl.jaas.config
120         resources: {{ include "common.resources" . | nindent 10 }}
121         {{- if .Values.nodeSelector }}
122         nodeSelector: {{ toYaml .Values.nodeSelector | nindent 12 }}
123         {{- end }}
124         {{- if .Values.affinity }}
125         affinity: {{ toYaml .Values.affinity | nindent 12 }}
126         {{- end }}
127         volumeMounts:
128           - mountPath: /app/resources/application-helm.yml
129             subPath: application-helm.yml
130             name: init-data
131           - mountPath: /app/resources/logback-spring.xml
132             subPath: logback-spring.xml
133             name: init-data
134           - mountPath: /tmp
135             name: init-temp
136       volumes:
137         - name: init-data-input
138           configMap:
139             name: {{ include "common.fullname" . }}
140         - name: init-data
141           emptyDir:
142             medium: Memory
143         - name: init-temp
144           emptyDir: {}
145       {{- include "common.imagePullSecrets" . | nindent 6 }}