[OOM] Fixing k8s ServiceAccounts
[oom.git] / kubernetes / common / postgres-init / templates / job.yaml
index 01151bb..09c21fe 100644 (file)
@@ -59,6 +59,8 @@ spec:
           }
           export PG_PASSWORD=`prepare_password $PG_PASSWORD_INPUT`;
           export PG_ROOT_PASSWORD=`prepare_password $PG_ROOT_PASSWORD_INPUT`;
+          {{- if include "common.onServiceMesh" . }}
+          echo "waiting 15s for istio side cars to be up"; sleep 15s;{{- end }}
           cd /config-input && for PFILE in `ls -1 .`; do envsubst <${PFILE} >/config/${PFILE}; done;
           psql "postgresql://postgres:$PG_ROOT_PASSWORD@$PG_HOST" < /config/setup.sql
         env:
@@ -78,12 +80,6 @@ spec:
           value: "{{ .Values.config.pgDatabase }}"
         - name: PG_ROOT_PASSWORD_INPUT
           {{- include "common.secret.envFromSecretFast" (dict "global" . "uid" (include "common.postgres.secret.rootPassUID" .) "key" "password") | indent 10 }}
-        volumeMounts:
-        - mountPath: /config-input/setup.sql
-          name: config
-          subPath: setup.sql
-        - mountPath: /config
-          name: pgconf
         image: {{ include "repositoryGenerator.image.postgres" . }}
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         name: {{ include "common.name" . }}-update-config
@@ -96,8 +92,8 @@ spec:
           subPath: setup.sql
         - mountPath: /config
           name: pgconf
-        resources:
-{{ include "common.resources" . | indent 12 }}
+        resources: {{ include "common.resources" . | nindent 10 }}
+      {{ include "common.waitForJobContainer" . | indent 6 | trim }}
       {{- if .Values.nodeSelector }}
       nodeSelector:
 {{ toYaml .Values.nodeSelector | indent 10 }}
@@ -106,6 +102,7 @@ spec:
       affinity:
 {{ toYaml .Values.affinity | indent 10 }}
       {{- end }}
+      serviceAccountName: {{ include "common.fullname" (dict "suffix" "read" "dot" . )}}
       volumes:
       - name: localtime
         hostPath: