Skip to content

Commit 049ec74

Browse files
authored
Merge pull request #166 from plusserver/allow_multiple_pack_images
Allow multiple packs images
2 parents 3d14e55 + 0b17588 commit 049ec74

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
@@ -112,8 +112,8 @@ Create the name of the stackstorm-ha service account to use
112112
{{- end -}}
113113

114114
{{- define "init-containers-wait-for-mq" -}}
115-
{{- if index .Values "rabbitmq" "enabled" }}
116-
{{- $rabbitmq_port := (int (index .Values "rabbitmq" "service" "port")) }}
115+
{{- if index .Values "rabbitmq" "enabled" }}
116+
{{- $rabbitmq_port := (int (index .Values "rabbitmq" "service" "port")) }}
117117
- name: wait-for-queue
118118
image: busybox:1.28
119119
command:
@@ -125,5 +125,63 @@ Create the name of the stackstorm-ha service account to use
125125
echo 'Waiting for RabbitMQ Connection...'
126126
sleep 2;
127127
done
128-
{{- end }}
128+
{{- end }}
129+
{{- end -}}
130+
131+
# For custom st2packs-Container reduce duplicity by defining it here once
132+
{{- define "packs-volumes" -}}
133+
{{- if .Values.st2.packs.images }}
134+
- name: st2-packs-vol
135+
emptyDir: {}
136+
- name: st2-virtualenvs-vol
137+
emptyDir: {}
138+
{{- end }}
139+
{{- end -}}
140+
141+
# For custom st2packs-initContainers reduce duplicity by defining them here once
142+
# Merge packs and virtualenvs from st2 with those from st2packs images
143+
{{- define "packs-initContainers" -}}
144+
{{- if $.Values.st2.packs.images }}
145+
{{- range $.Values.st2.packs.images }}
146+
- name: 'st2-custom-pack-{{ printf "%s-%s-%s" .repository .name .tag | sha1sum }}'
147+
image: "{{ .repository }}/{{ .name }}:{{ .tag }}"
148+
imagePullPolicy: {{ .pullPolicy | quote }}
149+
volumeMounts:
150+
- name: st2-packs-vol
151+
mountPath: /opt/stackstorm/packs-shared
152+
- name: st2-virtualenvs-vol
153+
mountPath: /opt/stackstorm/virtualenvs-shared
154+
command:
155+
- 'sh'
156+
- '-ec'
157+
- |
158+
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
159+
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
160+
{{- end }}
161+
# System packs
162+
- name: st2-system-packs
163+
image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
164+
imagePullPolicy: {{ .Values.image.pullPolicy }}
165+
volumeMounts:
166+
- name: st2-packs-vol
167+
mountPath: /opt/stackstorm/packs-shared
168+
- name: st2-virtualenvs-vol
169+
mountPath: /opt/stackstorm/virtualenvs-shared
170+
command:
171+
- 'sh'
172+
- '-ec'
173+
- |
174+
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
175+
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
176+
{{- end }}
177+
{{- end -}}
178+
179+
180+
# For custom st2packs-pullSecrets reduce duplicity by defining them here once
181+
{{- define "packs-pullSecrets" -}}
182+
{{- range $.Values.st2.packs.images }}
183+
{{- if .pullSecret }}
184+
- name: {{ .pullSecret }}
185+
{{- end }}
186+
{{- end }}
129187
{{- 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
@@ -154,47 +159,17 @@ spec:
154159
{{- if .Values.enterprise.enabled }}
155160
- name: {{ .Release.Name }}-st2-license
156161
{{- end }}
157-
{{- if .Values.st2.packs.image.pullSecret }}
158-
- name: {{ .Values.st2.packs.image.pullSecret }}
159-
{{- end }}
160162
{{- if .Values.image.pullSecret }}
161163
- name: {{ .Values.image.pullSecret }}
164+
{{- end }}
165+
{{- if .Values.st2.packs.images }}
166+
{{- include "packs-pullSecrets" . | indent 6 }}
162167
{{- end }}
163168
initContainers:
164169
{{ include "init-containers-wait-for-db" . | indent 6 }}
165170
{{ include "init-containers-wait-for-mq" . | indent 6 }}
166-
{{- if .Values.st2.packs.image.repository }}
167-
# Merge packs and virtualenvs from st2api with those from the st2.packs image
168-
# Custom packs
169-
- name: st2-custom-packs
170-
image: "{{ .Values.st2.packs.image.repository }}/{{ .Values.st2.packs.image.name }}:{{ .Values.st2.packs.image.tag }}"
171-
imagePullPolicy: {{ .Values.st2.packs.image.pullPolicy | quote }}
172-
volumeMounts:
173-
- name: st2-packs-vol
174-
mountPath: /opt/stackstorm/packs-shared
175-
- name: st2-virtualenvs-vol
176-
mountPath: /opt/stackstorm/virtualenvs-shared
177-
command:
178-
- 'sh'
179-
- '-ec'
180-
- |
181-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
182-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
183-
# System packs
184-
- name: st2-system-packs
185-
image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
186-
imagePullPolicy: {{ .Values.image.pullPolicy }}
187-
volumeMounts:
188-
- name: st2-packs-vol
189-
mountPath: /opt/stackstorm/packs-shared
190-
- name: st2-virtualenvs-vol
191-
mountPath: /opt/stackstorm/virtualenvs-shared
192-
command:
193-
- 'sh'
194-
- '-ec'
195-
- |
196-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
197-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
171+
{{- if .Values.st2.packs.images }}
172+
{{- include "packs-initContainers" . | indent 6 }}
198173
{{- end }}
199174
containers:
200175
- name: st2api{{ template "enterpriseSuffix" . }}
@@ -220,7 +195,7 @@ spec:
220195
mountPath: /etc/st2/keys
221196
readOnly: true
222197
{{- end }}
223-
{{- if .Values.st2.packs.image.repository }}
198+
{{- if .Values.st2.packs.images }}
224199
- name: st2-packs-vol
225200
mountPath: /opt/stackstorm/packs
226201
readOnly: true
@@ -245,11 +220,8 @@ spec:
245220
- name: st2-config-vol
246221
configMap:
247222
name: {{ .Release.Name }}-st2-config
248-
{{- if .Values.st2.packs.image.repository }}
249-
- name: st2-packs-vol
250-
emptyDir: {}
251-
- name: st2-virtualenvs-vol
252-
emptyDir: {}
223+
{{- if .Values.st2.packs.images }}
224+
{{- include "packs-volumes" . | indent 8 }}
253225
{{- end }}
254226
{{- with .Values.st2api.nodeSelector }}
255227
nodeSelector:
@@ -955,45 +927,17 @@ spec:
955927
{{- if $.Values.enterprise.enabled }}
956928
- name: {{ $.Release.Name }}-st2-license
957929
{{- end }}
958-
{{- if $.Values.st2.packs.image.pullSecret }}
959-
- name: {{ $.Values.st2.packs.image.pullSecret }}
960-
{{- end }}
961930
{{- if $.Values.image.pullSecret }}
962931
- name: {{ $.Values.image.pullSecret }}
932+
{{- end }}
933+
{{- if $.Values.st2.packs.images }}
934+
{{- include "packs-pullSecrets" $ | indent 6 }}
963935
{{- end }}
964936
initContainers:
965937
{{ include "init-containers-wait-for-db" $ | indent 6 }}
966938
{{ include "init-containers-wait-for-mq" $ | indent 6 }}
967-
{{- if $.Values.st2.packs.image.repository }}
968-
# Merge packs and virtualenvs from st2sensorcontainer with those from the st2.packs image
969-
# Custom packs
970-
- name: st2-custom-packs
971-
image: "{{ $.Values.st2.packs.image.repository }}/{{ $.Values.st2.packs.image.name }}:{{ $.Values.st2.packs.image.tag }}"
972-
imagePullPolicy: {{ $.Values.st2.packs.image.pullPolicy | quote }}
973-
volumeMounts:
974-
- name: st2-packs-vol
975-
mountPath: /opt/stackstorm/packs-shared
976-
- name: st2-virtualenvs-vol
977-
mountPath: /opt/stackstorm/virtualenvs-shared
978-
command:
979-
- 'sh'
980-
- '-ec'
981-
- |
982-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
983-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
984-
# System packs
985-
- name: st2-system-packs
986-
image: "{{ template "imageRepository" $ }}/st2actionrunner{{ template "enterpriseSuffix" $ }}:{{ $.Chart.AppVersion }}"
987-
imagePullPolicy: {{ $.Values.image.pullPolicy }}
988-
volumeMounts:
989-
- name: st2-packs-vol
990-
mountPath: /opt/stackstorm/packs-shared
991-
command:
992-
- 'sh'
993-
- '-ec'
994-
- |
995-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
996-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
939+
{{- if $.Values.st2.packs.images }}
940+
{{- include "packs-initContainers" $ | indent 6 }}
997941
{{- end }}
998942
containers:
999943
- name: st2sensorcontainer{{ template "hyphenPrefix" .name }}{{ template "enterpriseSuffix" $ }}
@@ -1027,7 +971,7 @@ spec:
1027971
- name: st2-config-vol
1028972
mountPath: /etc/st2/st2.user.conf
1029973
subPath: st2.user.conf
1030-
{{- if $.Values.st2.packs.image.repository }}
974+
{{- if $.Values.st2.packs.images }}
1031975
- name: st2-packs-vol
1032976
mountPath: /opt/stackstorm/packs
1033977
readOnly: true
@@ -1057,11 +1001,8 @@ spec:
10571001
- name: st2-config-vol
10581002
configMap:
10591003
name: {{ $.Release.Name }}-st2-config
1060-
{{- if $.Values.st2.packs.image.repository }}
1061-
- name: st2-packs-vol
1062-
emptyDir: {}
1063-
- name: st2-virtualenvs-vol
1064-
emptyDir: {}
1004+
{{- if $.Values.st2.packs.images }}
1005+
{{- include "packs-volumes" $ | indent 8 }}
10651006
{{- end }}
10661007
{{- with .nodeSelector }}
10671008
nodeSelector:
@@ -1126,45 +1067,17 @@ spec:
11261067
{{- if .Values.enterprise.enabled }}
11271068
- name: {{ .Release.Name }}-st2-license
11281069
{{- end }}
1129-
{{- if .Values.st2.packs.image.pullSecret }}
1130-
- name: {{ .Values.st2.packs.image.pullSecret }}
1131-
{{- end }}
11321070
{{- if .Values.image.pullSecret }}
11331071
- name: {{ .Values.image.pullSecret }}
1072+
{{- end }}
1073+
{{- if .Values.st2.packs.images }}
1074+
{{- include "packs-pullSecrets" . | indent 6 }}
11341075
{{- end }}
11351076
initContainers:
11361077
{{ include "init-containers-wait-for-db" . | indent 6 }}
11371078
{{ include "init-containers-wait-for-mq" . | indent 6 }}
1138-
{{- if .Values.st2.packs.image.repository }}
1139-
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
1140-
# Custom packs
1141-
- name: st2-custom-packs
1142-
image: "{{ .Values.st2.packs.image.repository }}/{{ .Values.st2.packs.image.name }}:{{ .Values.st2.packs.image.tag }}"
1143-
imagePullPolicy: {{ .Values.st2.packs.image.pullPolicy | quote }}
1144-
volumeMounts:
1145-
- name: st2-packs-vol
1146-
mountPath: /opt/stackstorm/packs-shared
1147-
- name: st2-virtualenvs-vol
1148-
mountPath: /opt/stackstorm/virtualenvs-shared
1149-
command:
1150-
- 'sh'
1151-
- '-ec'
1152-
- |
1153-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1154-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1155-
# System packs
1156-
- name: st2-system-packs
1157-
image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
1158-
imagePullPolicy: {{ .Values.image.pullPolicy }}
1159-
volumeMounts:
1160-
- name: st2-packs-vol
1161-
mountPath: /opt/stackstorm/packs-shared
1162-
command:
1163-
- 'sh'
1164-
- '-ec'
1165-
- |
1166-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1167-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1079+
{{- if .Values.st2.packs.images }}
1080+
{{- include "packs-initContainers" . | indent 6 }}
11681081
{{- end }}
11691082
containers:
11701083
- name: st2actionrunner{{ template "enterpriseSuffix" . }}
@@ -1191,7 +1104,7 @@ spec:
11911104
mountPath: /etc/st2/keys
11921105
readOnly: true
11931106
{{- end }}
1194-
{{- if .Values.st2.packs.image.repository }}
1107+
{{- if .Values.st2.packs.images }}
11951108
- name: st2-packs-vol
11961109
mountPath: /opt/stackstorm/packs
11971110
readOnly: true
@@ -1224,11 +1137,8 @@ spec:
12241137
path: stanley_rsa
12251138
# 0400 file permission
12261139
mode: 256
1227-
{{- if .Values.st2.packs.image.repository }}
1228-
- name: st2-packs-vol
1229-
emptyDir: {}
1230-
- name: st2-virtualenvs-vol
1231-
emptyDir: {}
1140+
{{- if .Values.st2.packs.images }}
1141+
{{- include "packs-volumes" . | indent 8 }}
12321142
{{- end }}
12331143
{{- with .Values.st2actionrunner.nodeSelector }}
12341144
nodeSelector:
@@ -1371,43 +1281,15 @@ spec:
13711281
{{- if .Values.enterprise.enabled }}
13721282
- name: {{ .Release.Name }}-st2-license
13731283
{{- end }}
1374-
{{- if .Values.st2.packs.image.pullSecret }}
1375-
- name: {{ .Values.st2.packs.image.pullSecret }}
1284+
{{- if .Values.st2.packs.images }}
1285+
{{- include "packs-pullSecrets" . | indent 6 }}
13761286
{{- end }}
13771287
{{- if .Values.image.pullSecret }}
13781288
- name: {{ .Values.image.pullSecret }}
13791289
{{- end }}
13801290
initContainers:
1381-
{{- if .Values.st2.packs.image.repository }}
1382-
# Merge packs and virtualenvs from st2actionrunner with those from the st2.packs image
1383-
# Custom packs
1384-
- name: st2-custom-packs
1385-
image: "{{ .Values.st2.packs.image.repository }}/{{ .Values.st2.packs.image.name }}:{{ .Values.st2.packs.image.tag }}"
1386-
imagePullPolicy: {{ .Values.st2.packs.image.pullPolicy | quote }}
1387-
volumeMounts:
1388-
- name: st2-packs-vol
1389-
mountPath: /opt/stackstorm/packs-shared
1390-
- name: st2-virtualenvs-vol
1391-
mountPath: /opt/stackstorm/virtualenvs-shared
1392-
command:
1393-
- 'sh'
1394-
- '-ec'
1395-
- |
1396-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1397-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1398-
# System packs
1399-
- name: st2-system-packs
1400-
image: "{{ template "imageRepository" . }}/st2actionrunner{{ template "enterpriseSuffix" . }}:{{ .Chart.AppVersion }}"
1401-
imagePullPolicy: {{ .Values.image.pullPolicy }}
1402-
volumeMounts:
1403-
- name: st2-packs-vol
1404-
mountPath: /opt/stackstorm/packs-shared
1405-
command:
1406-
- 'sh'
1407-
- '-ec'
1408-
- |
1409-
/bin/cp -aR /opt/stackstorm/packs/. /opt/stackstorm/packs-shared &&
1410-
/bin/cp -aR /opt/stackstorm/virtualenvs/. /opt/stackstorm/virtualenvs-shared
1291+
{{- if .Values.st2.packs.images }}
1292+
{{- include "packs-initContainers" . | indent 6 }}
14111293
{{- end }}
14121294
# Sidecar container for generating st2client config with st2 username & password pair and sharing produced file with the main container
14131295
- name: generate-st2client-config
@@ -1477,7 +1359,7 @@ spec:
14771359
mountPath: /etc/st2/keys
14781360
readOnly: true
14791361
{{- end }}
1480-
{{- if .Values.st2.packs.image.repository }}
1362+
{{- if .Values.st2.packs.images }}
14811363
- name: st2-packs-vol
14821364
mountPath: /opt/stackstorm/packs
14831365
readOnly: true
@@ -1530,11 +1412,8 @@ spec:
15301412
path: stanley_rsa
15311413
# 0400 file permission
15321414
mode: 256
1533-
{{- if .Values.st2.packs.image.repository }}
1534-
- name: st2-packs-vol
1535-
emptyDir: {}
1536-
- name: st2-virtualenvs-vol
1537-
emptyDir: {}
1415+
{{- if .Values.st2.packs.images }}
1416+
{{- include "packs-volumes" . | indent 8 }}
15381417
{{- end }}
15391418

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

0 commit comments

Comments
 (0)