[GENERAL] Use readiness container v3.0.1
[oom.git] / kubernetes / policy / templates / job.yaml
1 # Copyright © 2018 Amdocs, Bell Canada
2 # Modifications Copyright © 2020 AT&T Intellectual Property
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.release" . }}-policy-galera-config
20   namespace: {{ include "common.namespace" . }}
21   labels:
22     app: {{ include "common.name" . }}-job
23     release: {{ include "common.release" . }}
24 spec:
25   template:
26     metadata:
27       labels:
28         app: {{ include "common.name" . }}-job
29         release: {{ include "common.release" . }}
30     spec:
31       initContainers:
32 #This container checks that all galera instances are up before initializing it.
33       - name: {{ include "common.name" . }}-readiness
34         image: "{{ include "common.repository" . }}/{{ .Values.global.readinessImage }}"
35         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
36         command:
37         - /app/ready.py
38         - --container-name
39         - {{ index .Values "mariadb-galera" "service" "name" }}
40         env:
41         - name: NAMESPACE
42           valueFrom:
43             fieldRef:
44               apiVersion: v1
45               fieldPath: metadata.namespace
46       containers:
47       - name: {{ include "common.release" . }}-policy-galera-config
48         image: {{ .Values.mariadb_image }}
49         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
50         volumeMounts:
51         - mountPath: /dbcmd-config/db.sh
52           name: {{ include "common.fullname" . }}-config
53           subPath: db.sh
54         command:
55         - /bin/sh
56         args:
57         - -x
58         - /dbcmd-config/db.sh
59         env:
60         - name: MYSQL_ROOT_PASSWORD
61           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-root-password" "key" "password") | indent 10 }}
62         - name: MYSQL_HOST
63           value: "{{ index .Values "mariadb-galera" "service" "name" }}"
64         - name: MYSQL_USER
65           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" "db-secret" "key" "login") | indent 10 }}
66         - name: MYSQL_PORT
67           value: "{{ index .Values "mariadb-galera" "service" "internalPort" }}"
68       restartPolicy: Never
69       volumes:
70         - name: {{ include "common.fullname" . }}-config
71           configMap:
72             name: {{ include "common.fullname" . }}-db-configmap
73             items:
74               - key: db.sh
75                 path: db.sh