Skip to content

Commit f75905b

Browse files
authored
Merge pull request #4299 from hxrshxz/feature/add-httproute-helm
feat: add HTTPRoute support for Gateway API via new values and template.
2 parents 78c0069 + 2c66eff commit f75905b

File tree

5 files changed

+173
-0
lines changed

5 files changed

+173
-0
lines changed

charts/headlamp/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,43 @@ ingress:
205205
- headlamp.example.com
206206
```
207207

208+
### HTTPRoute Configuration (Gateway API)
209+
210+
For users who prefer Gateway API over classic Ingress resources, Headlamp supports HTTPRoute configuration.
211+
212+
| Key | Type | Default | Description |
213+
|-----|------|---------|-------------|
214+
| httpRoute.enabled | bool | `false` | Enable HTTPRoute resource for Gateway API |
215+
| httpRoute.annotations | object | `{}` | Annotations for HTTPRoute resource |
216+
| httpRoute.labels | object | `{}` | Additional labels for HTTPRoute resource |
217+
| httpRoute.parentRefs | list | `[]` | Parent gateway references (REQUIRED when enabled) |
218+
| httpRoute.hostnames | list | `[]` | Hostnames for the HTTPRoute |
219+
| httpRoute.rules | list | `[]` | Custom routing rules (optional, defaults to path prefix /) |
220+
221+
Example HTTPRoute configuration:
222+
```yaml
223+
httpRoute:
224+
enabled: true
225+
annotations:
226+
gateway.example.com/custom-annotation: "value"
227+
labels:
228+
app.kubernetes.io/component: ingress
229+
parentRefs:
230+
- name: my-gateway
231+
namespace: gateway-namespace
232+
hostnames:
233+
- headlamp.example.com
234+
# Optional custom rules (defaults to path prefix / if not specified)
235+
rules:
236+
- matches:
237+
- path:
238+
type: PathPrefix
239+
value: /headlamp
240+
backendRefs:
241+
- name: my-headlamp
242+
port: 80
243+
```
244+
208245
### Resource Management
209246

210247
| Key | Type | Default | Description |
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{{- if .Values.httpRoute.enabled -}}
2+
{{- $fullName := include "headlamp.fullname" . -}}
3+
{{- $svcPort := .Values.service.port -}}
4+
apiVersion: gateway.networking.k8s.io/v1
5+
kind: HTTPRoute
6+
metadata:
7+
name: {{ $fullName }}
8+
namespace: {{ include "headlamp.namespace" . }}
9+
labels:
10+
{{- include "headlamp.labels" . | nindent 4 }}
11+
{{- with .Values.httpRoute.labels }}
12+
{{- toYaml . | nindent 4 }}
13+
{{- end }}
14+
{{- with .Values.httpRoute.annotations }}
15+
annotations:
16+
{{- toYaml . | nindent 4 }}
17+
{{- end }}
18+
spec:
19+
parentRefs:
20+
{{- required "A valid .Values.httpRoute.parentRefs entry is required when httpRoute.enabled is true" .Values.httpRoute.parentRefs | toYaml | nindent 4 }}
21+
{{- with .Values.httpRoute.hostnames }}
22+
hostnames:
23+
{{- toYaml . | nindent 4 }}
24+
{{- end }}
25+
rules:
26+
{{- if .Values.httpRoute.rules }}
27+
{{- toYaml .Values.httpRoute.rules | nindent 4 }}
28+
{{- else }}
29+
- matches:
30+
- path:
31+
type: PathPrefix
32+
value: /
33+
backendRefs:
34+
- name: {{ $fullName }}
35+
port: {{ $svcPort }}
36+
{{- end }}
37+
{{- end }}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Test case for HTTPRoute Gateway API configuration
2+
httpRoute:
3+
enabled: true
4+
annotations:
5+
gateway.example.com/annotation: "test"
6+
labels:
7+
app.kubernetes.io/component: ingress
8+
parentRefs:
9+
- name: my-gateway
10+
namespace: gateway-namespace
11+
hostnames:
12+
- headlamp.example.com

charts/headlamp/values.schema.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,60 @@
445445
}
446446
}
447447
},
448+
"httpRoute": {
449+
"type": "object",
450+
"description": "HTTPRoute configuration for Gateway API",
451+
"properties": {
452+
"enabled": {
453+
"type": "boolean",
454+
"description": "Enable HTTPRoute resource for Gateway API"
455+
},
456+
"annotations": {
457+
"type": "object",
458+
"description": "Annotations for HTTPRoute resource"
459+
},
460+
"labels": {
461+
"type": "object",
462+
"description": "Additional labels for HTTPRoute resource"
463+
},
464+
"parentRefs": {
465+
"type": "array",
466+
"description": "Parent references (REQUIRED when enabled - HTTPRoute will not work without this)",
467+
"items": {
468+
"type": "object",
469+
"properties": {
470+
"name": {
471+
"type": "string",
472+
"description": "Name of the parent gateway"
473+
},
474+
"namespace": {
475+
"type": "string",
476+
"description": "Namespace of the parent gateway"
477+
},
478+
"sectionName": {
479+
"type": "string",
480+
"description": "Section name of the parent gateway listener"
481+
}
482+
},
483+
"required": ["name"]
484+
}
485+
},
486+
"hostnames": {
487+
"type": "array",
488+
"description": "Hostnames for the HTTPRoute",
489+
"items": {
490+
"type": "string"
491+
}
492+
},
493+
"rules": {
494+
"type": "array",
495+
"description": "Custom routing rules (optional, defaults to path prefix /)",
496+
"items": {
497+
"type": "object"
498+
}
499+
}
500+
}
501+
},
448502
"podDisruptionBudget": {
449503
"type": "object",
450504
"properties": {

charts/headlamp/values.yaml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,39 @@ ingress:
240240
# hosts:
241241
# - chart-example.local
242242

243+
# HTTPRoute configuration for Gateway API
244+
# Please refer to https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.HTTPRoute
245+
httpRoute:
246+
# -- Enable HTTPRoute resource for Gateway API
247+
enabled: false
248+
# -- Annotations for HTTPRoute resource
249+
annotations: {}
250+
# -- Additional labels for HTTPRoute resource
251+
labels: {}
252+
# -- Parent references (REQUIRED when enabled - HTTPRoute will not work without this)
253+
# Example:
254+
# parentRefs:
255+
# - name: my-gateway
256+
# namespace: gateway-namespace
257+
parentRefs: []
258+
# -- Hostnames for the HTTPRoute
259+
# Example:
260+
# hostnames:
261+
# - headlamp.example.com
262+
hostnames: []
263+
# -- Custom routing rules (optional, defaults to path prefix /)
264+
# If not specified, a default rule routing all traffic to the service is used
265+
rules: []
266+
# Example custom rules:
267+
# rules:
268+
# - matches:
269+
# - path:
270+
# type: PathPrefix
271+
# value: /headlamp
272+
# backendRefs:
273+
# - name: "{{ .Release.Name }}-headlamp"
274+
# port: 80
275+
243276
# -- CPU/Memory resource requests/limits
244277
resources:
245278
{}

0 commit comments

Comments
 (0)