Jakub Latusek | 3659d9f | 2020-09-14 16:21:55 +0200 | [diff] [blame] | 1 | {{/* |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 2 | # Copyright © 2019 Orange |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 3 | # Copyright © 2020 Samsung Electronics |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 4 | # |
| 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 Latusek | 3659d9f | 2020-09-14 16:21:55 +0200 | [diff] [blame] | 16 | */}} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 17 | |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 18 | {{ include "mariadbInit._updateSecrets" . -}} |
| 19 | |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 20 | apiVersion: batch/v1 |
| 21 | kind: Job |
| 22 | metadata: |
| 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 Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 28 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 29 | heritage: {{ .Release.Service }} |
| 30 | spec: |
| 31 | backoffLimit: 20 |
| 32 | template: |
| 33 | metadata: |
| 34 | labels: |
| 35 | app: {{ include "common.name" . }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 36 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 37 | name: {{ include "common.name" . }} |
| 38 | spec: |
| 39 | initContainers: |
| 40 | - name: {{ include "common.name" . }}-readiness |
| 41 | command: |
Sylvain Desbureaux | 1694e1d | 2020-08-21 09:58:25 +0200 | [diff] [blame] | 42 | - /app/ready.py |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 43 | args: |
| 44 | - --container-name |
Krzysztof Opasiak | 80e39d4 | 2020-08-31 22:25:52 +0200 | [diff] [blame] | 45 | - {{ default .Values.global.mariadbGalera.nameOverride .Values.mariadbGalera.containerName }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 46 | env: |
| 47 | - name: NAMESPACE |
| 48 | valueFrom: |
| 49 | fieldRef: |
| 50 | apiVersion: v1 |
| 51 | fieldPath: metadata.namespace |
Sylvain Desbureaux | 1694e1d | 2020-08-21 09:58:25 +0200 | [diff] [blame] | 52 | image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}" |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 53 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 54 | containers: |
| 55 | - name: {{ include "common.name" . }} |
| 56 | image: "{{ include "common.repository" . }}/{{ .Values.image }}" |
| 57 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 58 | command: |
| 59 | - bash |
| 60 | - /db_init/db_init.sh |
| 61 | env: |
| 62 | - name: DB_HOST |
Krzysztof Opasiak | 80e39d4 | 2020-08-31 22:25:52 +0200 | [diff] [blame] | 63 | value: "{{ default .Values.global.mariadbGalera.nameOverride .Values.mariadbGalera.serviceName }}" |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 64 | - name: DB_PORT |
Krzysztof Opasiak | 80e39d4 | 2020-08-31 22:25:52 +0200 | [diff] [blame] | 65 | value: "{{ default .Values.global.mariadbGalera.servicePort .Values.mariadbGalera.servicePort }}" |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 66 | - name: MYSQL_ROOT_PASSWORD |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 67 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-password" "key" (default "password" .Values.global.mariadbGalera.userRootSecretKey)) | indent 10 }} |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 68 | - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 69 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "login") | indent 10 }} |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 70 | - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 71 | {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "password") | indent 10 }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 72 | {{- $root := . }} |
Krzysztof Opasiak | d732244 | 2020-01-30 12:10:40 +0100 | [diff] [blame] | 73 | {{ range $db, $_values := .Values.config.mysqlAdditionalDatabases }} |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 74 | - name: {{ printf "MYSQL_USER_%s" $db | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 75 | {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "login") | indent 10 }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 76 | - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 77 | {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "password") | indent 10 }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 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" |