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: |
Andreas Geissler | d518f73 | 2024-03-25 11:15:11 +0100 | [diff] [blame] | 34 | annotations: |
| 35 | # Workarround to exclude K8S API from istio communication |
| 36 | # as init-container (readinessCheck) does not work with the |
| 37 | # Istio CNI plugin, see: |
| 38 | # (https://istio.io/latest/docs/setup/additional-setup/cni/#compatibility-with-application-init-containers) |
| 39 | traffic.sidecar.istio.io/excludeOutboundPorts: "443" |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 40 | labels: |
| 41 | app: {{ include "common.name" . }} |
Krzysztof Opasiak | 137d7cc | 2020-01-24 23:49:11 +0100 | [diff] [blame] | 42 | release: {{ include "common.release" . }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 43 | name: {{ include "common.name" . }} |
| 44 | spec: |
Andreas Geissler | d518f73 | 2024-03-25 11:15:11 +0100 | [diff] [blame] | 45 | initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 46 | containers: |
| 47 | - name: {{ include "common.name" . }} |
Sylvain Desbureaux | 72bbabf | 2020-11-19 17:15:14 +0100 | [diff] [blame] | 48 | image: {{ include "repositoryGenerator.image.mariadb" . }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 49 | imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} |
| 50 | command: |
RPMishra | e4ee7f1 | 2020-10-07 12:09:01 +0530 | [diff] [blame] | 51 | - /bin/sh |
| 52 | - -c |
| 53 | - | |
Andreas Geissler | ba1200c | 2022-04-07 17:02:59 +0200 | [diff] [blame] | 54 | {{- if include "common.onServiceMesh" . }} |
| 55 | echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }} |
RPMishra | e4ee7f1 | 2020-10-07 12:09:01 +0530 | [diff] [blame] | 56 | /db_init/db_init.sh {{ if or .Values.dbScriptConfigMap .Values.dbScript }} && |
| 57 | /db_config/db_cmd.sh{{ end }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 58 | env: |
| 59 | - name: DB_HOST |
Mahmoud Abdelhamid | e351f51 | 2021-05-04 17:52:04 +0200 | [diff] [blame] | 60 | value: {{ include "common.mariadbService" . }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 61 | - name: DB_PORT |
Mahmoud Abdelhamid | e351f51 | 2021-05-04 17:52:04 +0200 | [diff] [blame] | 62 | value: {{ include "common.mariadbPort" . | quote }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 63 | - name: MYSQL_ROOT_PASSWORD |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 64 | {{- 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] | 65 | - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 66 | {{- 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] | 67 | - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 68 | {{- 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] | 69 | {{- $root := . }} |
Krzysztof Opasiak | d732244 | 2020-01-30 12:10:40 +0100 | [diff] [blame] | 70 | {{ range $db, $_values := .Values.config.mysqlAdditionalDatabases }} |
Krzysztof Opasiak | f54d668 | 2020-01-08 18:35:44 +0100 | [diff] [blame] | 71 | - name: {{ printf "MYSQL_USER_%s" $db | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 72 | {{- 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] | 73 | - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }} |
Krzysztof Opasiak | ed7b049 | 2020-09-01 18:35:40 +0200 | [diff] [blame] | 74 | {{- 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] | 75 | {{ end }} |
| 76 | volumeMounts: |
| 77 | - mountPath: /etc/localtime |
| 78 | name: localtime |
| 79 | readOnly: true |
Mahmoud Abdelhamid | e351f51 | 2021-05-04 17:52:04 +0200 | [diff] [blame] | 80 | - name: mariadb-init |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 81 | mountPath: /db_init/ |
RPMishra | e4ee7f1 | 2020-10-07 12:09:01 +0530 | [diff] [blame] | 82 | {{- if or .Values.dbScriptConfigMap .Values.dbScript }} |
Mahmoud Abdelhamid | e351f51 | 2021-05-04 17:52:04 +0200 | [diff] [blame] | 83 | - name: mariadb-conf |
RPMishra | e4ee7f1 | 2020-10-07 12:09:01 +0530 | [diff] [blame] | 84 | mountPath: /db_config/ |
| 85 | {{- end }} |
miroslavmasaryk | a7ac7f0 | 2023-03-01 14:12:26 +0100 | [diff] [blame] | 86 | resources: {{ include "common.resources" . | nindent 10 }} |
Andreas Geissler | ba1200c | 2022-04-07 17:02:59 +0200 | [diff] [blame] | 87 | {{ include "common.waitForJobContainer" . | indent 6 | trim }} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 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 }} |
vladimir turok | d804418 | 2023-07-27 16:28:36 +0200 | [diff] [blame] | 96 | serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}} |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 97 | volumes: |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 98 | - name: localtime |
| 99 | hostPath: |
| 100 | path: /etc/localtime |
RPMishra | e4ee7f1 | 2020-10-07 12:09:01 +0530 | [diff] [blame] | 101 | {{- if or .Values.dbScriptConfigMap .Values.dbScript }} |
Mahmoud Abdelhamid | e351f51 | 2021-05-04 17:52:04 +0200 | [diff] [blame] | 102 | - name: mariadb-conf |
RPMishra | e4ee7f1 | 2020-10-07 12:09:01 +0530 | [diff] [blame] | 103 | configMap: |
| 104 | {{- if .Values.dbScriptConfigMap }} |
| 105 | name: {{ tpl .Values.dbScriptConfigMap . }} |
| 106 | {{- else -}} |
| 107 | name: {{ include "common.fullname" . }}-dbscript |
| 108 | {{- end }} |
| 109 | defaultMode: 0755 |
| 110 | {{- end }} |
Mahmoud Abdelhamid | e351f51 | 2021-05-04 17:52:04 +0200 | [diff] [blame] | 111 | - name: mariadb-init |
RPMishra | e4ee7f1 | 2020-10-07 12:09:01 +0530 | [diff] [blame] | 112 | configMap: |
| 113 | name: {{ include "mariadbInit.configMap" . }} |
| 114 | defaultMode: 0755 |
Sylvain Desbureaux | 1d061a4 | 2019-11-08 15:27:20 +0100 | [diff] [blame] | 115 | restartPolicy: Never |
Andreas Geissler | bd0d31a | 2024-03-20 09:51:32 +0100 | [diff] [blame] | 116 | {{- include "common.imagePullSecrets" . | nindent 6 }} |