Skip to content

Commit c3f49eb

Browse files
authored
Merge branch 'master' into optional_secret_config
2 parents bbe948d + dbcd54d commit c3f49eb

File tree

3 files changed

+206
-0
lines changed

3 files changed

+206
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## In Development
44
* Temporary workaround for #311 to use previous bitnami index from: https://github.com/bitnami/charts/issues/10539 (#312 #318) (by @0xhaven)
55
* Refactor label definitions to be more consistent by building labels and label selectors in partial helper templates. (#299) (by @cognifloyd)
6+
* Use the correct `apiVersion` for `Ingress` to add support for Kubernetes `v1.22`. (by @arms11)
67
* New Feature: Add `existingConfigSecret` . If this is defined, the `st2.secrets.conf` key within this secret will be written as /etc/st2/st2.secrets.conf and added to the end of the command line arguments of all pods. (#289) (by @eric-al)
78

89
## v0.100.0

templates/ingress.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{{- if .Values.ingress.enabled }}
22
---
3+
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
4+
apiVersion: networking.k8s.io/v1
5+
{{- else }}
36
apiVersion: networking.k8s.io/v1beta1
7+
{{- end }}
48
kind: Ingress
59
metadata:
610
name: {{ .Release.Name }}-st2web-ingress
@@ -20,9 +24,18 @@ spec:
2024
paths:
2125
{{- range .paths }}
2226
- path: {{ default "/*" .path }}
27+
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
28+
pathType: Prefix
29+
backend:
30+
service:
31+
name: {{ .serviceName }}
32+
port:
33+
number: {{ .servicePort }}
34+
{{- else }}
2335
backend:
2436
serviceName: {{ .serviceName }}
2537
servicePort: {{ .servicePort }}
38+
{{- end }}
2639
{{- end }}
2740
{{- else }}
2841
{{- if required "Missing context '.Values.st2web.service.hostname'!" .Values.st2web.service.hostname }}
@@ -31,9 +44,18 @@ spec:
3144
http:
3245
paths:
3346
- path: "/"
47+
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
48+
pathType: Prefix
49+
backend:
50+
service:
51+
name: {{ .Release.Name }}-st2web
52+
port:
53+
number: 80
54+
{{- else }}
3455
backend:
3556
serviceName: {{ .Release.Name }}-st2web
3657
servicePort: 80
58+
{{- end }}
3759
{{- end }}
3860
{{- if .Values.ingress.tls }}
3961
tls:

tests/unit/ingress_test.yaml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
suite: Ingress
3+
templates:
4+
# primary template files
5+
- ingress.yaml
6+
7+
tests:
8+
- it: Ingress not present if disabled
9+
set:
10+
ingress:
11+
enabled: false
12+
asserts:
13+
- hasDocuments:
14+
count: 0
15+
16+
- it: Ingress is present when enabled without hosts (older k8s)
17+
capabilities: &cap_older
18+
majorVersion: 1
19+
minorVersion: 18
20+
apiVersions:
21+
- networking.k8s.io/v1beta1
22+
set:
23+
ingress:
24+
enabled: true
25+
hosts: []
26+
tls: []
27+
st2web:
28+
service:
29+
hostname: &st2web_hostname hostname.domain.tld
30+
release:
31+
name: st2ha
32+
asserts:
33+
- hasDocuments:
34+
count: 1
35+
- equal:
36+
path: kind
37+
value: Ingress
38+
# no ingress.hosts, so only st2web.hostname
39+
- equal: &st2web_rules_host
40+
path: spec.rules[0].host
41+
value: *st2web_hostname
42+
- contains:
43+
path: spec.rules[0].http.paths
44+
count: 1
45+
content:
46+
path: "/"
47+
backend:
48+
serviceName: st2ha-st2web
49+
servicePort: 80
50+
- isNull:
51+
path: spec.rules[0].http.paths[0].pathType
52+
53+
- it: Ingress is present when enabled without hosts (newer k8s)
54+
capabilities: &cap_newer
55+
majorVersion: 1
56+
minorVersion: 19
57+
apiVersions:
58+
- networking.k8s.io/v1 # introduced in 1.19, stable in 1.22
59+
- networking.k8s.io/v1beta1
60+
set:
61+
ingress:
62+
enabled: true
63+
hosts: []
64+
tls: []
65+
st2web:
66+
service:
67+
hostname: *st2web_hostname
68+
release:
69+
name: st2ha
70+
asserts:
71+
- hasDocuments:
72+
count: 1
73+
- equal:
74+
path: kind
75+
value: Ingress
76+
# no ingress.hosts, so only st2web.hostname
77+
- equal: *st2web_rules_host
78+
- contains:
79+
path: spec.rules[0].http.paths
80+
count: 1
81+
content:
82+
path: "/"
83+
pathType: Prefix
84+
backend:
85+
service:
86+
name: st2ha-st2web
87+
port:
88+
number: 80
89+
90+
- it: Ingress is present when enabled with hosts (older k8s)
91+
capabilities: *cap_older
92+
set:
93+
ingress:
94+
enabled: true
95+
hosts: &hosts
96+
- host: *st2web_hostname
97+
paths:
98+
- serviceName: st2ha-st2web
99+
servicePort: 80
100+
- path: /fancy-sensor
101+
serviceName: fancy-sensor
102+
servicePort: 8080
103+
tls: []
104+
st2web:
105+
service:
106+
hostname: *st2web_hostname
107+
release:
108+
name: st2ha
109+
asserts:
110+
- hasDocuments:
111+
count: 1
112+
- equal:
113+
path: kind
114+
value: Ingress
115+
# no ingress.hosts, so only st2web.hostname
116+
- equal: *st2web_rules_host
117+
- equal: &host_path_is_root_glob
118+
path: spec.rules[0].http.paths[0].path
119+
value: "/*"
120+
- isNull:
121+
path: spec.rules[0].http.paths[0].pathType
122+
- equal:
123+
path: spec.rules[0].http.paths[0].backend
124+
value:
125+
serviceName: st2ha-st2web
126+
servicePort: 80
127+
128+
- equal:
129+
path: spec.rules[0].http.paths[1].path
130+
value: "/fancy-sensor"
131+
- isNull:
132+
path: spec.rules[0].http.paths[1].pathType
133+
- equal:
134+
path: spec.rules[0].http.paths[1].backend
135+
value:
136+
serviceName: fancy-sensor
137+
servicePort: 8080
138+
139+
- it: Ingress is present when enabled with hosts (newer k8s)
140+
capabilities: *cap_newer
141+
set:
142+
ingress:
143+
enabled: true
144+
hosts: *hosts
145+
tls: []
146+
st2web:
147+
service:
148+
hostname: *st2web_hostname
149+
release:
150+
name: st2ha
151+
asserts:
152+
- hasDocuments:
153+
count: 1
154+
- equal:
155+
path: kind
156+
value: Ingress
157+
# no ingress.hosts, so only st2web.hostname
158+
- equal: *st2web_rules_host
159+
- equal: *host_path_is_root_glob
160+
- equal:
161+
path: spec.rules[0].http.paths[0].pathType
162+
value: Prefix
163+
- equal:
164+
path: spec.rules[0].http.paths[0].backend
165+
value:
166+
service:
167+
name: st2ha-st2web
168+
port:
169+
number: 80
170+
171+
- equal:
172+
path: spec.rules[0].http.paths[1].path
173+
value: "/fancy-sensor"
174+
- equal:
175+
path: spec.rules[0].http.paths[1].pathType
176+
value: Prefix
177+
- equal:
178+
path: spec.rules[0].http.paths[1].backend
179+
value:
180+
service:
181+
name: fancy-sensor
182+
port:
183+
number: 8080

0 commit comments

Comments
 (0)