blob: 4bf9def21e8ee657822f2e6073b99add4078dc5f [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
Andreas Geisslerf10c5552023-03-21 18:09:46 +010034 annotations:
35 sidecar.istio.io/inject: "false"
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010036 spec:
andreas-geissler7d85f3f2021-07-19 17:53:22 +020037 imagePullSecrets:
38 - name: "{{ include "common.namespace" . }}-docker-registry-key"
amatthews736bf372021-12-14 16:04:15 +000039 initContainers:
waynedunican368aced2022-02-15 08:27:57 +000040 - name: {{ include "common.name" . }}-mariadb-readiness
Sylvain Desbureaux7c8c6862020-11-19 18:02:37 +010041 image: {{ include "repositoryGenerator.image.readiness" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010042 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
43 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020044 - /app/ready.py
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010045 - --container-name
46 - {{ index .Values "mariadb-galera" "service" "name" }}
47 env:
48 - name: NAMESPACE
49 valueFrom:
50 fieldRef:
51 apiVersion: v1
52 fieldPath: metadata.namespace
amatthews736bf372021-12-14 16:04:15 +000053 containers:
54 - name: {{ include "common.name" . }}-galera-config
Andreas Geisslera4275992023-01-25 09:27:30 +010055 image: {{ include "repositoryGenerator.image.mariadb" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010056 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
57 volumeMounts:
58 - mountPath: /dbcmd-config/db.sh
59 name: {{ include "common.fullname" . }}-config
60 subPath: db.sh
61 command:
62 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +000063 - -cx
64 - |
amatthews736bf372021-12-14 16:04:15 +000065 /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 restartPolicy: Never
77 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
78 volumes:
79 - name: {{ include "common.fullname" . }}-config
80 configMap:
81 name: {{ include "common.fullname" . }}-db-configmap
82 defaultMode: 0755
83 items:
84 - key: db.sh
85 path: db.sh
86
87{{ if .Values.global.postgres.localCluster }}
88---
89apiVersion: batch/v1
90kind: Job
91metadata:
92 name: {{ include "common.fullname" . }}-pg-init
93 namespace: {{ include "common.namespace" . }}
94 labels:
95 app: {{ include "common.name" . }}-pg-init
96 release: {{ include "common.release" . }}
97spec:
98 template:
99 metadata:
100 labels:
101 app: {{ include "common.name" . }}-pg-init
102 release: {{ include "common.release" . }}
103 name: {{ include "common.name" . }}-pg-init
Andreas Geisslerf10c5552023-03-21 18:09:46 +0100104 annotations:
105 sidecar.istio.io/inject: "false"
amatthews736bf372021-12-14 16:04:15 +0000106 spec:
107 imagePullSecrets:
108 - name: "{{ include "common.namespace" . }}-docker-registry-key"
109 initContainers: {{ if .Values.global.postgres.localCluster }}{{ include "common.readinessCheck.waitFor" . | nindent 6 }}{{ end }}
110 containers:
111 - name: {{ include "common.name" . }}-pg-config
Andreas Geissler6128f5f2023-01-25 09:18:56 +0100112 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.postgresImage }}
waynedunican368aced2022-02-15 08:27:57 +0000113 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
114 volumeMounts:
115 - mountPath: /docker-entrypoint-initdb.d/db-pg.sh
116 name: {{ include "common.fullname" . }}-config
117 subPath: db-pg.sh
118 command:
119 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000120 - -cx
121 - |
amatthews736bf372021-12-14 16:04:15 +0000122 /docker-entrypoint-initdb.d/db-pg.sh
waynedunican368aced2022-02-15 08:27:57 +0000123 env:
124 - name: PG_ADMIN_PASSWORD
125 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-root-pass" "key" "password") | indent 12 }}
126 - name: PG_HOST
127 value: "{{ .Values.postgres.service.name2 }}"
128 - name: PG_USER
129 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 12 }}
130 - name: PG_USER_PASSWORD
131 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 12 }}
132 - name: PG_PORT
133 value: "{{ .Values.postgres.service.internalPort }}"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100134 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +0000135 restartPolicy: Never
136 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
137 volumes:
138 - name: {{ include "common.fullname" . }}-config
139 configMap:
140 name: {{ include "common.fullname" . }}-db-configmap
141 defaultMode: 0755
142 items:
143 - key: db-pg.sh
144 path: db-pg.sh
145{{ end }}
146
147---
148apiVersion: batch/v1
149kind: Job
150metadata:
151 name: {{ include "common.fullname" . }}-galera-config
152 namespace: {{ include "common.namespace" . }}
153 labels:
154 app: {{ include "common.name" . }}-galera-config
155 release: {{ include "common.release" . }}
156spec:
157 template:
158 metadata:
159 labels:
160 app: {{ include "common.name" . }}-galera-config
161 release: {{ include "common.release" . }}
162 name: {{ include "common.name" . }}-galera-config
Andreas Geisslerf10c5552023-03-21 18:09:46 +0100163 annotations:
164 sidecar.istio.io/inject: "false"
amatthews736bf372021-12-14 16:04:15 +0000165 spec:
166 imagePullSecrets:
167 - name: "{{ include "common.namespace" . }}-docker-registry-key"
168 initContainers:
169 - name: {{ include "common.name" . }}-init-readiness
170 image: {{ include "repositoryGenerator.image.readiness" . }}
171 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
172 command:
173 - /app/ready.py
174 args:
175 - --job-name
176 - {{ include "common.fullname" . }}-galera-init
177 env:
178 - name: NAMESPACE
179 valueFrom:
180 fieldRef:
181 apiVersion: v1
182 fieldPath: metadata.namespace
jhhd74fe9f2021-04-15 11:04:39 -0500183 containers:
amatthews736bf372021-12-14 16:04:15 +0000184 - name: {{ include "common.name" . }}-galera-db-migrator
Andreas Geissler8d704ba2022-01-07 17:49:22 +0000185 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
jhhd74fe9f2021-04-15 11:04:39 -0500186 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
187 volumeMounts:
188 - mountPath: /dbcmd-config/db_migrator_policy_init.sh
189 name: {{ include "common.fullname" . }}-config
190 subPath: db_migrator_policy_init.sh
191 command:
192 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000193 - -cx
194 - |
amatthews736bf372021-12-14 16:04:15 +0000195 /dbcmd-config/db_migrator_policy_init.sh
jhhd74fe9f2021-04-15 11:04:39 -0500196 env:
197 - name: SQL_HOST
198 value: "{{ index .Values "mariadb-galera" "service" "name" }}"
199 - name: SQL_USER
200 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
201 - name: SQL_PASSWORD
202 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
203 - name: SQL_DB
204 value: {{ .Values.dbmigrator.schema }}
205 - name: POLICY_HOME
206 value: {{ .Values.dbmigrator.policy_home }}
waynedunican368aced2022-02-15 08:27:57 +0000207 - name: SCRIPT_DIRECTORY
208 value: "sql"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100209 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +0000210 restartPolicy: Never
211 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
212 volumes:
213 - name: {{ include "common.fullname" . }}-config
214 configMap:
215 name: {{ include "common.fullname" . }}-db-configmap
216 defaultMode: 0755
217 items:
218 - key: db_migrator_policy_init.sh
219 path: db_migrator_policy_init.sh
220
221{{ if .Values.global.postgres.localCluster }}
222---
223apiVersion: batch/v1
224kind: Job
225metadata:
226 name: {{ include "common.fullname" . }}-pg-config
227 namespace: {{ include "common.namespace" . }}
228 labels:
229 app: {{ include "common.name" . }}-pg-config
230 release: {{ include "common.release" . }}
231spec:
232 template:
233 metadata:
234 labels:
235 app: {{ include "common.name" . }}-pg-config
236 release: {{ include "common.release" . }}
237 name: {{ include "common.name" . }}-pg-config
Andreas Geisslerf10c5552023-03-21 18:09:46 +0100238 annotations:
239 sidecar.istio.io/inject: "false"
amatthews736bf372021-12-14 16:04:15 +0000240 spec:
241 imagePullSecrets:
242 - name: "{{ include "common.namespace" . }}-docker-registry-key"
243 initContainers:
244 - name: {{ include "common.name" . }}-init-readiness
245 image: {{ include "repositoryGenerator.image.readiness" . }}
246 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
247 command:
248 - /app/ready.py
249 args:
250 - --job-name
251 - {{ include "common.fullname" . }}-pg-init
252 env:
253 - name: NAMESPACE
254 valueFrom:
255 fieldRef:
256 apiVersion: v1
257 fieldPath: metadata.namespace
258 containers:
259 - name: {{ include "common.name" . }}-pg-db-migrator
waynedunican368aced2022-02-15 08:27:57 +0000260 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
261 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
262 volumeMounts:
263 - mountPath: /dbcmd-config/db_migrator_pg_policy_init.sh
264 name: {{ include "common.fullname" . }}-config
265 subPath: db_migrator_pg_policy_init.sh
266 command:
267 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000268 - -cx
269 - |
amatthews736bf372021-12-14 16:04:15 +0000270 /dbcmd-config/db_migrator_pg_policy_init.sh
waynedunican368aced2022-02-15 08:27:57 +0000271 env:
272 - name: SQL_HOST
273 value: "{{ .Values.postgres.service.name2 }}"
274 - name: SQL_USER
275 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
276 - name: SQL_PASSWORD
277 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
278 - name: SQL_DB
279 value: {{ .Values.dbmigrator.schema }}
280 - name: POLICY_HOME
281 value: {{ .Values.dbmigrator.policy_home }}
282 - name: SCRIPT_DIRECTORY
283 value: "postgres"
284 - name: PGPASSWORD
285 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100286 resources: {{ include "common.resources" . | nindent 10 }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100287 restartPolicy: Never
farida azmyc1178372021-04-11 12:55:33 +0200288 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100289 volumes:
290 - name: {{ include "common.fullname" . }}-config
291 configMap:
292 name: {{ include "common.fullname" . }}-db-configmap
amatthews736bf372021-12-14 16:04:15 +0000293 defaultMode: 0755
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100294 items:
waynedunican368aced2022-02-15 08:27:57 +0000295 - key: db_migrator_pg_policy_init.sh
296 path: db_migrator_pg_policy_init.sh
amatthews736bf372021-12-14 16:04:15 +0000297{{ end }}