blob: 3149f9461108857a0a0757efd8f9a254698c3861 [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
16apiVersion: batch/v1
17kind: Job
18metadata:
19 name: {{ include "common.fullname" . }}-config-job
20 namespace: {{ include "common.namespace" . }}
21 labels:
22 app: {{ include "common.name" . }}
23 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010024 release: {{ include "common.release" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010025 heritage: {{ .Release.Service }}
26spec:
27 backoffLimit: 20
28 template:
29 metadata:
30 labels:
31 app: {{ include "common.name" . }}
Krzysztof Opasiak137d7cc2020-01-24 23:49:11 +010032 release: {{ include "common.release" . }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010033 name: {{ include "common.name" . }}
34 spec:
35 initContainers:
36 - name: {{ include "common.name" . }}-readiness
37 command:
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020038 - /app/ready.py
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010039 args:
40 - --container-name
41 - {{ .Values.global.mariadbGalera.nameOverride }}
42 env:
43 - name: NAMESPACE
44 valueFrom:
45 fieldRef:
46 apiVersion: v1
47 fieldPath: metadata.namespace
Sylvain Desbureaux1694e1d2020-08-21 09:58:25 +020048 image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010049 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50 containers:
51 - name: {{ include "common.name" . }}
52 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
53 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
54 command:
55 - bash
56 - /db_init/db_init.sh
57 env:
58 - name: DB_HOST
59 value: "{{ .Values.global.mariadbGalera.nameOverride }}"
60 - name: DB_PORT
61 value: "{{ .Values.global.mariadbGalera.servicePort }}"
62 - name: MYSQL_ROOT_PASSWORD
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010063 {{- include "common.secret.envFromSecret" (dict "global" . "uid" "root-password" "key" (default "password" .Values.global.mariadbGalera.userRootSecretKey)) | indent 10 }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010064 - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010065 {{- include "common.secret.envFromSecret" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "login") | indent 10 }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010066 - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010067 {{- include "common.secret.envFromSecret" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010068{{- $root := . }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010069{{ range $db, $_values := .Values.config.mysqlAdditionalDatabases }}
Krzysztof Opasiakf54d6682020-01-08 18:35:44 +010070 - name: {{ printf "MYSQL_USER_%s" $db | upper }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010071 {{- include "common.secret.envFromSecret" (dict "global" $root "uid" $db "key" "login") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010072 - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }}
Krzysztof Opasiakd7322442020-01-30 12:10:40 +010073 {{- include "common.secret.envFromSecret" (dict "global" $root "uid" $db "key" "password") | indent 10 }}
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +010074{{ end }}
75 volumeMounts:
76 - mountPath: /etc/localtime
77 name: localtime
78 readOnly: true
79 - name: mariadb-conf
80 mountPath: /db_init/
81 readOnly: true
82 resources:
83{{ include "common.resources" . | indent 12 }}
84 {{- if .Values.nodeSelector }}
85 nodeSelector:
86{{ toYaml .Values.nodeSelector | indent 10 }}
87 {{- end -}}
88 {{- if .Values.affinity }}
89 affinity:
90{{ toYaml .Values.affinity | indent 10 }}
91 {{- end }}
92 volumes:
93 - name: mariadb-conf
94 configMap:
95 name: {{ include "mariadbInit.configMap" . }}
96 - name: localtime
97 hostPath:
98 path: /etc/localtime
99 restartPolicy: Never
100 imagePullSecrets:
101 - name: "{{ include "common.namespace" . }}-docker-registry-key"