Skip to content

Commit 1bf76b7

Browse files
apkatsikasdominiquemetz
authored andcommitted
feat(keycloakx): add ListenerSet support to httpRoute
Signed-off-by: apkatsikas <apkatsikas@gmail.com>
1 parent 52b0b71 commit 1bf76b7

4 files changed

Lines changed: 107 additions & 0 deletions

File tree

charts/keycloakx/templates/httproute.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,32 @@ metadata:
1616
{{- end }}
1717
spec:
1818
parentRefs:
19+
{{- if $httpRoute.listenerSet.enabled }}
20+
- kind: ListenerSet
21+
name: {{ include "keycloak.fullname" $ }}
22+
namespace: {{ $.Release.Namespace }}
23+
{{- else }}
1924
{{- with $httpRoute.parentRefs }}
2025
{{- toYaml . | nindent 4 }}
2126
{{- end }}
27+
{{- end }}
28+
{{- if $httpRoute.listenerSet.enabled }}
29+
{{- $hostnames := list }}
30+
{{- range $httpRoute.listenerSet.listeners }}
31+
{{- if .hostname }}
32+
{{- $hostnames = append $hostnames .hostname }}
33+
{{- end }}
34+
{{- end }}
35+
{{- with $hostnames }}
36+
hostnames:
37+
{{- toYaml . | nindent 4 }}
38+
{{- end }}
39+
{{- else }}
2240
{{- with $httpRoute.hostnames }}
2341
hostnames:
2442
{{- toYaml . | nindent 4 }}
2543
{{- end }}
44+
{{- end }}
2645
rules:
2746
{{- range $httpRoute.rules }}
2847
{{- with .matches }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- $httpRoute := .Values.httpRoute -}}
2+
{{- $listenerSet := $httpRoute.listenerSet -}}
3+
{{- if and $httpRoute.enabled $listenerSet.enabled -}}
4+
apiVersion: gateway.networking.k8s.io/v1
5+
kind: ListenerSet
6+
metadata:
7+
name: {{ include "keycloak.fullname" . }}
8+
namespace: {{ .Release.Namespace }}
9+
labels:
10+
{{- include "keycloak.labels" . | nindent 4 }}
11+
{{- range $key, $value := $httpRoute.labels }}
12+
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
13+
{{- end }}
14+
{{- range $key, $value := $listenerSet.labels }}
15+
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
16+
{{- end }}
17+
{{- with $listenerSet.annotations }}
18+
annotations:
19+
{{- toYaml . | nindent 4 }}
20+
{{- end }}
21+
spec:
22+
parentRef:
23+
name: {{ $listenerSet.parentRef.name }}
24+
{{- with $listenerSet.parentRef.namespace }}
25+
namespace: {{ . }}
26+
{{- end }}
27+
listeners:
28+
{{- toYaml $listenerSet.listeners | nindent 4 }}
29+
{{- end }}

charts/keycloakx/values.schema.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,37 @@
158158
},
159159
"console": {
160160
"$ref": "#/definitions/httpRoute"
161+
},
162+
"listenerSet": {
163+
"type": "object",
164+
"properties": {
165+
"enabled": {
166+
"type": "boolean"
167+
},
168+
"annotations": {
169+
"type": "object"
170+
},
171+
"labels": {
172+
"type": "object"
173+
},
174+
"parentRef": {
175+
"type": "object",
176+
"properties": {
177+
"name": {
178+
"type": "string"
179+
},
180+
"namespace": {
181+
"type": "string"
182+
}
183+
}
184+
},
185+
"listeners": {
186+
"type": "array",
187+
"items": {
188+
"type": "object"
189+
}
190+
}
191+
}
161192
}
162193
}
163194
}

charts/keycloakx/values.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,34 @@ httpRoute:
319319
type: PathPrefix
320320
value: '{{ tpl .Values.http.relativePath $ | trimSuffix "/" }}/'
321321

322+
# -- Create a ListenerSet resource to attach listeners to an existing Gateway
323+
# without requiring write access to the Gateway resource itself. Useful for
324+
# namespace-level configuration where app owners do not have Gateway write access.
325+
# When enabled, the HTTPRoute parentRefs are auto-derived from the ListenerSet name,
326+
# and hostnames are derived from listener hostnames; httpRoute.parentRefs and
327+
# httpRoute.hostnames are unused.
328+
listenerSet:
329+
# If `true`, a ListenerSet resource is created alongside the HTTPRoute
330+
enabled: false
331+
# Additional ListenerSet labels
332+
labels: {}
333+
# ListenerSet annotations
334+
annotations: {}
335+
# The Gateway this ListenerSet attaches to
336+
parentRef:
337+
name: gateway
338+
# namespace: envoy-gateway-system
339+
# Listeners to attach to the Gateway. Passed through as-is.
340+
# Listener hostnames are used to populate the HTTPRoute hostnames field.
341+
listeners: []
342+
# - name: http
343+
# hostname: keycloak.example.com
344+
# port: 80
345+
# protocol: HTTP
346+
# allowedRoutes:
347+
# namespaces:
348+
# from: Same
349+
322350
# HTTPRoute for console only (/auth/admin)
323351
console:
324352
# If `true`, an HTTPRoute is created for console path only

0 commit comments

Comments
 (0)