Skip to content

Commit 4ce954f

Browse files
committed
add test for imagePullSecrets and PullPolicy
1 parent a75bf70 commit 4ce954f

File tree

2 files changed

+119
-1
lines changed

2 files changed

+119
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Advanced Feature: Make securityContext (on Deployments/Jobs) and podSecurityContext (on Pods) configurable. This allows dropping all capabilities, for example. You can override the securityContext for `st2actionrunner`, `st2sensorcontainer`, and `st2client` if your actions or sensors need, for example, additional capabilites that the rest of StackStorm does not need. (#271) (by @cognifloyd)
55
* Prefix template helpers with chart name and format helper comments as template comments. (#272) (by @cognifloyd)
66
* New feature: Add `extra_volumes` to all python-based st2 deployments. This can facilitate changing log levels by loading logging conf file(s) from a custom ConfigMap. (#276) (by @cognifloyd)
7-
* Initialize basic unittest infrastructure using `helm-unittest`. Added tests for labels, custom annotations, and SecurityContext. (#284, #288)
7+
* Initialize basic unittest infrastructure using `helm-unittest`. Added tests for labels, custom annotations, SecurityContext, pullSecrets, and pullPolicy. (#284, #288)
88

99
## v0.80.0
1010
* Switch st2 to `v3.6` as a new default stable version (#274)

tests/unit/image_pull_test.yaml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
---
2+
suite: Image Pull
3+
templates:
4+
# primary template files
5+
- deployments.yaml
6+
- jobs.yaml
7+
- service-account.yaml
8+
9+
# included templates must also be listed
10+
- configmaps_packs.yaml
11+
- configmaps_rbac.yaml
12+
- configmaps_st2-conf.yaml
13+
- configmaps_st2-urls.yaml
14+
- configmaps_st2web.yaml
15+
- secrets_datastore_crypto_key.yaml
16+
- secrets_ssh.yaml
17+
- secrets_st2apikeys.yaml
18+
- secrets_st2auth.yaml
19+
- secrets_st2chatops.yaml
20+
21+
# relevant values:
22+
# imagePullPolicy
23+
# image.pullPolicy
24+
# serviceAccount.pullPolicy
25+
# st2.packs.images[].pullPolicy
26+
# imagePullSecreets
27+
# image.pullSecret
28+
# serviceAccount.pullSecret
29+
# st2.packs.images[].pullSecret
30+
31+
tests:
32+
- it: Deployments and Jobs use default pullPolicy and pullSecret
33+
templates:
34+
- deployments.yaml
35+
# st2auth, st2api,
36+
# st2stream, st2web,
37+
# st2rulesengine, st2timersengine,
38+
# st2workflowengine, st2scheduler,
39+
# st2notifier, (1) st2sensorcontainer,
40+
# st2actionrunner, st2garbagecollector,
41+
# st2client, st2chatops
42+
- jobs.yaml
43+
# job-st2-apply-rbac-defintions
44+
# job-st2-apikey-load
45+
# job-st2-key-load
46+
# job-st2-register-content
47+
set:
48+
# image.pullPolicy defaults to IfNotPresent
49+
# image.pullSecret defaults to None
50+
serviceAccount:
51+
create: true
52+
# show that this does not affect pod specs
53+
pullSecret: service-account-pull-secret
54+
st2:
55+
rbac: { enabled: true } # enable rbac job
56+
packs: { sensors: [] } # ensure only 1 sensor
57+
st2chatops:
58+
enabled: true
59+
asserts:
60+
- isNull:
61+
path: spec.template.spec.imagePullSecrets
62+
- equal:
63+
path: spec.template.spec.containers[0].imagePullPolicy
64+
value: IfNotPresent
65+
# path can only select one element, not all initContainers (if present).
66+
#- equal:
67+
# path: 'spec.template.spec.initContainers[].imagePullPolicy'
68+
# value: IfNotPresent
69+
70+
- it: Deployments and Jobs use custom pullPolicy and pullSecret
71+
templates:
72+
- deployments.yaml
73+
- jobs.yaml
74+
set:
75+
image:
76+
pullPolicy: Always
77+
pullSecret: custom-pull-secret
78+
serviceAccount:
79+
create: true
80+
# show that this does not affect pod specs
81+
pullSecret: service-account-pull-secret
82+
st2:
83+
rbac: { enabled: true } # enable rbac job
84+
packs: { sensors: [] } # ensure only 1 sensor
85+
st2chatops:
86+
enabled: true
87+
asserts:
88+
- equal:
89+
path: spec.template.spec.imagePullSecrets[0].name
90+
value: custom-pull-secret
91+
- equal:
92+
path: spec.template.spec.containers[0].imagePullPolicy
93+
value: Always
94+
# path can only select one element, not all initContainers (if present).
95+
#- equal:
96+
# path: 'spec.template.spec.initContainers[].imagePullPolicy'
97+
# value: Always
98+
99+
- it: ServiceAccount has no imagePullSecret by default
100+
template: service-account.yaml
101+
set:
102+
serviceAccount:
103+
create: true
104+
asserts:
105+
- isNull:
106+
path: imagePullSecrets
107+
108+
- it: ServiceAccount accepts custom imagePullSecret
109+
template: service-account.yaml
110+
set:
111+
serviceAccount:
112+
create: true
113+
# show that this does not affect pod specs
114+
pullSecret: service-account-pull-secret
115+
asserts:
116+
- equal:
117+
path: imagePullSecrets[0].name
118+
value: service-account-pull-secret

0 commit comments

Comments
 (0)