Skip to content

Commit e0dbba5

Browse files
author
hanancha
committed
Merge branch 'master' of github.com:StackStorm/stackstorm-ha
2 parents 1d9c1cb + 049ec74 commit e0dbba5

File tree

6 files changed

+117
-212
lines changed

6 files changed

+117
-212
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

33
## In Development
4-
4+
* Change st2packs definition to a list, to support multiple st2packs containers (#166) (by @moonrail)
55

66
## v0.52.0
77
* Improve resource allocation and scheduling by adding resources requests cpu/memory values for st2 Pods (#179)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ See [K8s documentation](https://kubernetes.io/docs/tasks/configure-pod-container
212212
# Create a Docker registry secret called 'st2packs-auth'
213213
kubectl create secret docker-registry st2packs-auth --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-password>
214214
```
215-
Once secret created, reference its name in helm value: `st2.packs.image.pullSecret`.
215+
Once secret created, reference its name in helm value: `st2.packs.images[].pullSecret`.
216216

217217

218218
## Tips & Tricks

templates/_helpers.tpl

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ Create the name of the stackstorm-ha service account to use
8989
{{- end -}}
9090

9191
{{- define "init-containers-wait-for-mq" -}}
92-
{{- if index .Values "rabbitmq" "enabled" }}
93-
{{- $rabbitmq_port := (int (index .Values "rabbitmq" "service" "port")) }}
92+
{{- if index .Values "rabbitmq" "enabled" }}
93+
{{- $rabbitmq_port := (int (index .Values "rabbitmq" "service" "port")) }}
9494
- name: wait-for-queue
9595
image: busybox:1.28
9696
command:
@@ -102,5 +102,63 @@ Create the name of the stackstorm-ha service account to use
102102
echo 'Waiting for RabbitMQ Connection...'
103103
sleep 2;
104104
done
105-
{{- end }}
105+
{{- end }}
106+
{{- end -}}
107+
108+
# For custom st2packs-Container reduce duplicity by defining it here once
109+
{{- define "packs-volumes" -}}
110+
{{- if .Values.st2.packs.images }}
111+
- name: st2-packs-vol
112+
emptyDir: {}
113+
- name: st2-virtualenvs-vol
114+
emptyDir: {}
115+
{{- end }}
116+
{{- end -}}
117+
118+
# For custom st2packs-initContainers reduce duplicity by defining them here once
119+
# Merge packs and virtualenvs from st2 with those from st2packs images
120+
{{- define "packs-initContainers" -}}
121+
{{- if $.Values.st2.packs.images }}
122+
{{- range $.Values.st2.packs.images }}
123+
- name: 'st2-custom-pack-{{ printf "%s-%s-%s" .repository .name .tag | sha1sum }}'
124+
image: "{{ .repository }}/{{ .name }}:{{ .tag }}"
125+
imagePullPolicy: {{ .pullPolicy | quote }}
126+
volumeMounts:
127+
- name: st2-packs-vol
128+
mountPath: /opt/stackstorm/packs-shared
129+
- name: st2-virtualenvs-vol
130+
mountPath: /opt/stackstorm/virtualenvs-shared
131+
command:
132+
- 'sh'
133+
- '-ec'
134+
- |
135+
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
136+
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
137+
{{- end }}
138+
# System packs
139+
- name: st2-system-packs
140+
image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
141+
imagePullPolicy: {{ .Values.image.pullPolicy }}
142+
volumeMounts:
143+
- name: st2-packs-vol
144+
mountPath: /opt/stackstorm/packs-shared
145+
- name: st2-virtualenvs-vol
146+
mountPath: /opt/stackstorm/virtualenvs-shared
147+
command:
148+
- 'sh'
149+
- '-ec'
150+
- |
151+
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
152+
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
153+
{{- end }}
154+
{{- end -}}
155+
156+
157+
# For custom st2packs-pullSecrets reduce duplicity by defining them here once
158+
{{- define "packs-pullSecrets" -}}
159+
{{- range $.Values.st2.packs.images }}
160+
{{- if .pullSecret }}
161+
- name: {{ .pullSecret }}
162+
{{- end }}
163+
{{- end }}
106164
{{- end -}}

templates/deployments.yaml

Lines changed: 36 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Notify users about breaking change regarding packs, to not destroy current installations
2+
{{- if and .Values.st2.packs.image }}
3+
{{- fail "Value st2.packs.image was renamed to st2.packs.images and is now a list of images" }}
4+
{{- end }}
5+
16
---
27
apiVersion: apps/v1
38
kind: Deployment
@@ -142,47 +147,17 @@ spec:
142147
checksum/datastore-key: {{ include (print $.Template.BasePath "/secrets_datastore_crypto_key.yaml") . | sha256sum }}
143148
spec:
144149
imagePullSecrets:
145-
{{- if .Values.st2.packs.image.pullSecret }}
146-
- name: {{ .Values.st2.packs.image.pullSecret }}
147-
{{- end }}
148150
{{- if .Values.image.pullSecret }}
149151
- name: {{ .Values.image.pullSecret }}
152+
{{- end }}
153+
{{- if .Values.st2.packs.images }}
154+
{{- include "packs-pullSecrets" . | indent 6 }}
150155
{{- end }}
151156
initContainers:
152157
{{ include "init-containers-wait-for-db" . | indent 6 }}
153158
{{ include "init-containers-wait-for-mq" . | indent 6 }}
154-
{{- if .Values.st2.packs.image.repository }}
155-
# Merge packs and virtualenvs from st2api with those from the st2.packs image
156-
# Custom packs
157-
- name: st2-custom-packs
158-
image: "{{ .Values.st2.packs.image.repository }}/{{ .Values.st2.packs.image.name }}:{{ .Values.st2.packs.image.tag }}"
159-
imagePullPolicy: {{ .Values.st2.packs.image.pullPolicy | quote }}
160-
volumeMounts:
161-
- name: st2-packs-vol
162-
mountPath: /opt/stackstorm/packs-shared
163-
- name: st2-virtualenvs-vol
164-
mountPath: /opt/stackstorm/virtualenvs-shared
165-
command:
166-
- 'sh'
167-
- '-ec'
168-
- |
169-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
170-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
171-
# System packs
172-
- name: st2-system-packs
173-
image: "{{ template "imageRepository" . }}/st2actionrunner:{{ .Chart.AppVersion }}"
174-
imagePullPolicy: {{ .Values.image.pullPolicy }}
175-
volumeMounts:
176-
- name: st2-packs-vol
177-
mountPath: /opt/stackstorm/packs-shared
178-
- name: st2-virtualenvs-vol
179-
mountPath: /opt/stackstorm/virtualenvs-shared
180-
command:
181-
- 'sh'
182-
- '-ec'
183-
- |
184-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
185-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
159+
{{- if .Values.st2.packs.images }}
160+
{{- include "packs-initContainers" . | indent 6 }}
186161
{{- end }}
187162
containers:
188163
- name: st2api
@@ -208,7 +183,7 @@ spec:
208183
mountPath: /etc/st2/keys
209184
readOnly: true
210185
{{- end }}
211-
{{- if .Values.st2.packs.image.repository }}
186+
{{- if .Values.st2.packs.images }}
212187
- name: st2-packs-vol
213188
mountPath: /opt/stackstorm/packs
214189
readOnly: true
@@ -233,11 +208,8 @@ spec:
233208
- name: st2-config-vol
234209
configMap:
235210
name: {{ .Release.Name }}-st2-config
236-
{{- if .Values.st2.packs.image.repository }}
237-
- name: st2-packs-vol
238-
emptyDir: {}
239-
- name: st2-virtualenvs-vol
240-
emptyDir: {}
211+
{{- if .Values.st2.packs.images }}
212+
{{- include "packs-volumes" . | indent 8 }}
241213
{{- end }}
242214
{{- with .Values.st2api.nodeSelector }}
243215
nodeSelector:
@@ -895,45 +867,17 @@ spec:
895867
{{- end }}
896868
spec:
897869
imagePullSecrets:
898-
{{- if $.Values.st2.packs.image.pullSecret }}
899-
- name: {{ $.Values.st2.packs.image.pullSecret }}
900-
{{- end }}
901870
{{- if $.Values.image.pullSecret }}
902871
- name: {{ $.Values.image.pullSecret }}
872+
{{- end }}
873+
{{- if $.Values.st2.packs.images }}
874+
{{- include "packs-pullSecrets" $ | indent 6 }}
903875
{{- end }}
904876
initContainers:
905877
{{ include "init-containers-wait-for-db" $ | indent 6 }}
906878
{{ include "init-containers-wait-for-mq" $ | indent 6 }}
907-
{{- if $.Values.st2.packs.image.repository }}
908-
# Merge packs and virtualenvs from st2sensorcontainer with those from the st2.packs image
909-
# Custom packs
910-
- name: st2-custom-packs
911-
image: "{{ $.Values.st2.packs.image.repository }}/{{ $.Values.st2.packs.image.name }}:{{ $.Values.st2.packs.image.tag }}"
912-
imagePullPolicy: {{ $.Values.st2.packs.image.pullPolicy | quote }}
913-
volumeMounts:
914-
- name: st2-packs-vol
915-
mountPath: /opt/stackstorm/packs-shared
916-
- name: st2-virtualenvs-vol
917-
mountPath: /opt/stackstorm/virtualenvs-shared
918-
command:
919-
- 'sh'
920-
- '-ec'
921-
- |
922-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
923-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
924-
# System packs
925-
- name: st2-system-packs
926-
image: "{{ template "imageRepository" $ }}/st2actionrunner:{{ $.Chart.AppVersion }}"
927-
imagePullPolicy: {{ $.Values.image.pullPolicy }}
928-
volumeMounts:
929-
- name: st2-packs-vol
930-
mountPath: /opt/stackstorm/packs-shared
931-
command:
932-
- 'sh'
933-
- '-ec'
934-
- |
935-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
936-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
879+
{{- if $.Values.st2.packs.images }}
880+
{{- include "packs-initContainers" $ | indent 6 }}
937881
{{- end }}
938882
containers:
939883
- name: st2sensorcontainer{{ template "hyphenPrefix" .name }}
@@ -967,7 +911,7 @@ spec:
967911
- name: st2-config-vol
968912
mountPath: /etc/st2/st2.user.conf
969913
subPath: st2.user.conf
970-
{{- if $.Values.st2.packs.image.repository }}
914+
{{- if $.Values.st2.packs.images }}
971915
- name: st2-packs-vol
972916
mountPath: /opt/stackstorm/packs
973917
readOnly: true
@@ -997,11 +941,8 @@ spec:
997941
- name: st2-config-vol
998942
configMap:
999943
name: {{ $.Release.Name }}-st2-config
1000-
{{- if $.Values.st2.packs.image.repository }}
1001-
- name: st2-packs-vol
1002-
emptyDir: {}
1003-
- name: st2-virtualenvs-vol
1004-
emptyDir: {}
944+
{{- if $.Values.st2.packs.images }}
945+
{{- include "packs-volumes" $ | indent 8 }}
1005946
{{- end }}
1006947
{{- with .nodeSelector }}
1007948
nodeSelector:
@@ -1060,45 +1001,17 @@ spec:
10601001
{{ toYaml .Values.st2actionrunner.hostAliases | indent 8 }}
10611002
{{- end }}
10621003
imagePullSecrets:
1063-
{{- if .Values.st2.packs.image.pullSecret }}
1064-
- name: {{ .Values.st2.packs.image.pullSecret }}
1065-
{{- end }}
10661004
{{- if .Values.image.pullSecret }}
10671005
- name: {{ .Values.image.pullSecret }}
1006+
{{- end }}
1007+
{{- if .Values.st2.packs.images }}
1008+
{{- include "packs-pullSecrets" . | indent 6 }}
10681009
{{- end }}
10691010
initContainers:
10701011
{{ include "init-containers-wait-for-db" . | indent 6 }}
10711012
{{ include "init-containers-wait-for-mq" . | indent 6 }}
1072-
{{- if .Values.st2.packs.image.repository }}
1073-
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
1074-
# Custom packs
1075-
- name: st2-custom-packs
1076-
image: "{{ .Values.st2.packs.image.repository }}/{{ .Values.st2.packs.image.name }}:{{ .Values.st2.packs.image.tag }}"
1077-
imagePullPolicy: {{ .Values.st2.packs.image.pullPolicy | quote }}
1078-
volumeMounts:
1079-
- name: st2-packs-vol
1080-
mountPath: /opt/stackstorm/packs-shared
1081-
- name: st2-virtualenvs-vol
1082-
mountPath: /opt/stackstorm/virtualenvs-shared
1083-
command:
1084-
- 'sh'
1085-
- '-ec'
1086-
- |
1087-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1088-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1089-
# System packs
1090-
- name: st2-system-packs
1091-
image: "{{ template "imageRepository" . }}/st2actionrunner:{{ .Chart.AppVersion }}"
1092-
imagePullPolicy: {{ .Values.image.pullPolicy }}
1093-
volumeMounts:
1094-
- name: st2-packs-vol
1095-
mountPath: /opt/stackstorm/packs-shared
1096-
command:
1097-
- 'sh'
1098-
- '-ec'
1099-
- |
1100-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1101-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1013+
{{- if .Values.st2.packs.images }}
1014+
{{- include "packs-initContainers" . | indent 6 }}
11021015
{{- end }}
11031016
containers:
11041017
- name: st2actionrunner
@@ -1125,7 +1038,7 @@ spec:
11251038
mountPath: /etc/st2/keys
11261039
readOnly: true
11271040
{{- end }}
1128-
{{- if .Values.st2.packs.image.repository }}
1041+
{{- if .Values.st2.packs.images }}
11291042
- name: st2-packs-vol
11301043
mountPath: /opt/stackstorm/packs
11311044
readOnly: true
@@ -1158,11 +1071,8 @@ spec:
11581071
path: stanley_rsa
11591072
# 0400 file permission
11601073
mode: 256
1161-
{{- if .Values.st2.packs.image.repository }}
1162-
- name: st2-packs-vol
1163-
emptyDir: {}
1164-
- name: st2-virtualenvs-vol
1165-
emptyDir: {}
1074+
{{- if .Values.st2.packs.images }}
1075+
{{- include "packs-volumes" . | indent 8 }}
11661076
{{- end }}
11671077
{{- with .Values.st2actionrunner.nodeSelector }}
11681078
nodeSelector:
@@ -1291,43 +1201,15 @@ spec:
12911201
checksum/datastore-key: {{ include (print $.Template.BasePath "/secrets_datastore_crypto_key.yaml") . | sha256sum }}
12921202
spec:
12931203
imagePullSecrets:
1294-
{{- if .Values.st2.packs.image.pullSecret }}
1295-
- name: {{ .Values.st2.packs.image.pullSecret }}
1204+
{{- if .Values.st2.packs.images }}
1205+
{{- include "packs-pullSecrets" . | indent 6 }}
12961206
{{- end }}
12971207
{{- if .Values.image.pullSecret }}
12981208
- name: {{ .Values.image.pullSecret }}
12991209
{{- end }}
13001210
initContainers:
1301-
{{- if .Values.st2.packs.image.repository }}
1302-
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
1303-
# Custom packs
1304-
- name: st2-custom-packs
1305-
image: "{{ .Values.st2.packs.image.repository }}/{{ .Values.st2.packs.image.name }}:{{ .Values.st2.packs.image.tag }}"
1306-
imagePullPolicy: {{ .Values.st2.packs.image.pullPolicy | quote }}
1307-
volumeMounts:
1308-
- name: st2-packs-vol
1309-
mountPath: /opt/stackstorm/packs-shared
1310-
- name: st2-virtualenvs-vol
1311-
mountPath: /opt/stackstorm/virtualenvs-shared
1312-
command:
1313-
- 'sh'
1314-
- '-ec'
1315-
- |
1316-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1317-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1318-
# System packs
1319-
- name: st2-system-packs
1320-
image: "{{ template "imageRepository" . }}/st2actionrunner:{{ .Chart.AppVersion }}"
1321-
imagePullPolicy: {{ .Values.image.pullPolicy }}
1322-
volumeMounts:
1323-
- name: st2-packs-vol
1324-
mountPath: /opt/stackstorm/packs-shared
1325-
command:
1326-
- 'sh'
1327-
- '-ec'
1328-
- |
1329-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1330-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1211+
{{- if .Values.st2.packs.images }}
1212+
{{- include "packs-initContainers" . | indent 6 }}
13311213
{{- end }}
13321214
# Sidecar container for generating st2client config with st2 username & password pair and sharing produced file with the main container
13331215
- name: generate-st2client-config
@@ -1397,7 +1279,7 @@ spec:
13971279
mountPath: /etc/st2/keys
13981280
readOnly: true
13991281
{{- end }}
1400-
{{- if .Values.st2.packs.image.repository }}
1282+
{{- if .Values.st2.packs.images }}
14011283
- name: st2-packs-vol
14021284
mountPath: /opt/stackstorm/packs
14031285
readOnly: true
@@ -1450,11 +1332,8 @@ spec:
14501332
path: stanley_rsa
14511333
# 0400 file permission
14521334
mode: 256
1453-
{{- if .Values.st2.packs.image.repository }}
1454-
- name: st2-packs-vol
1455-
emptyDir: {}
1456-
- name: st2-virtualenvs-vol
1457-
emptyDir: {}
1335+
{{- if .Values.st2.packs.images }}
1336+
{{- include "packs-volumes" . | indent 8 }}
14581337
{{- end }}
14591338

14601339
{{ if .Values.st2chatops.enabled -}}

0 commit comments

Comments
 (0)