Skip to content

Commit a99da9b

Browse files
committed
feat(wik-webservice): improve support for ListenerSet
1 parent 0dfa466 commit a99da9b

8 files changed

Lines changed: 139 additions & 137 deletions

File tree

charts/wik-webservice/README.md.gotmpl

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ It creates:
1818
- **ListenerSet** for automatic TLS listener provisioning (Gateway API)
1919
- **PVC** for persistent storage
2020

21+
## Breaking Changes
22+
23+
### 0.7.0
24+
25+
- **`webservice.ingress.enabled` now defaults to `false`** (was `true`).
26+
If you rely on Ingress, explicitly set `webservice.ingress.enabled: true` in your values.
27+
- **`webservice.httpRoute.tls` now defaults to `true`**.
28+
A ListenerSet is auto-created when Gateway API ListenerSet CRDs are available on the cluster.
29+
Silently skipped if the CRDs are absent.
30+
- **`webservice.httpRoute.parentRefs` replaced by `webservice.httpRoute.gatewayRef`**.
31+
Single object instead of array. For multi-gateway routing, use `additionalHttpRoutes`.
32+
2133
## Installation
2234

2335
```bash
@@ -73,8 +85,8 @@ The chart supports [Gateway API](https://gateway-api.sigs.k8s.io/) HTTPRoute as
7385
| Parameter | Description | Default |
7486
|-----------|-------------|---------|
7587
| `webservice.httpRoute.enabled` | Create an HTTPRoute | `false` |
76-
| `webservice.httpRoute.parentRefs` | Gateway parent references (omitted if empty) | `[]` |
77-
| `webservice.httpRoute.tls` | Auto-create a ListenerSet for TLS (like `ingress.tlsAcme`) | `false` |
88+
| `webservice.httpRoute.gatewayRef` | Gateway reference (`name`, `namespace`). Omitted if empty | `{}` |
89+
| `webservice.httpRoute.tls` | Auto-create a ListenerSet for TLS (like `ingress.tlsAcme`). Skipped if CRDs absent | `true` |
7890
| `webservice.httpRoute.annotations` | HTTPRoute annotations | `{}` |
7991
| `webservice.httpRoute.labels` | HTTPRoute labels | `{}` |
8092
| `webservice.httpRoute.filters` | Filters for the default rule | `[]` |
@@ -83,31 +95,23 @@ The chart supports [Gateway API](https://gateway-api.sigs.k8s.io/) HTTPRoute as
8395

8496
```yaml
8597
# Simple HTTPRoute (uses webservice.hosts)
98+
# TLS is enabled by default and auto-creates a ListenerSet
8699
webservice:
87100
image: myapp:latest
88101
hosts:
89102
- app.example.com
90-
ingress:
91-
enabled: false
92-
httpRoute:
93-
enabled: true
94-
parentRefs:
95-
- name: main-gateway
96-
97-
# HTTPRoute with TLS (auto-creates ListenerSet)
98-
webservice:
99103
httpRoute:
100104
enabled: true
101-
parentRefs:
102-
- name: main-gateway
103-
tls: true
105+
gatewayRef:
106+
name: main-gateway
107+
namespace: gateway
104108
105109
# Additional HTTPRoutes with custom hosts
106110
webservice:
107111
httpRoute:
108112
enabled: true
109-
parentRefs:
110-
- name: public-gateway
113+
gatewayRef:
114+
name: public-gateway
111115
additionalHttpRoutes:
112116
- name: internal
113117
parentRefs:
@@ -124,7 +128,6 @@ When `httpRoute.tls: true`, the chart auto-creates a ListenerSet that adds HTTPS
124128

125129
| Parameter | Description | Default |
126130
|-----------|-------------|---------|
127-
| `webservice.listenerSet.gatewayRef` | Gateway to attach listeners to (defaults to `httpRoute.parentRefs[0]`) | `{}` |
128131
| `webservice.listenerSet.port` | Listener port | `443` |
129132
| `webservice.listenerSet.protocol` | Listener protocol | `HTTPS` |
130133
| `webservice.listenerSet.tls.mode` | TLS mode | `Terminate` |
@@ -137,20 +140,19 @@ When `httpRoute.tls: true`, the chart auto-creates a ListenerSet that adds HTTPS
137140
webservice:
138141
httpRoute:
139142
enabled: true
140-
parentRefs:
141-
- name: main-gateway
142-
tls: true
143+
gatewayRef:
144+
name: main-gateway
145+
# tls: true is the default
143146
# Auto-creates ListenerSet:
144-
# - gatewayRef from httpRoute.parentRefs[0]
147+
# - uses httpRoute.gatewayRef as gateway target
145148
# - certificateRef: Secret/<fullname>--tls
146149
147150
# With cert-manager auto-provisioning
148151
webservice:
149152
httpRoute:
150153
enabled: true
151-
parentRefs:
152-
- name: main-gateway
153-
tls: true
154+
gatewayRef:
155+
name: main-gateway
154156
listenerSet:
155157
annotations:
156158
cert-manager.io/cluster-issuer: letsencrypt-prod
@@ -159,9 +161,8 @@ webservice:
159161
webservice:
160162
httpRoute:
161163
enabled: true
162-
parentRefs:
163-
- name: main-gateway
164-
tls: true
164+
gatewayRef:
165+
name: main-gateway
165166
listenerSet:
166167
tls:
167168
certificateRefs:
@@ -200,8 +201,8 @@ webservice:
200201
enabled: false
201202
httpRoute:
202203
enabled: true
203-
parentRefs:
204-
- name: main-gateway
204+
gatewayRef:
205+
name: main-gateway
205206
```
206207

207208
Policy to create alongside (Envoy Gateway example):
@@ -285,9 +286,9 @@ webservice:
285286
enabled: false
286287
httpRoute:
287288
enabled: true
288-
parentRefs:
289-
- name: main-gateway
290-
tls: true
289+
gatewayRef:
290+
name: main-gateway
291+
# tls: true is the default
291292
# Auto-creates a ListenerSet with HTTPS listeners for each host
292293
# certificateRefs defaults to Secret/<fullname>--tls
293294
```
@@ -854,10 +855,9 @@ webservice:
854855
enabled: false
855856
httpRoute:
856857
enabled: true
857-
parentRefs:
858-
- name: main-gateway
859-
namespace: gateway-system
860-
tls: true
858+
gatewayRef:
859+
name: main-gateway
860+
namespace: gateway-system
861861
```
862862
863863
### With init and sidecar containers

charts/wik-webservice/ci/full-values.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ webservice:
3030

3131
httpRoute:
3232
enabled: true
33-
parentRefs:
34-
- name: test-gateway
35-
namespace: gateway-system
33+
gatewayRef:
34+
name: test-gateway
35+
namespace: gateway-system
3636
tls: true
3737
annotations:
3838
example.com/test: "true"

charts/wik-webservice/templates/httproute.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ metadata:
1717
{{ toYaml . | indent 4 }}
1818
{{- end }}
1919
spec:
20-
{{- with .Values.webservice.httpRoute.parentRefs }}
20+
{{- with .Values.webservice.httpRoute.gatewayRef }}
21+
{{- if .name }}
2122
parentRefs:
22-
{{ toYaml . | indent 4 }}
23+
- name: {{ .name }}
24+
{{- with .namespace }}
25+
namespace: {{ . }}
26+
{{- end }}
27+
{{- if $root.Values.webservice.httpRoute.tls }}
28+
- group: gateway.networking.k8s.io
29+
kind: Listener
30+
name: {{ template "fullname" $root }}
31+
{{- end }}
32+
{{- end }}
2333
{{- end }}
2434
{{- if .Values.webservice.hosts }}
2535
hostnames:

charts/wik-webservice/templates/listenerset.yaml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
{{- if .Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/ListenerSet" }}
44
apiVersion: gateway.networking.k8s.io/v1
55
kind: ListenerSet
6-
{{- else }}
6+
{{- else if .Capabilities.APIVersions.Has "gateway.networking.x-k8s.io/v1alpha1/XListenerSet" }}
77
apiVersion: gateway.networking.x-k8s.io/v1alpha1
88
kind: XListenerSet
9+
{{- else }}
10+
{{- /* ListenerSet CRDs not available on cluster, silently skip */ -}}
911
{{- end }}
12+
{{- if or (.Capabilities.APIVersions.Has "gateway.networking.k8s.io/v1/ListenerSet") (.Capabilities.APIVersions.Has "gateway.networking.x-k8s.io/v1alpha1/XListenerSet") }}
1013
metadata:
1114
name: {{ template "fullname" . }}
1215
labels:
@@ -25,18 +28,13 @@ spec:
2528
parentRef:
2629
group: gateway.networking.k8s.io
2730
kind: Gateway
28-
{{- if .Values.webservice.listenerSet.gatewayRef.name }}
29-
name: {{ .Values.webservice.listenerSet.gatewayRef.name }}
30-
{{- with .Values.webservice.listenerSet.gatewayRef.namespace }}
31-
namespace: {{ . }}
32-
{{- end }}
33-
{{- else if .Values.webservice.httpRoute.parentRefs }}
34-
name: {{ (index .Values.webservice.httpRoute.parentRefs 0).name }}
35-
{{- with (index .Values.webservice.httpRoute.parentRefs 0).namespace }}
31+
{{- if .Values.webservice.httpRoute.gatewayRef.name }}
32+
name: {{ .Values.webservice.httpRoute.gatewayRef.name }}
33+
{{- with .Values.webservice.httpRoute.gatewayRef.namespace }}
3634
namespace: {{ . }}
3735
{{- end }}
3836
{{- else }}
39-
{{- fail "httpRoute.tls requires either listenerSet.gatewayRef.name or httpRoute.parentRefs to be set" }}
37+
{{- fail "httpRoute.tls requires httpRoute.gatewayRef.name to be set" }}
4038
{{- end }}
4139
listeners:
4240
{{- range .Values.webservice.hosts }}
@@ -55,3 +53,4 @@ spec:
5553
{{- end }}
5654
{{- end }}
5755
{{- end }}
56+
{{- end }}

charts/wik-webservice/tests/httproute_test.yaml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ tests:
2828
- isAPIVersion:
2929
of: gateway.networking.k8s.io/v1
3030

31-
- it: should set parentRefs when specified
31+
- it: should set parentRef from gatewayRef
3232
set:
3333
webservice:
3434
image: nginx:latest
3535
hosts:
3636
- test.example.com
3737
httpRoute:
3838
enabled: true
39-
parentRefs:
40-
- name: my-gateway
41-
namespace: gateway-system
39+
gatewayRef:
40+
name: my-gateway
41+
namespace: gateway-system
4242
asserts:
4343
- equal:
4444
path: spec.parentRefs[0].name
@@ -47,19 +47,35 @@ tests:
4747
path: spec.parentRefs[0].namespace
4848
value: gateway-system
4949

50-
- it: should omit parentRefs when empty
50+
- it: should omit parentRefs when no gatewayRef and no tls
5151
set:
5252
webservice:
5353
image: nginx:latest
5454
hosts:
5555
- test.example.com
5656
httpRoute:
5757
enabled: true
58-
parentRefs: []
58+
tls: false
59+
gatewayRef: {}
5960
asserts:
6061
- isNull:
6162
path: spec.parentRefs
6263

64+
- it: should add Listener parentRef when tls is true
65+
set:
66+
webservice:
67+
image: nginx:latest
68+
hosts:
69+
- test.example.com
70+
httpRoute:
71+
enabled: true
72+
gatewayRef:
73+
name: my-gateway
74+
asserts:
75+
- equal:
76+
path: spec.parentRefs[1].kind
77+
value: Listener
78+
6379
- it: should use hosts as hostnames
6480
set:
6581
webservice:

0 commit comments

Comments
 (0)