Skip to content

Commit 209af8b

Browse files
authored
Add image.entrypoint value to support custom entrypoints like dumb-init (#413)
* add dumb-init entrypoint * add image.entrypoint value * add changelog entry * add tests for image.entrypoint * correct command exists test assertions * old helm-unittest has isNull not notExists
1 parent 93e3f26 commit 209af8b

File tree

5 files changed

+270
-0
lines changed

5 files changed

+270
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Stop generating the DataStore Secret (#385) and checksum labels (#391) when existing secret provided or disabled (by @bmarick)
77
* Stop generating the checksum labels for Auth Secret (#392) when existing secret provided or disabled (by @bmarick)
88
* Use `image.pullPolicy` for all containers including init containers that use `image.utilityImage`. (#397) (by @jk464)
9+
* Add new `image.entrypoint` value to simplify using a custom entry point like `dumb-init` or `pid1` (if installed in the image). (#413) (by @cognifloyd)
910

1011
## v1.0.0
1112
* Bump to latest CircleCI orb versions ([email protected] and [email protected] by @ZoeLeah)

templates/_helpers.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,12 @@ Reduce duplication of the st2.*.conf volume details
181181
{{- end }}
182182
{{- end -}}
183183

184+
{{- define "stackstorm-ha.st2-entrypoint" -}}
185+
{{- range $.Values.image.entrypoint }}
186+
- {{ toYaml . }}
187+
{{- end }}
188+
{{- end -}}
189+
184190
# Override CMD CLI parameters passed to the startup of all pods to add support for /etc/st2/st2.secrets.conf
185191
{{- define "stackstorm-ha.st2-config-file-parameters" -}}
186192
- --config-file=/etc/st2/st2.conf

templates/deployments.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ spec:
7676
#livenessProbe:
7777
#readinessProbe:
7878
command:
79+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
7980
- /opt/stackstorm/st2/bin/st2auth
8081
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
8182
{{- if .Values.st2auth.env }}
@@ -203,6 +204,7 @@ spec:
203204
#livenessProbe:
204205
#readinessProbe:
205206
command:
207+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
206208
- /opt/stackstorm/st2/bin/st2api
207209
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
208210
{{- if .Values.st2api.env }}
@@ -335,6 +337,7 @@ spec:
335337
#livenessProbe:
336338
#readinessProbe:
337339
command:
340+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
338341
- /opt/stackstorm/st2/bin/st2stream
339342
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
340343
{{- if .Values.st2stream.env }}
@@ -580,6 +583,7 @@ spec:
580583
#livenessProbe:
581584
#readinessProbe:
582585
command:
586+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
583587
- /opt/stackstorm/st2/bin/st2rulesengine
584588
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
585589
{{- if .Values.st2rulesengine.env }}
@@ -697,6 +701,7 @@ spec:
697701
#livenessProbe:
698702
#readinessProbe:
699703
command:
704+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
700705
- /opt/stackstorm/st2/bin/st2timersengine
701706
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
702707
{{- if .Values.st2timersengine.env }}
@@ -804,6 +809,7 @@ spec:
804809
#livenessProbe:
805810
#readinessProbe:
806811
command:
812+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
807813
- /opt/stackstorm/st2/bin/st2workflowengine
808814
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
809815
{{- if .Values.st2workflowengine.env }}
@@ -922,6 +928,7 @@ spec:
922928
#livenessProbe:
923929
#readinessProbe:
924930
command:
931+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
925932
- /opt/stackstorm/st2/bin/st2scheduler
926933
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
927934
{{- if .Values.st2scheduler.env }}
@@ -1038,6 +1045,7 @@ spec:
10381045
#livenessProbe:
10391046
#readinessProbe:
10401047
command:
1048+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
10411049
- /opt/stackstorm/st2/bin/st2notifier
10421050
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
10431051
{{- if .Values.st2notifier.env }}
@@ -1213,6 +1221,7 @@ spec:
12131221
{{- toYaml . | nindent 10 }}
12141222
{{- end }}
12151223
command:
1224+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
12161225
- /opt/stackstorm/st2/bin/st2sensorcontainer
12171226
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
12181227
{{- if $one_sensor_per_pod }}{{/* only in st2.packs.sensors[] */}}
@@ -1375,6 +1384,7 @@ spec:
13751384
#livenessProbe:
13761385
#readinessProbe:
13771386
command:
1387+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
13781388
- /opt/stackstorm/st2/bin/st2actionrunner
13791389
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
13801390
{{- if .Values.st2actionrunner.env }}
@@ -1509,6 +1519,7 @@ spec:
15091519
#livenessProbe:
15101520
#readinessProbe:
15111521
command:
1522+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
15121523
- /opt/stackstorm/st2/bin/st2garbagecollector
15131524
{{- include "stackstorm-ha.st2-config-file-parameters" $ | nindent 10 }}
15141525
{{- if .Values.st2garbagecollector.env }}
@@ -1690,6 +1701,7 @@ spec:
16901701
mountPath: /post-start.sh
16911702
subPath: post-start.sh
16921703
command:
1704+
{{- include "stackstorm-ha.st2-entrypoint" $ | nindent 10 }}
16931705
- 'bash'
16941706
- '-ec'
16951707
- 'while true; do sleep 999; done'

tests/unit/image_entrypoint_test.yaml

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
---
2+
suite: Image Entrypoint
3+
templates:
4+
# primary template files
5+
- deployments.yaml
6+
7+
# included templates must also be listed
8+
- configmaps_overrides.yaml
9+
- configmaps_packs.yaml
10+
- configmaps_rbac.yaml
11+
- configmaps_st2-conf.yaml
12+
- configmaps_st2web.yaml
13+
- secrets_datastore_crypto_key.yaml
14+
- secrets_ssh.yaml
15+
- secrets_st2auth.yaml
16+
- secrets_st2chatops.yaml
17+
18+
# relevant values:
19+
# image.entrypoint
20+
21+
tests:
22+
- it: Deployments use custom image.entrypoint
23+
template: deployments.yaml
24+
# st2auth, st2api,
25+
# st2stream, st2web,
26+
# st2rulesengine, st2timersengine,
27+
# st2workflowengine, st2scheduler,
28+
# st2notifier, (1) st2sensorcontainer,
29+
# st2actionrunner, st2garbagecollector,
30+
# st2client, st2chatops
31+
set:
32+
image:
33+
entrypoint:
34+
- &custom_entrypoint_0 "/usr/bin/dumb-init"
35+
- &custom_entrypoint_1 "--"
36+
st2:
37+
rbac: { enabled: true } # enable rbac job
38+
packs: { sensors: [] } # ensure only 1 sensor
39+
st2chatops:
40+
enabled: true
41+
asserts:
42+
- hasDocuments:
43+
count: 14
44+
45+
# st2web and st2chatops do not use image.entrypoint
46+
# document indexes: 3, 13
47+
# all remaining deployments do use image.entrypoint
48+
49+
- isNull: &exists_command
50+
path: spec.template.spec.containers[0].command
51+
documentIndex: 3 # st2web
52+
- isNull: *exists_command
53+
documentIndex: 13 # st2chatops
54+
55+
- equal: &eq_custom_entrypoint_0
56+
path: spec.template.spec.containers[0].command[0]
57+
value: *custom_entrypoint_0
58+
documentIndex: 0
59+
- equal: &eq_custom_entrypoint_1
60+
path: spec.template.spec.containers[0].command[1]
61+
value: *custom_entrypoint_1
62+
documentIndex: 0
63+
- equal: *eq_custom_entrypoint_0
64+
documentIndex: 1
65+
- equal: *eq_custom_entrypoint_1
66+
documentIndex: 1
67+
- equal: *eq_custom_entrypoint_0
68+
documentIndex: 2
69+
- equal: *eq_custom_entrypoint_1
70+
documentIndex: 2
71+
- equal: *eq_custom_entrypoint_0
72+
documentIndex: 4
73+
- equal: *eq_custom_entrypoint_1
74+
documentIndex: 4
75+
- equal: *eq_custom_entrypoint_0
76+
documentIndex: 5
77+
- equal: *eq_custom_entrypoint_1
78+
documentIndex: 5
79+
- equal: *eq_custom_entrypoint_0
80+
documentIndex: 6
81+
- equal: *eq_custom_entrypoint_1
82+
documentIndex: 6
83+
- equal: *eq_custom_entrypoint_0
84+
documentIndex: 7
85+
- equal: *eq_custom_entrypoint_1
86+
documentIndex: 7
87+
- equal: *eq_custom_entrypoint_0
88+
documentIndex: 8
89+
- equal: *eq_custom_entrypoint_1
90+
documentIndex: 8
91+
- equal: *eq_custom_entrypoint_0
92+
documentIndex: 9
93+
- equal: *eq_custom_entrypoint_1
94+
documentIndex: 9
95+
- equal: *eq_custom_entrypoint_0
96+
documentIndex: 10
97+
- equal: *eq_custom_entrypoint_1
98+
documentIndex: 10
99+
- equal: *eq_custom_entrypoint_0
100+
documentIndex: 11
101+
- equal: *eq_custom_entrypoint_1
102+
documentIndex: 11
103+
- equal: *eq_custom_entrypoint_0
104+
documentIndex: 12
105+
- equal: *eq_custom_entrypoint_1
106+
documentIndex: 12
107+
108+
- it: Deployments use custom empty image.entrypoint
109+
template: deployments.yaml
110+
set:
111+
# image.entrypoint defaults to []
112+
# this might change in a future release
113+
st2:
114+
rbac: { enabled: true } # enable rbac job
115+
packs: { sensors: [] } # ensure only 1 sensor
116+
st2chatops:
117+
enabled: true
118+
asserts:
119+
- hasDocuments:
120+
count: 14
121+
122+
- isNull: *exists_command
123+
documentIndex: 3 # st2web
124+
- isNull: *exists_command
125+
documentIndex: 13 # st2chatops
126+
127+
- notEqual: *eq_custom_entrypoint_0
128+
documentIndex: 0
129+
- notEqual: *eq_custom_entrypoint_1
130+
documentIndex: 0
131+
- notEqual: *eq_custom_entrypoint_0
132+
documentIndex: 1
133+
- notEqual: *eq_custom_entrypoint_1
134+
documentIndex: 1
135+
- notEqual: *eq_custom_entrypoint_0
136+
documentIndex: 2
137+
- notEqual: *eq_custom_entrypoint_1
138+
documentIndex: 2
139+
- notEqual: *eq_custom_entrypoint_0
140+
documentIndex: 4
141+
- notEqual: *eq_custom_entrypoint_1
142+
documentIndex: 4
143+
- notEqual: *eq_custom_entrypoint_0
144+
documentIndex: 5
145+
- notEqual: *eq_custom_entrypoint_1
146+
documentIndex: 5
147+
- notEqual: *eq_custom_entrypoint_0
148+
documentIndex: 6
149+
- notEqual: *eq_custom_entrypoint_1
150+
documentIndex: 6
151+
- notEqual: *eq_custom_entrypoint_0
152+
documentIndex: 7
153+
- notEqual: *eq_custom_entrypoint_1
154+
documentIndex: 7
155+
- notEqual: *eq_custom_entrypoint_0
156+
documentIndex: 8
157+
- notEqual: *eq_custom_entrypoint_1
158+
documentIndex: 8
159+
- notEqual: *eq_custom_entrypoint_0
160+
documentIndex: 9
161+
- notEqual: *eq_custom_entrypoint_1
162+
documentIndex: 9
163+
- notEqual: *eq_custom_entrypoint_0
164+
documentIndex: 10
165+
- notEqual: *eq_custom_entrypoint_1
166+
documentIndex: 10
167+
- notEqual: *eq_custom_entrypoint_0
168+
documentIndex: 11
169+
- notEqual: *eq_custom_entrypoint_1
170+
documentIndex: 11
171+
- notEqual: *eq_custom_entrypoint_0
172+
documentIndex: 12
173+
- notEqual: *eq_custom_entrypoint_1
174+
documentIndex: 12
175+
176+
- it: Deployments use default image.entrypoint
177+
template: deployments.yaml
178+
set:
179+
image:
180+
entrypoint: [] # explicitly empty list
181+
st2:
182+
rbac: { enabled: true } # enable rbac job
183+
packs: { sensors: [] } # ensure only 1 sensor
184+
st2chatops:
185+
enabled: true
186+
asserts:
187+
- hasDocuments:
188+
count: 14
189+
190+
- isNull: *exists_command
191+
documentIndex: 3 # st2web
192+
- isNull: *exists_command
193+
documentIndex: 13 # st2chatops
194+
195+
- notEqual: *eq_custom_entrypoint_0
196+
documentIndex: 0
197+
- notEqual: *eq_custom_entrypoint_1
198+
documentIndex: 0
199+
- notEqual: *eq_custom_entrypoint_0
200+
documentIndex: 1
201+
- notEqual: *eq_custom_entrypoint_1
202+
documentIndex: 1
203+
- notEqual: *eq_custom_entrypoint_0
204+
documentIndex: 2
205+
- notEqual: *eq_custom_entrypoint_1
206+
documentIndex: 2
207+
- notEqual: *eq_custom_entrypoint_0
208+
documentIndex: 4
209+
- notEqual: *eq_custom_entrypoint_1
210+
documentIndex: 4
211+
- notEqual: *eq_custom_entrypoint_0
212+
documentIndex: 5
213+
- notEqual: *eq_custom_entrypoint_1
214+
documentIndex: 5
215+
- notEqual: *eq_custom_entrypoint_0
216+
documentIndex: 6
217+
- notEqual: *eq_custom_entrypoint_1
218+
documentIndex: 6
219+
- notEqual: *eq_custom_entrypoint_0
220+
documentIndex: 7
221+
- notEqual: *eq_custom_entrypoint_1
222+
documentIndex: 7
223+
- notEqual: *eq_custom_entrypoint_0
224+
documentIndex: 8
225+
- notEqual: *eq_custom_entrypoint_1
226+
documentIndex: 8
227+
- notEqual: *eq_custom_entrypoint_0
228+
documentIndex: 9
229+
- notEqual: *eq_custom_entrypoint_1
230+
documentIndex: 9
231+
- notEqual: *eq_custom_entrypoint_0
232+
documentIndex: 10
233+
- notEqual: *eq_custom_entrypoint_1
234+
documentIndex: 10
235+
- notEqual: *eq_custom_entrypoint_0
236+
documentIndex: 11
237+
- notEqual: *eq_custom_entrypoint_1
238+
documentIndex: 11
239+
- notEqual: *eq_custom_entrypoint_0
240+
documentIndex: 12
241+
- notEqual: *eq_custom_entrypoint_1
242+
documentIndex: 12
243+

values.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ image:
2424
# May be required for public docker hub due to rate limiting or any private repository.
2525
# See: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
2626
#pullSecret: "your-pull-secret"
27+
# Image entry point for st2* deployments (except st2web and st2chatops).
28+
# This chart replaces the entrypoint (command+args) baked into the docker images.
29+
# If you are have installed a custom init process (like dumb-init, pid1, tini or similar),
30+
# in the docker image(s) you are using, you can add that entrypoint here.
31+
entrypoint: []
32+
# For example you could add dumb-init like this (dumb-init must be present in the image).
33+
#- "/usr/bin/dumb-init"
34+
#- "--"
2735

2836
##
2937
## local cluster domain suffix to enable fqdn lookups for redis, mongo

0 commit comments

Comments
 (0)