Skip to content

Commit beab097

Browse files
committed
Introduced initContainers to wait for db and its bootstrap.
1 parent aaa7474 commit beab097

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

helm-chart/eoapi/templates/pgstacboostrap/job.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ spec:
1313
app: {{ include "eoapi.pgstacHostName" . | nindent 14 }}
1414
spec:
1515
restartPolicy: Never
16+
initContainers:
17+
- name: wait-for-db
18+
image: busybox
19+
command: ['sh', '-c', 'until nc -z eoapi-pgbouncer 5432; do echo waiting for db; sleep 2; done;']
1620
containers:
1721
- name: pgstacbootstrap
1822
image: {{ .Values.pgstacBootstrap.image.name }}:{{ .Values.pgstacBootstrap.image.tag }}

helm-chart/eoapi/templates/services/deployment.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ spec:
2929
labels:
3030
app: {{ $serviceName }}-{{ $.Release.Name }}
3131
spec:
32+
{{- if eq $serviceName "stac" }}
33+
initContainers:
34+
- name: wait-for-pgstacbootstrap
35+
image: bitnami/kubectl:latest
36+
command:
37+
- /bin/sh
38+
- -c
39+
- |
40+
echo "Waiting for pgstacbootstrap job to complete..."
41+
while ! kubectl -n eoapi get job pgstacbootstrap -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}' | grep -q "True"; do
42+
sleep 5
43+
done
44+
echo "pgstacbootstrap job completed successfully"
45+
{{- end }}
3246
containers:
3347
- image: {{ index $v "image" "name" }}:{{ index $v "image" "tag" }}
3448
name: {{ $serviceName }}

0 commit comments

Comments
 (0)