blob: 7de0a9182beee8ffabd8b6d67a84d7297f82a618 [file] [log] [blame]
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +01001# Copyright © 2019 Orange
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +01002# Copyright © 2020 Samsung Electronics
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +01003#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020016{{ include "mariadbInit._updateSecrets" . -}}
17
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010018apiVersion: batch/v1
19kind: Job
20metadata:
21 name: {{ include "common.fullname" . }}-config-job
22 namespace: {{ include "common.namespace" . }}
23 labels:
24 app: {{ include "common.name" . }}
25 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010026 release: {{ include "common.release" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010027 heritage: {{ .Release.Service }}
28spec:
29 backoffLimit: 20
30 template:
31 metadata:
32 labels:
33 app: {{ include "common.name" . }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010034 release: {{ include "common.release" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010035 name: {{ include "common.name" . }}
36 spec:
37 initContainers:
38 - name: {{ include "common.name" . }}-readiness
39 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020040 - /app/ready.py
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010041 args:
42 - --container-name
Krzysztof Opasiak80e39d42020-08-31 22:25:52 +020043 - {{ default .Values.global.mariadbGalera.nameOverride .Values.mariadbGalera.containerName }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010044 env:
45 - name: NAMESPACE
46 valueFrom:
47 fieldRef:
48 apiVersion: v1
49 fieldPath: metadata.namespace
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020050 image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010051 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
52 containers:
53 - name: {{ include "common.name" . }}
54 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
55 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
56 command:
57 - bash
58 - /db_init/db_init.sh
59 env:
60 - name: DB_HOST
Krzysztof Opasiak80e39d42020-08-31 22:25:52 +020061 value: "{{ default .Values.global.mariadbGalera.nameOverride .Values.mariadbGalera.serviceName }}"
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010062 - name: DB_PORT
Krzysztof Opasiak80e39d42020-08-31 22:25:52 +020063 value: "{{ default .Values.global.mariadbGalera.servicePort .Values.mariadbGalera.servicePort }}"
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010064 - name: MYSQL_ROOT_PASSWORD
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020065 {{- 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 +010066 - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020067 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "login") | indent 10 }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010068 - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020069 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010070{{- $root := . }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010071{{ range $db, $_values := .Values.config.mysqlAdditionalDatabases }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010072 - name: {{ printf "MYSQL_USER_%s" $db | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020073 {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "login") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010074 - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }}
Krzysztof Opasiaked7b0492020-09-01 18:35:40 +020075 {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010076{{ end }}
77 volumeMounts:
78 - mountPath: /etc/localtime
79 name: localtime
80 readOnly: true
81 - name: mariadb-conf
82 mountPath: /db_init/
83 readOnly: true
84 resources:
85{{ include "common.resources" . | indent 12 }}
86 {{- if .Values.nodeSelector }}
87 nodeSelector:
88{{ toYaml .Values.nodeSelector | indent 10 }}
89 {{- end -}}
90 {{- if .Values.affinity }}
91 affinity:
92{{ toYaml .Values.affinity | indent 10 }}
93 {{- end }}
94 volumes:
95 - name: mariadb-conf
96 configMap:
97 name: {{ include "mariadbInit.configMap" . }}
98 - name: localtime
99 hostPath:
100 path: /etc/localtime
101 restartPolicy: Never
102 imagePullSecrets:
103 - name: "{{ include "common.namespace" . }}-docker-registry-key"