blob: 968ca32d42aa29efc8b38fb031b8e5b1bc6ac3a1 [file] [log] [blame]
Jakub Latusekd71d26c2020-10-21 13:36:29 +02001{{/*
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +01002# Copyright © 2018 Amdocs, Bell Canada
jhhd4258672020-08-09 12:08:08 -05003# Modifications Copyright © 2020 AT&T Intellectual Property
waynedunican368aced2022-02-15 08:27:57 +00004# Modifications Copyright (C) 2022 Nordix Foundation.
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +01005#
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.
Jakub Latusekd71d26c2020-10-21 13:36:29 +020017*/}}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010018
19apiVersion: batch/v1
20kind: Job
21metadata:
amatthews736bf372021-12-14 16:04:15 +000022 name: {{ include "common.fullname" . }}-galera-init
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010023 namespace: {{ include "common.namespace" . }}
24 labels:
amatthews736bf372021-12-14 16:04:15 +000025 app: {{ include "common.name" . }}-galera-init
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010026 release: {{ include "common.release" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010027spec:
28 template:
29 metadata:
30 labels:
amatthews736bf372021-12-14 16:04:15 +000031 app: {{ include "common.name" . }}-galera-init
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010032 release: {{ include "common.release" . }}
amatthews736bf372021-12-14 16:04:15 +000033 name: {{ include "common.name" . }}-galera-init
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010034 spec:
andreas-geissler7d85f3f2021-07-19 17:53:22 +020035 imagePullSecrets:
36 - name: "{{ include "common.namespace" . }}-docker-registry-key"
amatthews736bf372021-12-14 16:04:15 +000037 initContainers:
waynedunican368aced2022-02-15 08:27:57 +000038 - name: {{ include "common.name" . }}-mariadb-readiness
Sylvain Desbureaux7c8c6862020-11-19 18:02:37 +010039 image: {{ include "repositoryGenerator.image.readiness" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010040 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
41 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020042 - /app/ready.py
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010043 - --container-name
44 - {{ index .Values "mariadb-galera" "service" "name" }}
45 env:
46 - name: NAMESPACE
47 valueFrom:
48 fieldRef:
49 apiVersion: v1
50 fieldPath: metadata.namespace
amatthews736bf372021-12-14 16:04:15 +000051 containers:
52 - name: {{ include "common.name" . }}-galera-config
Andreas Geisslera4275992023-01-25 09:27:30 +010053 image: {{ include "repositoryGenerator.image.mariadb" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010054 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
55 volumeMounts:
56 - mountPath: /dbcmd-config/db.sh
57 name: {{ include "common.fullname" . }}-config
58 subPath: db.sh
59 command:
60 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +000061 - -cx
62 - |
63 {{- if include "common.onServiceMesh" . }}
64 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
65 /dbcmd-config/db.sh
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010066 env:
67 - name: MYSQL_ROOT_PASSWORD
Krzysztof Opasiak98a79cc2020-04-01 22:33:58 +020068 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 10 }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010069 - name: MYSQL_HOST
70 value: "{{ index .Values "mariadb-galera" "service" "name" }}"
71 - name: MYSQL_USER
Krzysztof Opasiak98a79cc2020-04-01 22:33:58 +020072 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010073 - name: MYSQL_PORT
74 value: "{{ index .Values "mariadb-galera" "service" "internalPort" }}"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +010075 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +000076 {{- if (include "common.onServiceMesh" .) }}
77 - name: policy-service-mesh-wait-for-job-container
Andreas Geissler6128f5f2023-01-25 09:18:56 +010078 image: {{ include "repositoryGenerator.image.quitQuit" . }}
amatthews736bf372021-12-14 16:04:15 +000079 imagePullPolicy: Always
80 command:
81 - /bin/sh
82 - "-c"
83 args:
84 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
85 /app/ready.py --service-mesh-check {{ include "common.name" . }}-galera-config -t 45;
86 env:
87 - name: NAMESPACE
88 valueFrom:
89 fieldRef:
90 apiVersion: v1
91 fieldPath: metadata.namespace
92 {{- end }}
93 restartPolicy: Never
94 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
95 volumes:
96 - name: {{ include "common.fullname" . }}-config
97 configMap:
98 name: {{ include "common.fullname" . }}-db-configmap
99 defaultMode: 0755
100 items:
101 - key: db.sh
102 path: db.sh
103
104{{ if .Values.global.postgres.localCluster }}
105---
106apiVersion: batch/v1
107kind: Job
108metadata:
109 name: {{ include "common.fullname" . }}-pg-init
110 namespace: {{ include "common.namespace" . }}
111 labels:
112 app: {{ include "common.name" . }}-pg-init
113 release: {{ include "common.release" . }}
114spec:
115 template:
116 metadata:
117 labels:
118 app: {{ include "common.name" . }}-pg-init
119 release: {{ include "common.release" . }}
120 name: {{ include "common.name" . }}-pg-init
121 spec:
122 imagePullSecrets:
123 - name: "{{ include "common.namespace" . }}-docker-registry-key"
124 initContainers: {{ if .Values.global.postgres.localCluster }}{{ include "common.readinessCheck.waitFor" . | nindent 6 }}{{ end }}
125 containers:
126 - name: {{ include "common.name" . }}-pg-config
Andreas Geissler6128f5f2023-01-25 09:18:56 +0100127 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.postgresImage }}
waynedunican368aced2022-02-15 08:27:57 +0000128 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
129 volumeMounts:
130 - mountPath: /docker-entrypoint-initdb.d/db-pg.sh
131 name: {{ include "common.fullname" . }}-config
132 subPath: db-pg.sh
133 command:
134 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000135 - -cx
136 - |
137 {{- if include "common.onServiceMesh" . }}
138 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
139 /docker-entrypoint-initdb.d/db-pg.sh
waynedunican368aced2022-02-15 08:27:57 +0000140 env:
141 - name: PG_ADMIN_PASSWORD
142 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-root-pass" "key" "password") | indent 12 }}
143 - name: PG_HOST
144 value: "{{ .Values.postgres.service.name2 }}"
145 - name: PG_USER
146 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 12 }}
147 - name: PG_USER_PASSWORD
148 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 12 }}
149 - name: PG_PORT
150 value: "{{ .Values.postgres.service.internalPort }}"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100151 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +0000152 {{- if (include "common.onServiceMesh" .) }}
153 - name: policy-service-mesh-wait-for-job-container
Andreas Geissler6128f5f2023-01-25 09:18:56 +0100154 image: {{ include "repositoryGenerator.image.quitQuit" . }}
amatthews736bf372021-12-14 16:04:15 +0000155 imagePullPolicy: Always
156 command:
157 - /bin/sh
158 - "-c"
159 args:
160 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
161 /app/ready.py --service-mesh-check {{ include "common.name" . }}-pg-config -t 45;
162 env:
163 - name: NAMESPACE
164 valueFrom:
165 fieldRef:
166 apiVersion: v1
167 fieldPath: metadata.namespace
168 {{- end }}
169 restartPolicy: Never
170 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
171 volumes:
172 - name: {{ include "common.fullname" . }}-config
173 configMap:
174 name: {{ include "common.fullname" . }}-db-configmap
175 defaultMode: 0755
176 items:
177 - key: db-pg.sh
178 path: db-pg.sh
179{{ end }}
180
181---
182apiVersion: batch/v1
183kind: Job
184metadata:
185 name: {{ include "common.fullname" . }}-galera-config
186 namespace: {{ include "common.namespace" . }}
187 labels:
188 app: {{ include "common.name" . }}-galera-config
189 release: {{ include "common.release" . }}
190spec:
191 template:
192 metadata:
193 labels:
194 app: {{ include "common.name" . }}-galera-config
195 release: {{ include "common.release" . }}
196 name: {{ include "common.name" . }}-galera-config
197 spec:
198 imagePullSecrets:
199 - name: "{{ include "common.namespace" . }}-docker-registry-key"
200 initContainers:
201 - name: {{ include "common.name" . }}-init-readiness
202 image: {{ include "repositoryGenerator.image.readiness" . }}
203 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
204 command:
205 - /app/ready.py
206 args:
207 - --job-name
208 - {{ include "common.fullname" . }}-galera-init
209 env:
210 - name: NAMESPACE
211 valueFrom:
212 fieldRef:
213 apiVersion: v1
214 fieldPath: metadata.namespace
jhhd74fe9f2021-04-15 11:04:39 -0500215 containers:
amatthews736bf372021-12-14 16:04:15 +0000216 - name: {{ include "common.name" . }}-galera-db-migrator
Andreas Geissler8d704ba2022-01-07 17:49:22 +0000217 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
jhhd74fe9f2021-04-15 11:04:39 -0500218 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
219 volumeMounts:
220 - mountPath: /dbcmd-config/db_migrator_policy_init.sh
221 name: {{ include "common.fullname" . }}-config
222 subPath: db_migrator_policy_init.sh
223 command:
224 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000225 - -cx
226 - |
227 {{- if include "common.onServiceMesh" . }}
228 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
229 /dbcmd-config/db_migrator_policy_init.sh
jhhd74fe9f2021-04-15 11:04:39 -0500230 env:
231 - name: SQL_HOST
232 value: "{{ index .Values "mariadb-galera" "service" "name" }}"
233 - name: SQL_USER
234 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
235 - name: SQL_PASSWORD
236 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
237 - name: SQL_DB
238 value: {{ .Values.dbmigrator.schema }}
239 - name: POLICY_HOME
240 value: {{ .Values.dbmigrator.policy_home }}
waynedunican368aced2022-02-15 08:27:57 +0000241 - name: SCRIPT_DIRECTORY
242 value: "sql"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100243 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +0000244 {{- if (include "common.onServiceMesh" .) }}
245 - name: policy-service-mesh-wait-for-job-container
Andreas Geissler6128f5f2023-01-25 09:18:56 +0100246 image: {{ include "repositoryGenerator.image.quitQuit" . }}
amatthews736bf372021-12-14 16:04:15 +0000247 imagePullPolicy: Always
248 command:
249 - /bin/sh
250 - "-c"
251 args:
252 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
253 /app/ready.py --service-mesh-check {{ include "common.name" . }}-galera-db-migrator -t 45;
254 env:
255 - name: NAMESPACE
256 valueFrom:
257 fieldRef:
258 apiVersion: v1
259 fieldPath: metadata.namespace
260 {{- end }}
261 restartPolicy: Never
262 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
263 volumes:
264 - name: {{ include "common.fullname" . }}-config
265 configMap:
266 name: {{ include "common.fullname" . }}-db-configmap
267 defaultMode: 0755
268 items:
269 - key: db_migrator_policy_init.sh
270 path: db_migrator_policy_init.sh
271
272{{ if .Values.global.postgres.localCluster }}
273---
274apiVersion: batch/v1
275kind: Job
276metadata:
277 name: {{ include "common.fullname" . }}-pg-config
278 namespace: {{ include "common.namespace" . }}
279 labels:
280 app: {{ include "common.name" . }}-pg-config
281 release: {{ include "common.release" . }}
282spec:
283 template:
284 metadata:
285 labels:
286 app: {{ include "common.name" . }}-pg-config
287 release: {{ include "common.release" . }}
288 name: {{ include "common.name" . }}-pg-config
289 spec:
290 imagePullSecrets:
291 - name: "{{ include "common.namespace" . }}-docker-registry-key"
292 initContainers:
293 - name: {{ include "common.name" . }}-init-readiness
294 image: {{ include "repositoryGenerator.image.readiness" . }}
295 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
296 command:
297 - /app/ready.py
298 args:
299 - --job-name
300 - {{ include "common.fullname" . }}-pg-init
301 env:
302 - name: NAMESPACE
303 valueFrom:
304 fieldRef:
305 apiVersion: v1
306 fieldPath: metadata.namespace
307 containers:
308 - name: {{ include "common.name" . }}-pg-db-migrator
waynedunican368aced2022-02-15 08:27:57 +0000309 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
310 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
311 volumeMounts:
312 - mountPath: /dbcmd-config/db_migrator_pg_policy_init.sh
313 name: {{ include "common.fullname" . }}-config
314 subPath: db_migrator_pg_policy_init.sh
315 command:
316 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000317 - -cx
318 - |
319 {{- if include "common.onServiceMesh" . }}
320 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
321 /dbcmd-config/db_migrator_pg_policy_init.sh
waynedunican368aced2022-02-15 08:27:57 +0000322 env:
323 - name: SQL_HOST
324 value: "{{ .Values.postgres.service.name2 }}"
325 - name: SQL_USER
326 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
327 - name: SQL_PASSWORD
328 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
329 - name: SQL_DB
330 value: {{ .Values.dbmigrator.schema }}
331 - name: POLICY_HOME
332 value: {{ .Values.dbmigrator.policy_home }}
333 - name: SCRIPT_DIRECTORY
334 value: "postgres"
335 - name: PGPASSWORD
336 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100337 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +0000338 {{- if (include "common.onServiceMesh" .) }}
339 - name: policy-service-mesh-wait-for-job-container
Andreas Geissler6128f5f2023-01-25 09:18:56 +0100340 image: {{ include "repositoryGenerator.image.quitQuit" . }}
amatthews736bf372021-12-14 16:04:15 +0000341 imagePullPolicy: Always
342 command:
343 - /bin/sh
344 - "-c"
345 args:
346 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
347 /app/ready.py --service-mesh-check {{ include "common.name" . }}-pg-db-migrator -t 45;
348 env:
349 - name: NAMESPACE
350 valueFrom:
351 fieldRef:
352 apiVersion: v1
353 fieldPath: metadata.namespace
354 {{- end }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100355 restartPolicy: Never
farida azmyc1178372021-04-11 12:55:33 +0200356 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100357 volumes:
358 - name: {{ include "common.fullname" . }}-config
359 configMap:
360 name: {{ include "common.fullname" . }}-db-configmap
amatthews736bf372021-12-14 16:04:15 +0000361 defaultMode: 0755
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100362 items:
waynedunican368aced2022-02-15 08:27:57 +0000363 - key: db_migrator_pg_policy_init.sh
364 path: db_migrator_pg_policy_init.sh
amatthews736bf372021-12-14 16:04:15 +0000365{{ end }}