Skip to content

Commit 4752d82

Browse files
committed
Defined template for resuability and made recommended changes
1 parent 0cbb05c commit 4752d82

File tree

5 files changed

+63
-245
lines changed

5 files changed

+63
-245
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v0.52.0
4+
* Implemented initContainers to wait for DB/MQ to be available for St2 Pods (#178)
5+
36
## In Development
47
* Add option to define config.js for st2web (#165) (by @moonrail)
58

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
# StackStorm version which refers to Docker images tag
33
appVersion: 3.4dev
44
name: stackstorm-ha
5-
version: 0.51.0
5+
version: 0.52.0
66
description: StackStorm K8s Helm Chart, optimized for running StackStorm in HA environment.
77
home: https://stackstorm.com/
88
icon: https://landscape.cncf.io/logos/stack-storm.svg

templates/_helpers.tpl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,36 @@ Create the name of the stackstorm-ha service account to use
9494
{{- end -}}
9595
{{- end -}}
9696

97+
{{- define "init-containers-wait-for-db" -}}
98+
{{- if index .Values "mongodb" "enabled" }}
99+
{{- $mongodb_port := (int (index .Values "mongodb" "service" "port")) }}
100+
- name: wait-for-db
101+
image: busybox:1.28
102+
command:
103+
- 'sh'
104+
- '-c'
105+
- >
106+
until nc -z -w 2 {{ $.Release.Name }}-mongodb-headless {{ $mongodb_port }} && echo mongodb ok;
107+
do
108+
echo 'Waiting for MongoDB Connection...'
109+
sleep 2;
110+
done
111+
{{- end }}
112+
{{- end -}}
113+
114+
{{- define "init-containers-wait-for-mq" -}}
115+
{{- if index .Values "rabbitmq" "enabled" }}
116+
{{- $rabbitmq_port := (int (index .Values "rabbitmq" "service" "port")) }}
117+
- name: wait-for-queue
118+
image: busybox:1.28
119+
command:
120+
- 'sh'
121+
- '-c'
122+
- >
123+
until nc -z -w 2 {{ $.Release.Name }}-rabbitmq {{ $rabbitmq_port }} && echo rabbitmq ok;
124+
do
125+
echo 'Waiting for RabbitMQ Connection...'
126+
sleep 2;
127+
done
128+
{{- end }}
129+
{{- end -}}

templates/deployments.yaml

Lines changed: 23 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,10 @@ spec:
4141
{{- if .Values.image.pullSecret }}
4242
- name: {{ .Values.image.pullSecret }}
4343
{{- end }}
44-
# Sidecar container for generating .htpasswd with st2 username & password pair and sharing produced file with the main st2auth container
4544
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
45+
{{ include "init-containers-wait-for-db" . | indent 6 }}
46+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
47+
# Sidecar container for generating .htpasswd with st2 username & password pair and sharing produced file with the main st2auth container
6448
- name: generate-htpasswd
6549
image: "{{ template "imageRepository" . }}/st2auth{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
6650
imagePullPolicy: {{ .Values.image.pullPolicy }}
@@ -177,24 +161,8 @@ spec:
177161
- name: {{ .Values.image.pullSecret }}
178162
{{- end }}
179163
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
164+
{{ include "init-containers-wait-for-db" . | indent 6 }}
165+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
198166
{{- if .Values.st2.packs.image.repository }}
199167
# Merge packs and virtualenvs from st2api with those from the st2.packs image
200168
# Custom packs
@@ -339,24 +307,8 @@ spec:
339307
- name: {{ .Values.image.pullSecret }}
340308
{{- end }}
341309
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
310+
{{ include "init-containers-wait-for-db" . | indent 6 }}
311+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
360312
containers:
361313
- name: st2stream{{ template "enterpriseSuffix" . }}
362314
image: "{{ template "imageRepository" . }}/st2stream{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -543,24 +495,8 @@ spec:
543495
- name: {{ .Values.image.pullSecret }}
544496
{{- end }}
545497
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
498+
{{ include "init-containers-wait-for-db" . | indent 6 }}
499+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
564500
containers:
565501
- name: st2rulesengine{{ template "enterpriseSuffix" . }}
566502
image: "{{ template "imageRepository" . }}/st2rulesengine{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -652,24 +588,8 @@ spec:
652588
- name: {{ .Values.image.pullSecret }}
653589
{{- end }}
654590
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
591+
{{ include "init-containers-wait-for-db" . | indent 6 }}
592+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
673593
containers:
674594
- name: st2timersengine{{ template "enterpriseSuffix" . }}
675595
image: "{{ template "imageRepository" . }}/st2timersengine{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -753,24 +673,8 @@ spec:
753673
- name: {{ .Values.image.pullSecret }}
754674
{{- end }}
755675
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
676+
{{ include "init-containers-wait-for-db" . | indent 6 }}
677+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
774678
containers:
775679
- name: st2workflowengine{{ template "enterpriseSuffix" . }}
776680
image: "{{ template "imageRepository" . }}/st2workflowengine{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -866,24 +770,8 @@ spec:
866770
- name: {{ .Values.image.pullSecret }}
867771
{{- end }}
868772
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
773+
{{ include "init-containers-wait-for-db" . | indent 6 }}
774+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
887775
containers:
888776
- name: st2scheduler{{ template "enterpriseSuffix" . }}
889777
image: "{{ template "imageRepository" . }}/st2scheduler{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -979,24 +867,8 @@ spec:
979867
- name: {{ .Values.image.pullSecret }}
980868
{{- end }}
981869
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
870+
{{ include "init-containers-wait-for-db" . | indent 6 }}
871+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
1000872
containers:
1001873
- name: st2notifier{{ template "enterpriseSuffix" . }}
1002874
image: "{{ template "imageRepository" . }}/st2notifier{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -1090,24 +962,8 @@ spec:
1090962
- name: {{ $.Values.image.pullSecret }}
1091963
{{- end }}
1092964
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
965+
{{ include "init-containers-wait-for-db" $ | indent 6 }}
966+
{{ include "init-containers-wait-for-mq" $ | indent 6 }}
1111967
{{- if $.Values.st2.packs.image.repository }}
1112968
# Merge packs and virtualenvs from st2sensorcontainer with those from the st2.packs image
1113969
# Custom packs
@@ -1277,24 +1133,8 @@ spec:
12771133
- name: {{ .Values.image.pullSecret }}
12781134
{{- end }}
12791135
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
1136+
{{ include "init-containers-wait-for-db" . | indent 6 }}
1137+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
12981138
{{- if .Values.st2.packs.image.repository }}
12991139
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
13001140
# Custom packs
@@ -1446,24 +1286,8 @@ spec:
14461286
- name: {{ .Values.image.pullSecret }}
14471287
{{- end }}
14481288
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
1289+
{{ include "init-containers-wait-for-db" . | indent 6 }}
1290+
{{ include "init-containers-wait-for-mq" . | indent 6 }}
14671291
containers:
14681292
- name: st2garbagecollector{{ template "enterpriseSuffix" . }}
14691293
image: "{{ template "imageRepository" . }}/st2garbagecollector{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
@@ -1554,24 +1378,6 @@ spec:
15541378
- name: {{ .Values.image.pullSecret }}
15551379
{{- end }}
15561380
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
15751381
{{- if .Values.st2.packs.image.repository }}
15761382
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
15771383
# Custom packs

0 commit comments

Comments
 (0)