blob: 679c10c9a320cc95909c1daf05c96b3ecea49e93 [file] [log] [blame]
Sylvain Desbureaux1d061a42019-11-08 15:27:20 +01001# Copyright © 2019 Orange
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15apiVersion: batch/v1
16kind: Job
17metadata:
18 name: {{ include "common.fullname" . }}-config-job
19 namespace: {{ include "common.namespace" . }}
20 labels:
21 app: {{ include "common.name" . }}
22 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
23 release: {{ .Release.Name }}
24 heritage: {{ .Release.Service }}
25spec:
26 backoffLimit: 20
27 template:
28 metadata:
29 labels:
30 app: {{ include "common.name" . }}
31 release: {{ .Release.Name }}
32 name: {{ include "common.name" . }}
33 spec:
34 initContainers:
35 - name: {{ include "common.name" . }}-readiness
36 command:
37 - /root/ready.py
38 args:
39 - --container-name
40 - {{ .Values.global.mariadbGalera.nameOverride }}
41 env:
42 - name: NAMESPACE
43 valueFrom:
44 fieldRef:
45 apiVersion: v1
46 fieldPath: metadata.namespace
47 image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
48 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
49 containers:
50 - name: {{ include "common.name" . }}
51 image: "{{ include "common.repository" . }}/{{ .Values.image }}"
52 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
53 command:
54 - bash
55 - /db_init/db_init.sh
56 env:
57 - name: DB_HOST
58 value: "{{ .Values.global.mariadbGalera.nameOverride }}"
59 - name: DB_PORT
60 value: "{{ .Values.global.mariadbGalera.servicePort }}"
61 - name: MYSQL_ROOT_PASSWORD
62 valueFrom:
63 secretKeyRef:
64 name: {{ include "mariadbInit.mariadbClusterSecret" . }}
65 key: {{ .Values.global.mariadbGalera.userRootSecretKey }}
66 - name: MYSQL_PASSWORD
67 valueFrom:
68 secretKeyRef:
69 name: {{ template "common.fullname" . }}
70 key: db-user-password
71{{- $root := . }}
72{{ range $db, $_value := .Values.config.mysqlAdditionalDatabases }}
73 - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }}
74 valueFrom:
75 secretKeyRef:
76 name: {{ template "common.fullname" $root }}-secret
77 key: {{ printf "db-%s-user-password" $db }}
78{{ end }}
79 volumeMounts:
80 - mountPath: /etc/localtime
81 name: localtime
82 readOnly: true
83 - name: mariadb-conf
84 mountPath: /db_init/
85 readOnly: true
86 resources:
87{{ include "common.resources" . | indent 12 }}
88 {{- if .Values.nodeSelector }}
89 nodeSelector:
90{{ toYaml .Values.nodeSelector | indent 10 }}
91 {{- end -}}
92 {{- if .Values.affinity }}
93 affinity:
94{{ toYaml .Values.affinity | indent 10 }}
95 {{- end }}
96 volumes:
97 - name: mariadb-conf
98 configMap:
99 name: {{ include "mariadbInit.configMap" . }}
100 - name: localtime
101 hostPath:
102 path: /etc/localtime
103 restartPolicy: Never
104 imagePullSecrets:
105 - name: "{{ include "common.namespace" . }}-docker-registry-key"