Skip to content

Commit a8b9a47

Browse files
committed
feat: adds gateway api httproute support
Signed-off-by: wilmarguida <[email protected]>
1 parent 88dc1b8 commit a8b9a47

File tree

3 files changed

+226
-1
lines changed

3 files changed

+226
-1
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{{- $httpRoute := .Values.httpRoute -}}
2+
{{- if $httpRoute.enabled -}}
3+
apiVersion: gateway.networking.k8s.io/v1
4+
kind: HTTPRoute
5+
metadata:
6+
name: {{ include "keycloak.fullname" . }}
7+
labels:
8+
{{- include "keycloak.labels" . | nindent 4 }}
9+
{{- range $key, $value := $httpRoute.labels }}
10+
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
11+
{{- end }}
12+
{{- with $httpRoute.annotations }}
13+
annotations:
14+
{{- toYaml . | nindent 4 }}
15+
{{- end }}
16+
spec:
17+
parentRefs:
18+
{{- with $httpRoute.parentRefs }}
19+
{{- toYaml . | nindent 4 }}
20+
{{- end }}
21+
{{- with $httpRoute.hostnames }}
22+
hostnames:
23+
{{- toYaml . | nindent 4 }}
24+
{{- end }}
25+
rules:
26+
{{- range $httpRoute.rules }}
27+
{{- with .matches }}
28+
- matches:
29+
{{- range . }}
30+
{{- if .path }}
31+
- path:
32+
type: {{ .path.type }}
33+
value: {{ tpl .path.value $ }}
34+
{{- end }}
35+
{{- else }}
36+
{{ . | toYaml | nindent 8 }}
37+
{{- end }}
38+
{{- end }}
39+
{{- with .filters }}
40+
filters:
41+
{{- toYaml . | nindent 8 }}
42+
{{- end }}
43+
backendRefs:
44+
- name: {{ include "keycloak.fullname" $ }}-http
45+
port:
46+
name: {{ $httpRoute.servicePort }}
47+
{{- end }}
48+
{{- end }}
49+
---
50+
{{- if $httpRoute.console.enabled -}}
51+
apiVersion: gateway.networking.k8s.io/v1
52+
kind: HTTPRoute
53+
metadata:
54+
name: {{ include "keycloak.fullname" . }}
55+
labels:
56+
{{- include "keycloak.labels" . | nindent 4 }}
57+
{{- range $key, $value := $httpRoute.labels }}
58+
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
59+
{{- end }}
60+
{{- range $key, $value := $httpRoute.console.labels }}
61+
{{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }}
62+
{{- end }}
63+
{{- with $httpRoute.console.annotations }}
64+
annotations:
65+
{{- toYaml . | nindent 4 }}
66+
{{- end }}
67+
spec:
68+
parentRefs:
69+
{{- with pluck "parentRefs" $httpRoute.console $httpRoute | first }}
70+
{{- toYaml . | nindent 4 }}
71+
{{- end }}
72+
{{- with pluck "hostnames" $httpRoute.console $httpRoute | first }}
73+
hostnames:
74+
{{- toYaml . | nindent 4 }}
75+
{{- end }}
76+
rules:
77+
{{- range $httpRoute.console.rules }}
78+
{{- with .matches }}
79+
- matches:
80+
{{- range . }}
81+
{{- if .path }}
82+
- path:
83+
type: {{ .path.type }}
84+
value: {{ tpl .path.value $ }}
85+
{{- end }}
86+
{{- else }}
87+
{{ . | toYaml | nindent 8 }}
88+
{{- end }}
89+
{{- end }}
90+
{{- with .filters }}
91+
filters:
92+
{{- toYaml . | nindent 8 }}
93+
{{- end }}
94+
backendRefs:
95+
- name: {{ include "keycloak.fullname" $ }}-http
96+
port:
97+
name: {{ $httpRoute.servicePort }}
98+
{{- end }}
99+
{{- end }}

charts/keycloakx/values.schema.json

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,69 @@
33
"type": "object",
44
"required": ["image"],
55
"definitions": {
6+
"httpRoute": {
7+
"type": "object",
8+
"properties": {
9+
"annotations": {
10+
"type": "object"
11+
},
12+
"enabled": {
13+
"type": "boolean"
14+
},
15+
"labels": {
16+
"type": "object"
17+
},
18+
"parentRefs": {
19+
"type": "array",
20+
"items": {
21+
"properties": {
22+
"name": {
23+
"type": "string"
24+
},
25+
"sectionName": {
26+
"type": "string"
27+
}
28+
}
29+
}
30+
},
31+
"hostnames": {
32+
"type": "array",
33+
"items": {
34+
"type": "string"
35+
}
36+
},
37+
"rules": {
38+
"type": "array",
39+
"items": {
40+
"$comment": "don't allow additionalProperties to make sure backendRefs isn't set by the user",
41+
"additionalProperties": false,
42+
"properties": {
43+
"matches": {
44+
"type": "array",
45+
"items": {
46+
"$comment": "don't allow additionalProperties, only path matcher supported",
47+
"additionalProperties": false,
48+
"properties": {
49+
"path": {
50+
"type": "object"
51+
}
52+
}
53+
}
54+
},
55+
"filters": {
56+
"type": "array"
57+
}
58+
}
59+
}
60+
}
61+
}
62+
},
663
"image": {
764
"type": "object",
8-
"required": ["repository", "tag"],
65+
"required": [
66+
"repository",
67+
"tag"
68+
],
969
"properties": {
1070
"pullPolicy": {
1171
"type": "string",
@@ -323,6 +383,22 @@
323383
},
324384
"type": "object"
325385
},
386+
"httpRoute": {
387+
"allOf": [
388+
{ "$ref": "#/definitions/httpRoute" },
389+
{
390+
"type": "object",
391+
"properties": {
392+
"servicePort": {
393+
"type": "string"
394+
},
395+
"console": {
396+
"$ref": "#/definitions/httpRoute"
397+
}
398+
}
399+
}
400+
]
401+
},
326402
"image": {
327403
"$ref": "#/definitions/image"
328404
},

charts/keycloakx/values.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,56 @@ serviceHeadless:
280280
# Add additional ports to the headless service, e. g. for admin console or exposing JGroups ports
281281
extraPorts: []
282282

283+
# -- Expose the service via gateway-api HTTPRoute
284+
# Requires Gateway API resources and suitable controller installed within the cluster
285+
# (see: https://gateway-api.sigs.k8s.io/guides/)
286+
httpRoute:
287+
# HTTPRoute enabled.
288+
enabled: false
289+
# Additional HTTPRoute labels
290+
labels: {}
291+
# HTTPRoute annotations.
292+
annotations: {}
293+
# The Service port targeted by the HTTPRoute
294+
servicePort: http
295+
# Which Gateways this Route is attached to.
296+
parentRefs:
297+
- name: gateway
298+
sectionName: http
299+
# namespace: default
300+
# Hostnames matching HTTP header.
301+
hostnames:
302+
- chart-example.local
303+
# List of rules and filters applied.
304+
rules:
305+
- matches:
306+
- path:
307+
type: PathPrefix
308+
value: '{{ tpl .Values.http.relativePath $ | trimSuffix "/" }}/'
309+
310+
# HTTPRoute for console only (/auth/admin)
311+
console:
312+
# If `true`, an HTTPRoute is created for console path only
313+
enabled: false
314+
# Additional HTTPRoute labels
315+
labels: {}
316+
# HTTPRoute annotations.
317+
annotations: {}
318+
# Which Gateways this Route is attached to.
319+
parentRefs:
320+
- name: gateway
321+
sectionName: http
322+
# namespace: default
323+
# Hostnames matching HTTP header.
324+
hostnames:
325+
- chart-example.local
326+
# List of rules and filters applied.
327+
rules:
328+
- matches:
329+
- path:
330+
type: PathPrefix
331+
value: '{{ tpl .Values.http.relativePath $ | trimSuffix "/" }}/admin'
332+
283333
ingress:
284334
# If `true`, an Ingress is created
285335
enabled: false

0 commit comments

Comments
 (0)