blob: 0df26568e5f7976dce05631894dc47cf19e4a534 [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
Sylvain Desbureaux7c8c6862020-11-19 18:02:37 +010053 image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.mariadb.image }}
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" }}"
jhhbf8d8a92020-09-10 14:01:49 -050075 resources:
76{{ include "common.resources" . }}
amatthews736bf372021-12-14 16:04:15 +000077 {{- if (include "common.onServiceMesh" .) }}
78 - name: policy-service-mesh-wait-for-job-container
79 image: nexus3.onap.org:10001/onap/oom/readiness:4.1.0
80 imagePullPolicy: Always
81 command:
82 - /bin/sh
83 - "-c"
84 args:
85 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
86 /app/ready.py --service-mesh-check {{ include "common.name" . }}-galera-config -t 45;
87 env:
88 - name: NAMESPACE
89 valueFrom:
90 fieldRef:
91 apiVersion: v1
92 fieldPath: metadata.namespace
93 {{- end }}
94 restartPolicy: Never
95 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
96 volumes:
97 - name: {{ include "common.fullname" . }}-config
98 configMap:
99 name: {{ include "common.fullname" . }}-db-configmap
100 defaultMode: 0755
101 items:
102 - key: db.sh
103 path: db.sh
104
105{{ if .Values.global.postgres.localCluster }}
106---
107apiVersion: batch/v1
108kind: Job
109metadata:
110 name: {{ include "common.fullname" . }}-pg-init
111 namespace: {{ include "common.namespace" . }}
112 labels:
113 app: {{ include "common.name" . }}-pg-init
114 release: {{ include "common.release" . }}
115spec:
116 template:
117 metadata:
118 labels:
119 app: {{ include "common.name" . }}-pg-init
120 release: {{ include "common.release" . }}
121 name: {{ include "common.name" . }}-pg-init
122 spec:
123 imagePullSecrets:
124 - name: "{{ include "common.namespace" . }}-docker-registry-key"
125 initContainers: {{ if .Values.global.postgres.localCluster }}{{ include "common.readinessCheck.waitFor" . | nindent 6 }}{{ end }}
126 containers:
127 - name: {{ include "common.name" . }}-pg-config
waynedunican368aced2022-02-15 08:27:57 +0000128 image: {{ .Values.repository }}/{{ .Values.postgresImage }}
129 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
130 volumeMounts:
131 - mountPath: /docker-entrypoint-initdb.d/db-pg.sh
132 name: {{ include "common.fullname" . }}-config
133 subPath: db-pg.sh
134 command:
135 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000136 - -cx
137 - |
138 {{- if include "common.onServiceMesh" . }}
139 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
140 /docker-entrypoint-initdb.d/db-pg.sh
waynedunican368aced2022-02-15 08:27:57 +0000141 env:
142 - name: PG_ADMIN_PASSWORD
143 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-root-pass" "key" "password") | indent 12 }}
144 - name: PG_HOST
145 value: "{{ .Values.postgres.service.name2 }}"
146 - name: PG_USER
147 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 12 }}
148 - name: PG_USER_PASSWORD
149 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 12 }}
150 - name: PG_PORT
151 value: "{{ .Values.postgres.service.internalPort }}"
152 resources:
153{{ include "common.resources" . }}
amatthews736bf372021-12-14 16:04:15 +0000154 {{- if (include "common.onServiceMesh" .) }}
155 - name: policy-service-mesh-wait-for-job-container
156 image: nexus3.onap.org:10001/onap/oom/readiness:4.1.0
157 imagePullPolicy: Always
158 command:
159 - /bin/sh
160 - "-c"
161 args:
162 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
163 /app/ready.py --service-mesh-check {{ include "common.name" . }}-pg-config -t 45;
164 env:
165 - name: NAMESPACE
166 valueFrom:
167 fieldRef:
168 apiVersion: v1
169 fieldPath: metadata.namespace
170 {{- end }}
171 restartPolicy: Never
172 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
173 volumes:
174 - name: {{ include "common.fullname" . }}-config
175 configMap:
176 name: {{ include "common.fullname" . }}-db-configmap
177 defaultMode: 0755
178 items:
179 - key: db-pg.sh
180 path: db-pg.sh
181{{ end }}
182
183---
184apiVersion: batch/v1
185kind: Job
186metadata:
187 name: {{ include "common.fullname" . }}-galera-config
188 namespace: {{ include "common.namespace" . }}
189 labels:
190 app: {{ include "common.name" . }}-galera-config
191 release: {{ include "common.release" . }}
192spec:
193 template:
194 metadata:
195 labels:
196 app: {{ include "common.name" . }}-galera-config
197 release: {{ include "common.release" . }}
198 name: {{ include "common.name" . }}-galera-config
199 spec:
200 imagePullSecrets:
201 - name: "{{ include "common.namespace" . }}-docker-registry-key"
202 initContainers:
203 - name: {{ include "common.name" . }}-init-readiness
204 image: {{ include "repositoryGenerator.image.readiness" . }}
205 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
206 command:
207 - /app/ready.py
208 args:
209 - --job-name
210 - {{ include "common.fullname" . }}-galera-init
211 env:
212 - name: NAMESPACE
213 valueFrom:
214 fieldRef:
215 apiVersion: v1
216 fieldPath: metadata.namespace
jhhd74fe9f2021-04-15 11:04:39 -0500217 containers:
amatthews736bf372021-12-14 16:04:15 +0000218 - name: {{ include "common.name" . }}-galera-db-migrator
Andreas Geissler8d704ba2022-01-07 17:49:22 +0000219 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
jhhd74fe9f2021-04-15 11:04:39 -0500220 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
221 volumeMounts:
222 - mountPath: /dbcmd-config/db_migrator_policy_init.sh
223 name: {{ include "common.fullname" . }}-config
224 subPath: db_migrator_policy_init.sh
225 command:
226 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000227 - -cx
228 - |
229 {{- if include "common.onServiceMesh" . }}
230 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
231 /dbcmd-config/db_migrator_policy_init.sh
jhhd74fe9f2021-04-15 11:04:39 -0500232 env:
233 - name: SQL_HOST
234 value: "{{ index .Values "mariadb-galera" "service" "name" }}"
235 - name: SQL_USER
236 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
237 - name: SQL_PASSWORD
238 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "password") | indent 10 }}
239 - name: SQL_DB
240 value: {{ .Values.dbmigrator.schema }}
241 - name: POLICY_HOME
242 value: {{ .Values.dbmigrator.policy_home }}
waynedunican368aced2022-02-15 08:27:57 +0000243 - name: SCRIPT_DIRECTORY
244 value: "sql"
jhhd74fe9f2021-04-15 11:04:39 -0500245 resources:
246{{ include "common.resources" . }}
amatthews736bf372021-12-14 16:04:15 +0000247 {{- if (include "common.onServiceMesh" .) }}
248 - name: policy-service-mesh-wait-for-job-container
249 image: nexus3.onap.org:10001/onap/oom/readiness:4.1.0
250 imagePullPolicy: Always
251 command:
252 - /bin/sh
253 - "-c"
254 args:
255 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
256 /app/ready.py --service-mesh-check {{ include "common.name" . }}-galera-db-migrator -t 45;
257 env:
258 - name: NAMESPACE
259 valueFrom:
260 fieldRef:
261 apiVersion: v1
262 fieldPath: metadata.namespace
263 {{- end }}
264 restartPolicy: Never
265 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
266 volumes:
267 - name: {{ include "common.fullname" . }}-config
268 configMap:
269 name: {{ include "common.fullname" . }}-db-configmap
270 defaultMode: 0755
271 items:
272 - key: db_migrator_policy_init.sh
273 path: db_migrator_policy_init.sh
274
275{{ if .Values.global.postgres.localCluster }}
276---
277apiVersion: batch/v1
278kind: Job
279metadata:
280 name: {{ include "common.fullname" . }}-pg-config
281 namespace: {{ include "common.namespace" . }}
282 labels:
283 app: {{ include "common.name" . }}-pg-config
284 release: {{ include "common.release" . }}
285spec:
286 template:
287 metadata:
288 labels:
289 app: {{ include "common.name" . }}-pg-config
290 release: {{ include "common.release" . }}
291 name: {{ include "common.name" . }}-pg-config
292 spec:
293 imagePullSecrets:
294 - name: "{{ include "common.namespace" . }}-docker-registry-key"
295 initContainers:
296 - name: {{ include "common.name" . }}-init-readiness
297 image: {{ include "repositoryGenerator.image.readiness" . }}
298 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
299 command:
300 - /app/ready.py
301 args:
302 - --job-name
303 - {{ include "common.fullname" . }}-pg-init
304 env:
305 - name: NAMESPACE
306 valueFrom:
307 fieldRef:
308 apiVersion: v1
309 fieldPath: metadata.namespace
310 containers:
311 - name: {{ include "common.name" . }}-pg-db-migrator
waynedunican368aced2022-02-15 08:27:57 +0000312 image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.dbmigrator.image }}
313 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
314 volumeMounts:
315 - mountPath: /dbcmd-config/db_migrator_pg_policy_init.sh
316 name: {{ include "common.fullname" . }}-config
317 subPath: db_migrator_pg_policy_init.sh
318 command:
319 - /bin/sh
amatthews736bf372021-12-14 16:04:15 +0000320 - -cx
321 - |
322 {{- if include "common.onServiceMesh" . }}
323 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
324 /dbcmd-config/db_migrator_pg_policy_init.sh
waynedunican368aced2022-02-15 08:27:57 +0000325 env:
326 - name: SQL_HOST
327 value: "{{ .Values.postgres.service.name2 }}"
328 - name: SQL_USER
329 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "login") | indent 10 }}
330 - name: SQL_PASSWORD
331 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
332 - name: SQL_DB
333 value: {{ .Values.dbmigrator.schema }}
334 - name: POLICY_HOME
335 value: {{ .Values.dbmigrator.policy_home }}
336 - name: SCRIPT_DIRECTORY
337 value: "postgres"
338 - name: PGPASSWORD
339 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "pg-user-creds" "key" "password") | indent 10 }}
340 resources:
341{{ include "common.resources" . }}
amatthews736bf372021-12-14 16:04:15 +0000342 {{- if (include "common.onServiceMesh" .) }}
343 - name: policy-service-mesh-wait-for-job-container
344 image: nexus3.onap.org:10001/onap/oom/readiness:4.1.0
345 imagePullPolicy: Always
346 command:
347 - /bin/sh
348 - "-c"
349 args:
350 - echo "waiting 10s for istio side cars to be up"; sleep 10s;
351 /app/ready.py --service-mesh-check {{ include "common.name" . }}-pg-db-migrator -t 45;
352 env:
353 - name: NAMESPACE
354 valueFrom:
355 fieldRef:
356 apiVersion: v1
357 fieldPath: metadata.namespace
358 {{- end }}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100359 restartPolicy: Never
farida azmyc1178372021-04-11 12:55:33 +0200360 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100361 volumes:
362 - name: {{ include "common.fullname" . }}-config
363 configMap:
364 name: {{ include "common.fullname" . }}-db-configmap
amatthews736bf372021-12-14 16:04:15 +0000365 defaultMode: 0755
Sylvain Desbureaux4898dc02019-11-14 13:35:13 +0100366 items:
waynedunican368aced2022-02-15 08:27:57 +0000367 - key: db_migrator_pg_policy_init.sh
368 path: db_migrator_pg_policy_init.sh
amatthews736bf372021-12-14 16:04:15 +0000369{{ end }}