blob: 88ff0e09c273f5554bc9eab0cf1aff46f721417f [file] [log] [blame]
Jakub Latusek3659d9f2020-09-14 16:21:55 +02001{{/*
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +01002# Copyright © 2019 Orange
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +01003# Copyright © 2020 Samsung Electronics
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +01004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
Jakub Latusek3659d9f2020-09-14 16:21:55 +020016*/}}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010017
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020018{{ include "mariadbInit._updateSecrets" . -}}
19
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010020apiVersion: batch/v1
21kind: Job
22metadata:
23 name: {{ include "common.fullname" . }}-config-job
24 namespace: {{ include "common.namespace" . }}
25 labels:
26 app: {{ include "common.name" . }}
27 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010028 release: {{ include "common.release" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010029 heritage: {{ .Release.Service }}
30spec:
31 backoffLimit: 20
32 template:
33 metadata:
34 labels:
35 app: {{ include "common.name" . }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010036 release: {{ include "common.release" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010037 name: {{ include "common.name" . }}
38 spec:
39 initContainers:
Andreas Geissler060bc372024-03-11 17:26:53 +010040 {{- if .Values.global.mariadbGalera.localCluster }}
41 {{- if .Values.global.mariadbGalera.useOperator }}
42 {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_local_operator ) | indent 6 | trim }}
43 {{ else }}
44 {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_local ) | indent 6 | trim }}
45 {{- end }}
46 {{ else }}
47 {{- if .Values.global.mariadbGalera.useOperator }}
48 {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_global_operator ) | indent 6 | trim }}
49 {{ else }}
50 {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.readinessCheck.wait_for_global ) | indent 6 | trim }}
51 {{- end }}
52 {{- end }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010053 containers:
54 - name: {{ include "common.name" . }}
Sylvain Desbureaux72bbabf2020-11-19 17:15:14 +010055 image: {{ include "repositoryGenerator.image.mariadb" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010056 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
57 command:
RPMishrae4ee7f12020-10-07 12:09:01 +053058 - /bin/sh
59 - -c
60 - |
Andreas Geisslerba1200c2022-04-07 17:02:59 +020061 {{- if include "common.onServiceMesh" . }}
62 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
RPMishrae4ee7f12020-10-07 12:09:01 +053063 /db_init/db_init.sh {{ if or .Values.dbScriptConfigMap .Values.dbScript }} &&
64 /db_config/db_cmd.sh{{ end }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010065 env:
66 - name: DB_HOST
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020067 value: {{ include "common.mariadbService" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010068 - name: DB_PORT
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020069 value: {{ include "common.mariadbPort" . | quote }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010070 - name: MYSQL_ROOT_PASSWORD
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020071 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-password" "key" (default "password" .Values.global.mariadbGalera.userRootSecretKey)) | indent 10 }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010072 - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020073 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "login") | indent 10 }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010074 - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020075 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010076{{- $root := . }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010077{{ range $db, $_values := .Values.config.mysqlAdditionalDatabases }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010078 - name: {{ printf "MYSQL_USER_%s" $db | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020079 {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "login") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010080 - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020081 {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010082{{ end }}
83 volumeMounts:
84 - mountPath: /etc/localtime
85 name: localtime
86 readOnly: true
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020087 - name: mariadb-init
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010088 mountPath: /db_init/
RPMishrae4ee7f12020-10-07 12:09:01 +053089{{- if or .Values.dbScriptConfigMap .Values.dbScript }}
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020090 - name: mariadb-conf
RPMishrae4ee7f12020-10-07 12:09:01 +053091 mountPath: /db_config/
92{{- end }}
miroslavmasaryka7ac7f02023-03-01 14:12:26 +010093 resources: {{ include "common.resources" . | nindent 10 }}
Andreas Geisslerba1200c2022-04-07 17:02:59 +020094 {{ include "common.waitForJobContainer" . | indent 6 | trim }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010095 {{- if .Values.nodeSelector }}
96 nodeSelector:
97{{ toYaml .Values.nodeSelector | indent 10 }}
98 {{- end -}}
99 {{- if .Values.affinity }}
100 affinity:
101{{ toYaml .Values.affinity | indent 10 }}
102 {{- end }}
vladimir turokd8044182023-07-27 16:28:36 +0200103 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +0100104 volumes:
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +0100105 - name: localtime
106 hostPath:
107 path: /etc/localtime
RPMishrae4ee7f12020-10-07 12:09:01 +0530108{{- if or .Values.dbScriptConfigMap .Values.dbScript }}
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +0200109 - name: mariadb-conf
RPMishrae4ee7f12020-10-07 12:09:01 +0530110 configMap:
111{{- if .Values.dbScriptConfigMap }}
112 name: {{ tpl .Values.dbScriptConfigMap . }}
113{{- else -}}
114 name: {{ include "common.fullname" . }}-dbscript
115{{- end }}
116 defaultMode: 0755
117{{- end }}
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +0200118 - name: mariadb-init
RPMishrae4ee7f12020-10-07 12:09:01 +0530119 configMap:
120 name: {{ include "mariadbInit.configMap" . }}
121 defaultMode: 0755
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +0100122 restartPolicy: Never
Andreas Geisslerbd0d31a2024-03-20 09:51:32 +0100123 {{- include "common.imagePullSecrets" . | nindent 6 }}