blob: 6736559b81f9550a497b3816e6574658347cf2e4 [file] [log] [blame]
Abdelmuhaimen Seaudi988aeed2021-09-23 21:11:44 +00001{{/*
2# Copyright © 2021 Orange
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
17apiVersion: batch/v1
18kind: Job
19metadata:
20 name: {{ include "common.fullname" . }}-config-job
21 namespace: {{ include "common.namespace" . }}
22 labels:
23 app: {{ include "common.name" . }}
24 chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
25 release: {{ include "common.release" . }}
26 heritage: {{ .Release.Service }}
27spec:
28 backoffLimit: 20
29 template:
30 metadata:
31 labels:
32 app: {{ include "common.name" . }}
33 release: {{ include "common.release" . }}
34 name: {{ include "common.name" . }}
35 spec:
rajesh.kumar062e7c22023-10-17 15:29:20 +053036 initContainers: {{ include "common.readinessCheck.waitFor" . | nindent 6 }}
Abdelmuhaimen Seaudi988aeed2021-09-23 21:11:44 +000037 containers:
38 - command:
39 - sh
40 args:
41 - -c
42 - |
43 function prepare_password {
44 echo -n $1 | sed -e "s/'/''/g"
45 }
46 export PG_PASSWORD=`prepare_password $PG_PASSWORD_INPUT`;
47 export PG_ROOT_PASSWORD=`prepare_password $PG_ROOT_PASSWORD_INPUT`;
Andreas Geissler02398152022-05-10 10:30:11 +020048 {{- if include "common.onServiceMesh" . }}
49 echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
Abdelmuhaimen Seaudi988aeed2021-09-23 21:11:44 +000050 cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done;
51 psql "postgresql://postgres:$PG_ROOT_PASSWORD@$PG_HOST" < /config/setup.sql
52 env:
53 - name: PG_HOST
54 value: "{{ .Values.global.postgres.service.name2 }}"
55 - name: PG_PRIMARY_USER
56 value: primaryuser
57 - name: MODE
58 value: postgres
59 - name: PG_PRIMARY_PASSWORD_INPUT
60 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.postgres.secret.primaryPasswordUID" .) "key" "password") | indent 10 }}
61 - name: PG_USER
62 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "login") | indent 10 }}
63 - name: PG_PASSWORD_INPUT
64 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.postgres.secret.userCredentialsUID" .) "key" "password") | indent 10 }}
65 - name: PG_DATABASE
66 value: "{{ .Values.config.pgDatabase }}"
67 - name: PG_ROOT_PASSWORD_INPUT
68 {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
Abdelmuhaimen Seaudi988aeed2021-09-23 21:11:44 +000069 image: {{ include "repositoryGenerator.image.postgres" . }}
70 imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
71 name: {{ include "common.name" . }}-update-config
72 volumeMounts:
73 - mountPath: /etc/localtime
74 name: localtime
75 readOnly: true
76 - mountPath: /config-input/setup.sql
77 name: config
78 subPath: setup.sql
79 - mountPath: /config
80 name: pgconf
miroslavmasaryka7ac7f02023-03-01 14:12:26 +010081 resources: {{ include "common.resources" . | nindent 10 }}
Andreas Geissler02398152022-05-10 10:30:11 +020082 {{ include "common.waitForJobContainer" . | indent 6 | trim }}
Abdelmuhaimen Seaudi988aeed2021-09-23 21:11:44 +000083 {{- if .Values.nodeSelector }}
84 nodeSelector:
85{{ toYaml .Values.nodeSelector | indent 10 }}
86 {{- end -}}
87 {{- if .Values.affinity }}
88 affinity:
89{{ toYaml .Values.affinity | indent 10 }}
90 {{- end }}
vladimir turokd8044182023-07-27 16:28:36 +020091 serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
Abdelmuhaimen Seaudi988aeed2021-09-23 21:11:44 +000092 volumes:
93 - name: localtime
94 hostPath:
95 path: /etc/localtime
96 - name: config
97 configMap:
98 name: {{ include "common.fullname" . }}
99 - name: pgconf
100 emptyDir:
101 medium: Memory
102 restartPolicy: Never
Andreas Geisslerbd0d31a2024-03-20 09:51:32 +0100103 {{- include "common.imagePullSecrets" . | nindent 6 }}