blob: f0e91e8350b1473175d924ca4313eccf128363c3 [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
saul.gillef208b02023-04-26 16:16:05 +010019{{ if not .Values.global.postgres.localCluster }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010020apiVersion: batch/v1
21kind: Job
22metadata:
amatthews736bf372021-12-14 16:04:15 +000023 name: {{ include "common.fullname" . }}-galera-init
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010024 namespace: {{ include "common.namespace" . }}
25 labels:
amatthews736bf372021-12-14 16:04:15 +000026 app: {{ include "common.name" . }}-galera-init
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010027 release: {{ include "common.release" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010028spec:
29 template:
30 metadata:
31 labels:
amatthews736bf372021-12-14 16:04:15 +000032 app: {{ include "common.name" . }}-galera-init
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010033 release: {{ include "common.release" . }}
amatthews736bf372021-12-14 16:04:15 +000034 name: {{ include "common.name" . }}-galera-init
Andreas Geisslerf10c5552023-03-21 18:09:46 +010035 annotations:
36 sidecar.istio.io/inject: "false"
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010037 spec:
andreas-geissler7d85f3f2021-07-19 17:53:22 +020038 imagePullSecrets:
39 - name: "{{ include "common.namespace" . }}-docker-registry-key"
amatthews736bf372021-12-14 16:04:15 +000040 initContainers:
waynedunican368aced2022-02-15 08:27:57 +000041 - name: {{ include "common.name" . }}-mariadb-readiness
Sylvain Desbureaux7c8c6862020-11-19 18:02:37 +010042 image: {{ include "repositoryGenerator.image.readiness" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010043 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
44 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020045 - /app/ready.py
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010046 - --container-name
47 - {{ index .Values "mariadb-galera" "service" "name" }}
48 env:
49 - name: NAMESPACE
50 valueFrom:
51 fieldRef:
52 apiVersion: v1
53 fieldPath: metadata.namespace
amatthews736bf372021-12-14 16:04:15 +000054 containers:
55 - name: {{ include "common.name" . }}-galera-config
Andreas Geisslera4275992023-01-25 09:27:30 +010056 image: {{ include "repositoryGenerator.image.mariadb" . }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010057 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
58 volumeMounts:
59 - mountPath: /dbcmd-config/db.sh
60 name: {{ include "common.fullname" . }}-config
61 subPath: db.sh
62 command:
63 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +000064 - -cx
65 - |
amatthews736bf372021-12-14 16:04:15 +000066 /dbcmd-config/db.sh
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010067 env:
68 - name: MYSQL_ROOT_PASSWORD
Krzysztof Opasiak98a79cc2020-04-01 22:33:58 +020069 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 10 }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010070 - name: MYSQL_HOST
71 value: "{{ index .Values "mariadb-galera" "service" "name" }}"
72 - name: MYSQL_USER
Krzysztof Opasiak98a79cc2020-04-01 22:33:58 +020073 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +010074 - name: MYSQL_PORT
75 value: "{{ index .Values "mariadb-galera" "service" "internalPort" }}"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +010076 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +000077 restartPolicy: Never
78 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
79 volumes:
80 - name: {{ include "common.fullname" . }}-config
81 configMap:
82 name: {{ include "common.fullname" . }}-db-configmap
83 defaultMode: 0755
84 items:
85 - key: db.sh
86 path: db.sh
saul.gillef208b02023-04-26 16:16:05 +010087{{ end }}
amatthews736bf372021-12-14 16:04:15 +000088
89{{ if .Values.global.postgres.localCluster }}
90---
91apiVersion: batch/v1
92kind: Job
93metadata:
94 name: {{ include "common.fullname" . }}-pg-init
95 namespace: {{ include "common.namespace" . }}
96 labels:
97 app: {{ include "common.name" . }}-pg-init
98 release: {{ include "common.release" . }}
99spec:
100 template:
101 metadata:
102 labels:
103 app: {{ include "common.name" . }}-pg-init
104 release: {{ include "common.release" . }}
105 name: {{ include "common.name" . }}-pg-init
Andreas Geisslerf10c5552023-03-21 18:09:46 +0100106 annotations:
107 sidecar.istio.io/inject: "false"
amatthews736bf372021-12-14 16:04:15 +0000108 spec:
109 imagePullSecrets:
110 - name: "{{ include "common.namespace" . }}-docker-registry-key"
111 initContainers: {{ if .Values.global.postgres.localCluster }}{{ include "common.readinessCheck.waitFor" . | nindent 6 }}{{ end }}
112 containers:
113 - name: {{ include "common.name" . }}-pg-config
Andreas Geissler6128f5f2023-01-25 09:18:56 +0100114 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.postgresImage }}
waynedunican368aced2022-02-15 08:27:57 +0000115 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
116 volumeMounts:
117 - mountPath: /docker-entrypoint-initdb.d/db-pg.sh
118 name: {{ include "common.fullname" . }}-config
119 subPath: db-pg.sh
120 command:
121 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000122 - -cx
123 - |
amatthews736bf372021-12-14 16:04:15 +0000124 /docker-entrypoint-initdb.d/db-pg.sh
waynedunican368aced2022-02-15 08:27:57 +0000125 env:
126 - name: PG_ADMIN_PASSWORD
saul.gillef208b02023-04-26 16:16:05 +0100127 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 12 }}
waynedunican368aced2022-02-15 08:27:57 +0000128 - name: PG_HOST
129 value: "{{ .Values.postgres.service.name2 }}"
130 - name: PG_USER
saul.gillef208b02023-04-26 16:16:05 +0100131 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 12 }}
waynedunican368aced2022-02-15 08:27:57 +0000132 - name: PG_USER_PASSWORD
saul.gillef208b02023-04-26 16:16:05 +0100133 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 12 }}
waynedunican368aced2022-02-15 08:27:57 +0000134 - name: PG_PORT
135 value: "{{ .Values.postgres.service.internalPort }}"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100136 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +0000137 restartPolicy: Never
138 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
139 volumes:
140 - name: {{ include "common.fullname" . }}-config
141 configMap:
142 name: {{ include "common.fullname" . }}-db-configmap
143 defaultMode: 0755
144 items:
145 - key: db-pg.sh
146 path: db-pg.sh
147{{ end }}
148
149---
saul.gillef208b02023-04-26 16:16:05 +0100150{{ if not .Values.global.postgres.localCluster }}
amatthews736bf372021-12-14 16:04:15 +0000151apiVersion: batch/v1
152kind: Job
153metadata:
154 name: {{ include "common.fullname" . }}-galera-config
155 namespace: {{ include "common.namespace" . }}
156 labels:
157 app: {{ include "common.name" . }}-galera-config
158 release: {{ include "common.release" . }}
159spec:
160 template:
161 metadata:
162 labels:
163 app: {{ include "common.name" . }}-galera-config
164 release: {{ include "common.release" . }}
165 name: {{ include "common.name" . }}-galera-config
Andreas Geisslerf10c5552023-03-21 18:09:46 +0100166 annotations:
167 sidecar.istio.io/inject: "false"
amatthews736bf372021-12-14 16:04:15 +0000168 spec:
169 imagePullSecrets:
170 - name: "{{ include "common.namespace" . }}-docker-registry-key"
171 initContainers:
172 - name: {{ include "common.name" . }}-init-readiness
173 image: {{ include "repositoryGenerator.image.readiness" . }}
174 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
175 command:
176 - /app/ready.py
177 args:
178 - --job-name
179 - {{ include "common.fullname" . }}-galera-init
180 env:
181 - name: NAMESPACE
182 valueFrom:
183 fieldRef:
184 apiVersion: v1
185 fieldPath: metadata.namespace
jhhd74fe9f2021-04-15 11:04:39 -0500186 containers:
amatthews736bf372021-12-14 16:04:15 +0000187 - name: {{ include "common.name" . }}-galera-db-migrator
Andreas Geissler8d704ba2022-01-07 17:49:22 +0000188 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
jhhd74fe9f2021-04-15 11:04:39 -0500189 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
190 volumeMounts:
191 - mountPath: /dbcmd-config/db_migrator_policy_init.sh
192 name: {{ include "common.fullname" . }}-config
193 subPath: db_migrator_policy_init.sh
194 command:
195 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000196 - -cx
197 - |
amatthews736bf372021-12-14 16:04:15 +0000198 /dbcmd-config/db_migrator_policy_init.sh
jhhd74fe9f2021-04-15 11:04:39 -0500199 env:
200 - name: SQL_HOST
201 value: "{{ index .Values "mariadb-galera" "service" "name" }}"
202 - name: SQL_USER
203 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
204 - name: SQL_PASSWORD
205 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
206 - name: SQL_DB
207 value: {{ .Values.dbmigrator.schema }}
208 - name: POLICY_HOME
209 value: {{ .Values.dbmigrator.policy_home }}
waynedunican368aced2022-02-15 08:27:57 +0000210 - name: SCRIPT_DIRECTORY
211 value: "sql"
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100212 resources: {{ include "common.resources" . | nindent 10 }}
amatthews736bf372021-12-14 16:04:15 +0000213 restartPolicy: Never
214 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
215 volumes:
216 - name: {{ include "common.fullname" . }}-config
217 configMap:
218 name: {{ include "common.fullname" . }}-db-configmap
219 defaultMode: 0755
220 items:
221 - key: db_migrator_policy_init.sh
222 path: db_migrator_policy_init.sh
saul.gillef208b02023-04-26 16:16:05 +0100223{{ end }}
amatthews736bf372021-12-14 16:04:15 +0000224{{ if .Values.global.postgres.localCluster }}
225---
226apiVersion: batch/v1
227kind: Job
228metadata:
229 name: {{ include "common.fullname" . }}-pg-config
230 namespace: {{ include "common.namespace" . }}
231 labels:
232 app: {{ include "common.name" . }}-pg-config
233 release: {{ include "common.release" . }}
234spec:
235 template:
236 metadata:
237 labels:
238 app: {{ include "common.name" . }}-pg-config
239 release: {{ include "common.release" . }}
240 name: {{ include "common.name" . }}-pg-config
Andreas Geisslerf10c5552023-03-21 18:09:46 +0100241 annotations:
242 sidecar.istio.io/inject: "false"
amatthews736bf372021-12-14 16:04:15 +0000243 spec:
244 imagePullSecrets:
245 - name: "{{ include "common.namespace" . }}-docker-registry-key"
246 initContainers:
247 - name: {{ include "common.name" . }}-init-readiness
248 image: {{ include "repositoryGenerator.image.readiness" . }}
249 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
250 command:
251 - /app/ready.py
252 args:
253 - --job-name
254 - {{ include "common.fullname" . }}-pg-init
255 env:
256 - name: NAMESPACE
257 valueFrom:
258 fieldRef:
259 apiVersion: v1
260 fieldPath: metadata.namespace
261 containers:
262 - name: {{ include "common.name" . }}-pg-db-migrator
waynedunican368aced2022-02-15 08:27:57 +0000263 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
264 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
265 volumeMounts:
266 - mountPath: /dbcmd-config/db_migrator_pg_policy_init.sh
267 name: {{ include "common.fullname" . }}-config
268 subPath: db_migrator_pg_policy_init.sh
269 command:
270 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000271 - -cx
272 - |
amatthews736bf372021-12-14 16:04:15 +0000273 /dbcmd-config/db_migrator_pg_policy_init.sh
waynedunican368aced2022-02-15 08:27:57 +0000274 env:
275 - name: SQL_HOST
276 value: "{{ .Values.postgres.service.name2 }}"
277 - name: SQL_USER
saul.gillef208b02023-04-26 16:16:05 +0100278 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
waynedunican368aced2022-02-15 08:27:57 +0000279 - name: SQL_PASSWORD
saul.gillef208b02023-04-26 16:16:05 +0100280 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
waynedunican368aced2022-02-15 08:27:57 +0000281 - name: SQL_DB
282 value: {{ .Values.dbmigrator.schema }}
283 - name: POLICY_HOME
284 value: {{ .Values.dbmigrator.policy_home }}
285 - name: SCRIPT_DIRECTORY
286 value: "postgres"
287 - name: PGPASSWORD
saul.gillef208b02023-04-26 16:16:05 +0100288 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
miroslavmasaryka7ac7f02023-03-01 14:12:26 +0100289 resources: {{ include "common.resources" . | nindent 10 }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100290 restartPolicy: Never
farida azmyc1178372021-04-11 12:55:33 +0200291 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100292 volumes:
293 - name: {{ include "common.fullname" . }}-config
294 configMap:
295 name: {{ include "common.fullname" . }}-db-configmap
amatthews736bf372021-12-14 16:04:15 +0000296 defaultMode: 0755
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100297 items:
waynedunican368aced2022-02-15 08:27:57 +0000298 - key: db_migrator_pg_policy_init.sh
299 path: db_migrator_pg_policy_init.sh
amatthews736bf372021-12-14 16:04:15 +0000300{{ end }}