Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / mariadb-init / templates / job.yaml
1 {{/*
2 # Copyright © 2019 Orange
3 # Copyright © 2020 Samsung Electronics
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.
16 */}}
17
18 {{ include "mariadbInit._updateSecrets" . -}}
19
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 "+" "_" }}
28     release: {{ include "common.release" . }}
29     heritage: {{ .Release.Service }}
30 spec:
31   backoffLimit: 20
32   template:
33     metadata:
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"
40       labels:
41         app: {{ include "common.name" . }}
42         release: {{ include "common.release" . }}
43       name: {{ include "common.name" . }}
44     spec:
45       initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
46       containers:
47       - name: {{ include "common.name" . }}
48         image: {{ include "repositoryGenerator.image.mariadb" . }}
49         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50         command:
51           - /bin/sh
52           - -c
53           - |
54             {{- if include "common.onServiceMesh" . }}
55             echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
56             /db_init/db_init.sh {{ if or .Values.dbScriptConfigMap .Values.dbScript }} &&
57             /db_config/db_cmd.sh{{ end }}
58         env:
59         - name: DB_HOST
60           value: {{ include "common.mariadbService" . }}
61         - name: DB_PORT
62           value: {{ include "common.mariadbPort" . | quote }}
63         - name: MYSQL_ROOT_PASSWORD
64           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "root-password" "key" (default "password" .Values.global.mariadbGalera.userRootSecretKey)) | indent 10 }}
65         - name: {{ printf "MYSQL_USER_%s" .Values.config.mysqlDatabase | upper }}
66           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "login") | indent 10 }}
67         - name: {{ printf "MYSQL_PASSWORD_%s" .Values.config.mysqlDatabase | upper }}
68           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" .Values.config.mysqlDatabase "key" "password") | indent 10 }}
69 {{- $root := . }}
70 {{ range $db, $_values := .Values.config.mysqlAdditionalDatabases }}
71         - name: {{ printf "MYSQL_USER_%s" $db | upper }}
72           {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "login") | indent 10 }}
73         - name: {{ printf "MYSQL_PASSWORD_%s" $db | upper }}
74           {{- include "common.secret.envFromSecretFast" (dict "global" $root "uid" $db "key" "password") | indent 10 }}
75 {{ end }}
76         volumeMounts:
77         - name: mariadb-init
78           mountPath: /db_init/
79 {{- if or .Values.dbScriptConfigMap .Values.dbScript }}
80         - name: mariadb-conf
81           mountPath: /db_config/
82 {{- end }}
83         resources: {{ include "common.resources" . | nindent 10 }}
84       {{ include "common.waitForJobContainer" . | indent 6 | trim }}
85       {{- if .Values.nodeSelector }}
86       nodeSelector:
87 {{ toYaml .Values.nodeSelector | indent 10 }}
88       {{- end -}}
89       {{- if .Values.affinity }}
90       affinity:
91 {{ toYaml .Values.affinity | indent 10 }}
92       {{- end }}
93       serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
94       volumes:
95 {{- if  or .Values.dbScriptConfigMap .Values.dbScript }}
96       - name: mariadb-conf
97         configMap:
98 {{-   if  .Values.dbScriptConfigMap }}
99           name: {{ tpl .Values.dbScriptConfigMap . }}
100 {{-   else -}}
101           name: {{ include "common.fullname" . }}-dbscript
102 {{-   end }}
103           defaultMode: 0755
104 {{- end }}
105       - name: mariadb-init
106         configMap:
107           name: {{ include "mariadbInit.configMap" . }}
108           defaultMode: 0755
109       restartPolicy: Never
110       {{- include "common.imagePullSecrets" . | nindent 6 }}