Skip to content

Commit a8dc79c

Browse files
committed
fix(wik-webservice): add opt-in option webservice.httproute.addGatewayParentRef
1 parent ca6ebfe commit a8dc79c

5 files changed

Lines changed: 52 additions & 3 deletions

File tree

charts/wik-webservice/README.md.gotmpl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,16 @@ The chart supports [Gateway API](https://gateway-api.sigs.k8s.io/) HTTPRoute as
8787
| `webservice.httpRoute.enabled` | Create an HTTPRoute | `false` |
8888
| `webservice.httpRoute.gatewayRef` | Gateway reference (`name`, `namespace`). Omitted if empty | `{}` |
8989
| `webservice.httpRoute.tls` | Auto-create a ListenerSet for TLS (like `ingress.tlsAcme`). Skipped if CRDs absent | `true` |
90+
| `webservice.httpRoute.addGatewayParentRef` | When `tls: true`, also add the Gateway as a parentRef (in addition to the ListenerSet) | `false` |
9091
| `webservice.httpRoute.annotations` | HTTPRoute annotations | `{}` |
9192
| `webservice.httpRoute.labels` | HTTPRoute labels | `{}` |
9293
| `webservice.httpRoute.filters` | Filters for the default rule | `[]` |
9394
| `webservice.httpRoute.additionalRules` | Extra routing rules | `[]` |
9495
| `webservice.additionalHttpRoutes` | Additional HTTPRoute resources with custom hosts | `[]` |
9596

9697
```yaml
97-
# Simple HTTPRoute (uses webservice.hosts)
98-
# TLS is enabled by default and auto-creates a ListenerSet
98+
# Simple HTTPRoute with TLS (default)
99+
# The ListenerSet is the only parentRef, Gateway is referenced via the ListenerSet
99100
webservice:
100101
image: myapp:latest
101102
hosts:
@@ -106,6 +107,22 @@ webservice:
106107
name: main-gateway
107108
namespace: gateway
108109
110+
# Also add the Gateway as a parentRef (if needed by your implementation)
111+
webservice:
112+
httpRoute:
113+
enabled: true
114+
gatewayRef:
115+
name: main-gateway
116+
addGatewayParentRef: true
117+
118+
# Without TLS — Gateway is the only parentRef
119+
webservice:
120+
httpRoute:
121+
enabled: true
122+
tls: false
123+
gatewayRef:
124+
name: main-gateway
125+
109126
# Additional HTTPRoutes with custom hosts
110127
webservice:
111128
httpRoute:

charts/wik-webservice/templates/httproute.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,18 @@ spec:
3030
kind: XListenerSet
3131
name: {{ template "fullname" $root }}
3232
{{- end }}
33+
{{- if $root.Values.webservice.httpRoute.addGatewayParentRef }}
34+
- name: {{ .name }}
35+
{{- with .namespace }}
36+
namespace: {{ . }}
37+
{{- end }}
3338
{{- end }}
39+
{{- else }}
3440
- name: {{ .name }}
3541
{{- with .namespace }}
3642
namespace: {{ . }}
3743
{{- end }}
44+
{{- end }}
3845
{{- end }}
3946
{{- end }}
4047
{{- if .Values.webservice.hosts }}

charts/wik-webservice/tests/httproute_test.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ tests:
6262
- isNull:
6363
path: spec.parentRefs
6464

65-
- it: should add Listener parentRef when tls is true
65+
- it: should only have ListenerSet parentRef when tls is true
6666
set:
6767
webservice:
6868
image: nginx:latest
@@ -72,6 +72,25 @@ tests:
7272
enabled: true
7373
gatewayRef:
7474
name: my-gateway
75+
asserts:
76+
- equal:
77+
path: spec.parentRefs[0].kind
78+
value: XListenerSet
79+
- lengthEqual:
80+
path: spec.parentRefs
81+
count: 1
82+
83+
- it: should add gateway parentRef when addGatewayParentRef is true
84+
set:
85+
webservice:
86+
image: nginx:latest
87+
hosts:
88+
- test.example.com
89+
httpRoute:
90+
enabled: true
91+
gatewayRef:
92+
name: my-gateway
93+
addGatewayParentRef: true
7594
asserts:
7695
- equal:
7796
path: spec.parentRefs[0].kind

charts/wik-webservice/values.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@
134134
"type": "boolean",
135135
"default": true
136136
},
137+
"addGatewayParentRef": {
138+
"type": "boolean",
139+
"default": false
140+
},
137141
"annotations": {
138142
"type": "object",
139143
"default": {}

charts/wik-webservice/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ webservice:
176176
# Creates HTTPS listeners on the gateway for each host in webservice.hosts
177177
# Silently skipped if ListenerSet/XListenerSet CRDs are not available on the cluster
178178
tls: true
179+
# When tls is true, also add the Gateway itself as a parentRef (in addition to the ListenerSet)
180+
addGatewayParentRef: false
179181
annotations: {}
180182
labels: {}
181183
# Filters applied to the default rule (e.g. RequestHeaderModifier, RequestRedirect)

0 commit comments

Comments
 (0)