Skip to content

Commit 48d3848

Browse files
authored
feat: Add default rules for API, SSE, and frontend HTTPRoutes (#522)
1 parent d3b2aed commit 48d3848

4 files changed

Lines changed: 34 additions & 4 deletions

File tree

charts/flagsmith/templates/httproute-api.yaml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,25 @@ spec:
2323
hostnames:
2424
{{- toYaml . | nindent 4 }}
2525
{{- end }}
26-
# TODO: add default rules for /api/, /health/, /admin/, /static/admin/
2726
rules:
27+
{{- if .Values.gateway.api.rules }}
2828
{{- toYaml .Values.gateway.api.rules | nindent 4 }}
29+
{{- else }}
30+
- matches:
31+
- path:
32+
type: PathPrefix
33+
value: /api/
34+
- path:
35+
type: PathPrefix
36+
value: /health/
37+
- path:
38+
type: PathPrefix
39+
value: /admin/
40+
- path:
41+
type: PathPrefix
42+
value: /static/admin/
43+
backendRefs:
44+
- name: {{ $fullName }}-api
45+
port: {{ $svcPort }}
46+
{{- end }}
2947
{{- end }}

charts/flagsmith/templates/httproute-frontend.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@ spec:
3131
- path:
3232
type: PathPrefix
3333
value: /
34+
backendRefs:
35+
- name: {{ $fullName }}-frontend
36+
port: {{ $svcPort }}
3437
{{- end }}
3538
{{- end }}

charts/flagsmith/templates/httproute-sse.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,16 @@ spec:
2323
hostnames:
2424
{{- toYaml . | nindent 4 }}
2525
{{- end }}
26-
# TODO: add default rule for /
2726
rules:
27+
{{- if .Values.gateway.sse.rules }}
2828
{{- toYaml .Values.gateway.sse.rules | nindent 4 }}
29+
{{- else }}
30+
- matches:
31+
- path:
32+
type: PathPrefix
33+
value: /
34+
backendRefs:
35+
- name: {{ $fullName }}-sse
36+
port: {{ $svcPort }}
37+
{{- end }}
2938
{{- end }}

charts/flagsmith/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,13 +548,13 @@ gateway:
548548
enabled: false
549549
parentRefs: []
550550
hostnames: []
551-
# rules defines routing rules. No defaults — must be provided by the user.
551+
# rules defines routing rules. If empty, defaults to /api/, /health/, /admin/, /static/admin/ routing to the API service.
552552
rules: []
553553
sse:
554554
enabled: false
555555
parentRefs: []
556556
hostnames: []
557-
# rules defines routing rules. No defaults — must be provided by the user.
557+
# rules defines routing rules. If empty, defaults to "/" routing to the SSE service.
558558
rules: []
559559

560560
jobs:

0 commit comments

Comments
 (0)