Skip to content

Commit 0cbb05c

Browse files
committed
Introduced initContainers to wait for DB/MQ availability
1 parent 428edb5 commit 0cbb05c

File tree

2 files changed

+262
-3
lines changed

2 files changed

+262
-3
lines changed

templates/deployments.yaml

Lines changed: 226 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ spec:
4343
{{- end }}
4444
# Sidecar container for generating .htpasswd with st2 username & password pair and sharing produced file with the main st2auth container
4545
initContainers:
46+
- name: wait-for-db
47+
image: busybox:1.28
48+
command:
49+
- 'sh'
50+
- '-c'
51+
- >
52+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
53+
do sleep 2;
54+
done
55+
- name: wait-for-queue
56+
image: busybox:1.28
57+
command:
58+
- 'sh'
59+
- '-c'
60+
- >
61+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
62+
do sleep 2;
63+
done
4664
- name: generate-htpasswd
4765
image: "{{ template "imageRepository" . }}/st2auth{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
4866
imagePullPolicy: {{ .Values.image.pullPolicy }}
@@ -158,8 +176,26 @@ spec:
158176
{{- if .Values.image.pullSecret }}
159177
- name: {{ .Values.image.pullSecret }}
160178
{{- end }}
161-
{{- if .Values.st2.packs.image.repository }}
162179
initContainers:
180+
- name: wait-for-db
181+
image: busybox:1.28
182+
command:
183+
- 'sh'
184+
- '-c'
185+
- >
186+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
187+
do sleep 2;
188+
done
189+
- name: wait-for-queue
190+
image: busybox:1.28
191+
command:
192+
- 'sh'
193+
- '-c'
194+
- >
195+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
196+
do sleep 2;
197+
done
198+
{{- if .Values.st2.packs.image.repository }}
163199
# Merge packs and virtualenvs from st2api with those from the st2.packs image
164200
# Custom packs
165201
- name: st2-custom-packs
@@ -302,6 +338,25 @@ spec:
302338
{{- if .Values.image.pullSecret }}
303339
- name: {{ .Values.image.pullSecret }}
304340
{{- end }}
341+
initContainers:
342+
- name: wait-for-db
343+
image: busybox:1.28
344+
command:
345+
- 'sh'
346+
- '-c'
347+
- >
348+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
349+
do sleep 2;
350+
done
351+
- name: wait-for-queue
352+
image: busybox:1.28
353+
command:
354+
- 'sh'
355+
- '-c'
356+
- >
357+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
358+
do sleep 2;
359+
done
305360
containers:
306361
- name: st2stream{{ template "enterpriseSuffix" . }}
307362
image: "{{ template "imageRepository" . }}/st2stream{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -487,6 +542,25 @@ spec:
487542
{{- if .Values.image.pullSecret }}
488543
- name: {{ .Values.image.pullSecret }}
489544
{{- end }}
545+
initContainers:
546+
- name: wait-for-db
547+
image: busybox:1.28
548+
command:
549+
- 'sh'
550+
- '-c'
551+
- >
552+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
553+
do sleep 2;
554+
done
555+
- name: wait-for-queue
556+
image: busybox:1.28
557+
command:
558+
- 'sh'
559+
- '-c'
560+
- >
561+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
562+
do sleep 2;
563+
done
490564
containers:
491565
- name: st2rulesengine{{ template "enterpriseSuffix" . }}
492566
image: "{{ template "imageRepository" . }}/st2rulesengine{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -577,6 +651,25 @@ spec:
577651
{{- if .Values.image.pullSecret }}
578652
- name: {{ .Values.image.pullSecret }}
579653
{{- end }}
654+
initContainers:
655+
- name: wait-for-db
656+
image: busybox:1.28
657+
command:
658+
- 'sh'
659+
- '-c'
660+
- >
661+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
662+
do sleep 2;
663+
done
664+
- name: wait-for-queue
665+
image: busybox:1.28
666+
command:
667+
- 'sh'
668+
- '-c'
669+
- >
670+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
671+
do sleep 2;
672+
done
580673
containers:
581674
- name: st2timersengine{{ template "enterpriseSuffix" . }}
582675
image: "{{ template "imageRepository" . }}/st2timersengine{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -659,6 +752,25 @@ spec:
659752
{{- if .Values.image.pullSecret }}
660753
- name: {{ .Values.image.pullSecret }}
661754
{{- end }}
755+
initContainers:
756+
- name: wait-for-db
757+
image: busybox:1.28
758+
command:
759+
- 'sh'
760+
- '-c'
761+
- >
762+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
763+
do sleep 2;
764+
done
765+
- name: wait-for-queue
766+
image: busybox:1.28
767+
command:
768+
- 'sh'
769+
- '-c'
770+
- >
771+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
772+
do sleep 2;
773+
done
662774
containers:
663775
- name: st2workflowengine{{ template "enterpriseSuffix" . }}
664776
image: "{{ template "imageRepository" . }}/st2workflowengine{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -753,6 +865,25 @@ spec:
753865
{{- if .Values.image.pullSecret }}
754866
- name: {{ .Values.image.pullSecret }}
755867
{{- end }}
868+
initContainers:
869+
- name: wait-for-db
870+
image: busybox:1.28
871+
command:
872+
- 'sh'
873+
- '-c'
874+
- >
875+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
876+
do sleep 2;
877+
done
878+
- name: wait-for-queue
879+
image: busybox:1.28
880+
command:
881+
- 'sh'
882+
- '-c'
883+
- >
884+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
885+
do sleep 2;
886+
done
756887
containers:
757888
- name: st2scheduler{{ template "enterpriseSuffix" . }}
758889
image: "{{ template "imageRepository" . }}/st2scheduler{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -847,6 +978,25 @@ spec:
847978
{{- if .Values.image.pullSecret }}
848979
- name: {{ .Values.image.pullSecret }}
849980
{{- end }}
981+
initContainers:
982+
- name: wait-for-db
983+
image: busybox:1.28
984+
command:
985+
- 'sh'
986+
- '-c'
987+
- >
988+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
989+
do sleep 2;
990+
done
991+
- name: wait-for-queue
992+
image: busybox:1.28
993+
command:
994+
- 'sh'
995+
- '-c'
996+
- >
997+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
998+
do sleep 2;
999+
done
8501000
containers:
8511001
- name: st2notifier{{ template "enterpriseSuffix" . }}
8521002
image: "{{ template "imageRepository" . }}/st2notifier{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -939,8 +1089,26 @@ spec:
9391089
{{- if $.Values.image.pullSecret }}
9401090
- name: {{ $.Values.image.pullSecret }}
9411091
{{- end }}
942-
{{- if $.Values.st2.packs.image.repository }}
9431092
initContainers:
1093+
- name: wait-for-db
1094+
image: busybox:1.28
1095+
command:
1096+
- 'sh'
1097+
- '-c'
1098+
- >
1099+
until nc -z -w 2 {{ $.Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
1100+
do sleep 2;
1101+
done
1102+
- name: wait-for-queue
1103+
image: busybox:1.28
1104+
command:
1105+
- 'sh'
1106+
- '-c'
1107+
- >
1108+
until nc -z -w 2 {{ $.Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
1109+
do sleep 2;
1110+
done
1111+
{{- if $.Values.st2.packs.image.repository }}
9441112
# Merge packs and virtualenvs from st2sensorcontainer with those from the st2.packs image
9451113
# Custom packs
9461114
- name: st2-custom-packs
@@ -1108,8 +1276,26 @@ spec:
11081276
{{- if .Values.image.pullSecret }}
11091277
- name: {{ .Values.image.pullSecret }}
11101278
{{- end }}
1111-
{{- if .Values.st2.packs.image.repository }}
11121279
initContainers:
1280+
- name: wait-for-db
1281+
image: busybox:1.28
1282+
command:
1283+
- 'sh'
1284+
- '-c'
1285+
- >
1286+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
1287+
do sleep 2;
1288+
done
1289+
- name: wait-for-queue
1290+
image: busybox:1.28
1291+
command:
1292+
- 'sh'
1293+
- '-c'
1294+
- >
1295+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
1296+
do sleep 2;
1297+
done
1298+
{{- if .Values.st2.packs.image.repository }}
11131299
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
11141300
# Custom packs
11151301
- name: st2-custom-packs
@@ -1259,6 +1445,25 @@ spec:
12591445
{{- if .Values.image.pullSecret }}
12601446
- name: {{ .Values.image.pullSecret }}
12611447
{{- end }}
1448+
initContainers:
1449+
- name: wait-for-db
1450+
image: busybox:1.28
1451+
command:
1452+
- 'sh'
1453+
- '-c'
1454+
- >
1455+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
1456+
do sleep 2;
1457+
done
1458+
- name: wait-for-queue
1459+
image: busybox:1.28
1460+
command:
1461+
- 'sh'
1462+
- '-c'
1463+
- >
1464+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
1465+
do sleep 2;
1466+
done
12621467
containers:
12631468
- name: st2garbagecollector{{ template "enterpriseSuffix" . }}
12641469
image: "{{ template "imageRepository" . }}/st2garbagecollector{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -1349,6 +1554,24 @@ spec:
13491554
- name: {{ .Values.image.pullSecret }}
13501555
{{- end }}
13511556
initContainers:
1557+
- name: wait-for-db
1558+
image: busybox:1.28
1559+
command:
1560+
- 'sh'
1561+
- '-c'
1562+
- >
1563+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
1564+
do sleep 2;
1565+
done
1566+
- name: wait-for-queue
1567+
image: busybox:1.28
1568+
command:
1569+
- 'sh'
1570+
- '-c'
1571+
- >
1572+
until nc -z -w 2 {{ .Release.Name }}-rabbitmq 5672 && echo rabbitmq ok;
1573+
do sleep 2;
1574+
done
13521575
{{- if .Values.st2.packs.image.repository }}
13531576
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
13541577
# Custom packs

templates/jobs.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,24 @@ spec:
121121
- name: {{ .Values.image.pullSecret }}
122122
{{- end }}
123123
initContainers:
124+
- name: wait-for-db
125+
image: busybox:1.28
126+
command:
127+
- 'sh'
128+
- '-c'
129+
- >
130+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
131+
do sleep 2;
132+
done
133+
- name: wait-for-api
134+
image: busybox:1.28
135+
command:
136+
- 'sh'
137+
- '-c'
138+
- >
139+
until nc -z -w 2 {{ .Release.Name }}-st2api 9101 && echo st2api ready;
140+
do sleep 2;
141+
done
124142
# Sidecar container for generating st2client config with st2 username & password pair and sharing produced file with the main container
125143
- name: generate-st2client-config
126144
image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -223,6 +241,15 @@ spec:
223241
- name: {{ .Values.image.pullSecret }}
224242
{{- end }}
225243
initContainers:
244+
- name: wait-for-db
245+
image: busybox:1.28
246+
command:
247+
- 'sh'
248+
- '-c'
249+
- >
250+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
251+
do sleep 2;
252+
done
226253
# Sidecar container for generating st2client config with st2 username & password pair and sharing produced file with the main container
227254
- name: generate-st2client-config
228255
image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -338,6 +365,15 @@ spec:
338365
{{- end }}
339366
{{- if .Values.st2.packs.image.repository }}
340367
initContainers:
368+
- name: wait-for-db
369+
image: busybox:1.28
370+
command:
371+
- 'sh'
372+
- '-c'
373+
- >
374+
until nc -z -w 2 {{ .Release.Name }}-mongodb-headless 27017 && echo mongodb ok;
375+
do sleep 2;
376+
done
341377
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
342378
# Custom packs
343379
- name: st2-custom-packs

0 commit comments

Comments
 (0)