blob: 96d1dc54a4b0c329a6b63d28e7db70c6df9808f8 [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:
40 - name: {{ include "common.name" . }}-readiness
41 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020042 - /app/ready.py
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010043 args:
44 - --container-name
Krzysztof Opasiak80e39d42020-08-31 22:25:52 +020045 - {{ default .Values.global.mariadbGalera.nameOverride .Values.mariadbGalera.containerName }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010046 env:
47 - name: NAMESPACE
48 valueFrom:
49 fieldRef:
50 apiVersion: v1
51 fieldPath: metadata.namespace
Sylvain Desbureaux72bbabf2020-11-19 17:15:14 +010052 image: {{ include "repositoryGenerator.image.readiness" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010053 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
54 containers:
55 - name: {{ include "common.name" . }}
Sylvain Desbureaux72bbabf2020-11-19 17:15:14 +010056 image: {{ include "repositoryGenerator.image.mariadb" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010057 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
58 command:
RPMishrae4ee7f12020-10-07 12:09:01 +053059 - /bin/sh
60 - -c
61 - |
62 /db_init/db_init.sh {{ if or .Values.dbScriptConfigMap .Values.dbScript }} &&
63 /db_config/db_cmd.sh{{ end }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010064 env:
65 - name: DB_HOST
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020066 value: {{ include "common.mariadbService" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010067 - name: DB_PORT
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020068 value: {{ include "common.mariadbPort" . | quote }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010069 - name: MYSQL_ROOT_PASSWORD
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020070 {{- 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 +010071 - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020072 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "login") | indent 10 }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010073 - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020074 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010075{{- $root := . }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010076{{ range $db, $_values := .Values.config.mysqlAdditionalDatabases }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010077 - name: {{ printf "MYSQL_USER_%s" $db | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020078 {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "login") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010079 - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020080 {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010081{{ end }}
82 volumeMounts:
83 - mountPath: /etc/localtime
84 name: localtime
85 readOnly: true
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020086 - name: mariadb-init
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010087 mountPath: /db_init/
RPMishrae4ee7f12020-10-07 12:09:01 +053088{{- if or .Values.dbScriptConfigMap .Values.dbScript }}
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +020089 - name: mariadb-conf
RPMishrae4ee7f12020-10-07 12:09:01 +053090 mountPath: /db_config/
91{{- end }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010092 resources:
93{{ include "common.resources" . | indent 12 }}
94 {{- if .Values.nodeSelector }}
95 nodeSelector:
96{{ toYaml .Values.nodeSelector | indent 10 }}
97 {{- end -}}
98 {{- if .Values.affinity }}
99 affinity:
100{{ toYaml .Values.affinity | indent 10 }}
101 {{- end }}
102 volumes:
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +0100103 - name: localtime
104 hostPath:
105 path: /etc/localtime
RPMishrae4ee7f12020-10-07 12:09:01 +0530106{{- if or .Values.dbScriptConfigMap .Values.dbScript }}
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +0200107 - name: mariadb-conf
RPMishrae4ee7f12020-10-07 12:09:01 +0530108 configMap:
109{{- if .Values.dbScriptConfigMap }}
110 name: {{ tpl .Values.dbScriptConfigMap . }}
111{{- else -}}
112 name: {{ include "common.fullname" . }}-dbscript
113{{- end }}
114 defaultMode: 0755
115{{- end }}
Mahmoud Abdelhamide351f512021-05-04 17:52:04 +0200116 - name: mariadb-init
RPMishrae4ee7f12020-10-07 12:09:01 +0530117 configMap:
118 name: {{ include "mariadbInit.configMap" . }}
119 defaultMode: 0755
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +0100120 restartPolicy: Never
121 imagePullSecrets:
122 - name: "{{ include "common.namespace" . }}-docker-registry-key"