Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 1 | # Copyright © 2019 Orange |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 2 | # Copyright © 2020 Samsung Electronics |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 3 | # |
| 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 | |
| 16 | apiVersion: batch/v1 |
| 17 | kind: Job |
| 18 | metadata: |
| 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 Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame^] | 24 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 25 | heritage: {{ .Release.Service }} |
| 26 | spec: |
| 27 | backoffLimit: 20 |
| 28 | template: |
| 29 | metadata: |
| 30 | labels: |
| 31 | app: {{ include "common.name" . }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame^] | 32 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 33 | name: {{ include "common.name" . }} |
| 34 | spec: |
| 35 | initContainers: |
| 36 | - name: {{ include "common.name" . }}-readiness |
| 37 | command: |
| 38 | - /root/ready.py |
| 39 | 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 |
| 48 | image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}" |
| 49 | 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 |
| 63 | valueFrom: |
| 64 | secretKeyRef: |
| 65 | name: {{ include "mariadbInit.mariadbClusterSecret" . }} |
| 66 | key: {{ .Values.global.mariadbGalera.userRootSecretKey }} |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 67 | - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }} |
| 68 | value: "{{ .Values.config.userName }}" |
| 69 | - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 70 | valueFrom: |
| 71 | secretKeyRef: |
| 72 | name: {{ template "common.fullname" . }} |
| 73 | key: db-user-password |
| 74 | {{- $root := . }} |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 75 | {{ range $db, $dbInfos := .Values.config.mysqlAdditionalDatabases }} |
| 76 | - name: {{ printf "MYSQL_USER_%s" $db | upper }} |
| 77 | value: {{ $dbInfos.user }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 78 | - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }} |
| 79 | valueFrom: |
| 80 | secretKeyRef: |
| 81 | name: {{ template "common.fullname" $root }}-secret |
| 82 | key: {{ printf "db-%s-user-password" $db }} |
| 83 | {{ end }} |
| 84 | volumeMounts: |
| 85 | - mountPath: /etc/localtime |
| 86 | name: localtime |
| 87 | readOnly: true |
| 88 | - name: mariadb-conf |
| 89 | mountPath: /db_init/ |
| 90 | readOnly: true |
| 91 | resources: |
| 92 | {{ include "common.resources" . | indent 12 }} |
| 93 | {{- if .Values.nodeSelector }} |
| 94 | nodeSelector: |
| 95 | {{ toYaml .Values.nodeSelector | indent 10 }} |
| 96 | {{- end -}} |
| 97 | {{- if .Values.affinity }} |
| 98 | affinity: |
| 99 | {{ toYaml .Values.affinity | indent 10 }} |
| 100 | {{- end }} |
| 101 | volumes: |
| 102 | - name: mariadb-conf |
| 103 | configMap: |
| 104 | name: {{ include "mariadbInit.configMap" . }} |
| 105 | - name: localtime |
| 106 | hostPath: |
| 107 | path: /etc/localtime |
| 108 | restartPolicy: Never |
| 109 | imagePullSecrets: |
| 110 | - name: "{{ include "common.namespace" . }}-docker-registry-key" |