Skip to content

Commit 74cb7cd

Browse files
Merge pull request #21 from Intreecom/feat/gateway-api-support
feat: added support for Gateway API (HTTPRoute)
2 parents 8a092c2 + e433856 commit 74cb7cd

2 files changed

Lines changed: 108 additions & 5 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{{- if .Values.httproute.enabled -}}
2+
---
3+
{{- $fullName := include "py-app.fullname" . -}}
4+
{{- $svcPort := .Values.service.port -}}
5+
{{- $gatewayName := required "httproute.gatewayName is required and cannot be empty" .Values.httproute.gatewayName -}}
6+
7+
apiVersion: gateway.networking.k8s.io/v1
8+
kind: HTTPRoute
9+
metadata:
10+
name: {{ $fullName }}
11+
namespace: {{ .Release.Namespace }}
12+
{{- with .Values.httproute.annotations }}
13+
annotations: {{ toYaml . | nindent 4 }}
14+
{{- end }}
15+
labels: {{- include "py-app.labels" $ | nindent 4 }}
16+
{{- with .Values.httproute.labels }}
17+
{{- toYaml . | nindent 4 }}
18+
{{- end }}
19+
spec:
20+
parentRefs:
21+
- name: {{ $gatewayName }}
22+
{{- with .Values.httproute.gatewayNamespace }}
23+
namespace: {{ . }}
24+
{{- end }}
25+
kind: Gateway
26+
group: gateway.networking.k8s.io
27+
sectionName: {{ .Values.httproute.httpsListenerName }}
28+
{{- with .Values.httproute.hostnames }}
29+
hostnames: {{ tpl (toYaml .) $ | nindent 4 }}
30+
{{- end -}}
31+
{{ range .Values.httproute.rules }}
32+
rules:
33+
- backendRefs:
34+
- name: {{ $fullName }}
35+
port: {{ $svcPort }}
36+
{{- with .filters }}
37+
filters: {{ toYaml . | nindent 8 }}
38+
{{- end }}
39+
{{- with .matches }}
40+
matches: {{ toYaml . | nindent 8 }}
41+
{{- end }}
42+
{{- end}}
43+
---
44+
{{- if .Values.httproute.httpsRedirect.enabled }}
45+
apiVersion: gateway.networking.k8s.io/v1
46+
kind: HTTPRoute
47+
metadata:
48+
name: {{ $fullName }}-https-redirect
49+
namespace: {{ .Release.Namespace }}
50+
{{- with .Values.httproute.annotations }}
51+
annotations: {{ toYaml . | nindent 4 }}
52+
{{- end }}
53+
labels: {{- include "py-app.labels" $ | nindent 4 }}
54+
{{- with .Values.httproute.labels }}
55+
{{- toYaml . | nindent 4 }}
56+
{{- end }}
57+
spec:
58+
{{- with .Values.httproute.hostnames }}
59+
hostnames: {{ tpl (toYaml .) $ | nindent 4 }}
60+
{{- end }}
61+
parentRefs:
62+
- name: {{ $gatewayName }}
63+
{{- with .Values.httproute.gatewayNamespace }}
64+
namespace: {{ . }}
65+
{{- end }}
66+
kind: Gateway
67+
group: gateway.networking.k8s.io
68+
sectionName: {{ .Values.httproute.httpListenerName }}
69+
rules:
70+
- filters:
71+
- type: RequestRedirect
72+
requestRedirect:
73+
scheme: https
74+
statusCode: 301
75+
{{- end }}
76+
{{- end }}

‎charts/py-app/values.yaml‎

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env: {}
1515

1616
# Definition of migrator jobs.
1717
#
18-
# This should
18+
# This should
1919
migrators: {}
2020
# pg:
2121
# # Job's additional annotations
@@ -48,7 +48,6 @@ probes:
4848
# httpGet:
4949
# path: /api/app/health
5050
# port: http
51-
5251

5352
externalSecrets: {}
5453
# secret-envs:
@@ -92,8 +91,7 @@ service:
9291
ingress:
9392
enabled: false
9493
className: ""
95-
annotations:
96-
{}
94+
annotations: {}
9795
# kubernetes.io/ingress.class: nginx
9896
# kubernetes.io/tls-acme: "true"
9997
hosts: []
@@ -109,6 +107,35 @@ ingress:
109107
# hosts:
110108
# - chart-example.local
111109

110+
# HTTPRoute configuration
111+
httproute:
112+
enabled: true
113+
114+
annotations: {}
115+
labels: {}
116+
117+
hostnames:
118+
- example.com
119+
httpsRedirect:
120+
enabled: true
121+
122+
# Gateway resource of following configuration has to be created beforehand.
123+
gatewayName: ""
124+
gatewayNamespace: ""
125+
httpsListenerName: example-com-https
126+
httpListenerName: example-com-http
127+
128+
rules:
129+
- matches: []
130+
# - path:
131+
# type: PathPrefix
132+
# value: /api/someplace
133+
# headers: []
134+
# queryParams: []
135+
filters: []
136+
# - type: ReplacePrefixMatch
137+
# replacePrefixMatch: /api/someotherplace
138+
112139
resources: {}
113140
# We usually recommend not to specify default resources and to leave this as a conscious
114141
# choice for the user. This also increases chances charts run on environments with little
@@ -137,4 +164,4 @@ limitRange:
137164
# cpu: 50m
138165
# memory: 500Mi
139166
# type: Container
140-
extraManifests: []
167+
extraManifests: []

0 commit comments

Comments
 (0)