From 2f587c6af1a25209659641399f15373cbadde93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Alejandro=20Marug=C3=A1n?= Date: Fri, 19 Jun 2026 20:35:34 +0200 Subject: [PATCH] feat: add Gateway API --- charts/self-learning-platform/README.md | 10 +++++ .../templates/NOTES.txt | 14 ++++++- .../templates/gateway-httproute.yaml | 40 +++++++++++++++++++ .../templates/gateway.yaml | 13 ++++++ charts/self-learning-platform/values.yaml | 38 ++++++++++++++++++ 5 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 charts/self-learning-platform/templates/gateway-httproute.yaml create mode 100644 charts/self-learning-platform/templates/gateway.yaml diff --git a/charts/self-learning-platform/README.md b/charts/self-learning-platform/README.md index d6b0ad1..0875e38 100644 --- a/charts/self-learning-platform/README.md +++ b/charts/self-learning-platform/README.md @@ -88,6 +88,16 @@ helm show values self-learning-platform/self-learning-platform | envFromFiles | list | `[]` | Load all variables from files | | envFromSecrets | object | `{}` | Variables from secrets | | fullnameOverride | string | `""` | String to fully override self-learning-platform.fullname template | +| gateway | object | `{"annotations":{},"className":"","create":false,"enabled":false,"filters":[],"hostnames":[],"labels":{},"listeners":[{"name":"http","port":80,"protocol":"HTTP"}],"parentRefs":[{"name":"","namespace":""}],"rules":[{"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]}` | Gateway API configuration (Gateway + HTTPRoute resources)
Ref: https://gateway-api.sigs.k8s.io/
Requires Gateway API CRDs installed in the cluster.
TLS is configured at the Gateway listener level, not the HTTPRoute. | +| gateway.annotations | object | `{}` | Annotations for the HTTPRoute | +| gateway.className | string | `""` | GatewayClass name — required when create is true | +| gateway.create | bool | `false` | Set to false to attach to a pre-existing Gateway via parentRefs. | +| gateway.filters | list | `[]` | Additional request/response filters | +| gateway.hostnames | list | `[]` | Hostnames to match (leave empty to match all hostnames) | +| gateway.labels | object | `{}` | Additional labels for the HTTPRoute | +| gateway.listeners | list | `[{"name":"http","port":80,"protocol":"HTTP"}]` | Gateway listeners — used only when create is true | +| gateway.parentRefs | list | `[{"name":"","namespace":""}]` | Ignored when create is true (auto-wired to the chart-managed Gateway). | +| gateway.rules | list | `[{"matches":[{"path":{"type":"PathPrefix","value":"/"}}]}]` | Route rules (backendRefs are auto-generated from service config) | | global | object | `{"imagePullSecrets":[],"imageRegistry":""}` | Global section contains configuration options that are applied to all services | | global.imagePullSecrets | list | `[]` | Specifies the secrets to use for pulling images from private registries | | global.imageRegistry | string | `""` | Specifies the registry to pull images from. Leave empty for the default registry | diff --git a/charts/self-learning-platform/templates/NOTES.txt b/charts/self-learning-platform/templates/NOTES.txt index 188393a..0fed145 100644 --- a/charts/self-learning-platform/templates/NOTES.txt +++ b/charts/self-learning-platform/templates/NOTES.txt @@ -7,7 +7,19 @@ To learn more about the release, try: $ helm status {{ .Release.Name }} -n {{ .Release.Namespace }} $ helm get all {{ .Release.Name }} -n {{ .Release.Namespace }} -{{- if .Values.ingress.enabled }} +{{- if .Values.gateway.enabled }} + +The application is accessible via Gateway API at: +{{- if .Values.gateway.hostnames }} +{{- range .Values.gateway.hostnames }} + {{ . }} +{{- end }} +{{- else }} + (HTTPRoute - no hostnames configured) +{{- end }} + (Gateway API / HTTPRoute) + +{{- else if .Values.ingress.enabled }} The application is accessible via Ingress at: {{- range .Values.ingress.hosts }} diff --git a/charts/self-learning-platform/templates/gateway-httproute.yaml b/charts/self-learning-platform/templates/gateway-httproute.yaml new file mode 100644 index 0000000..637af78 --- /dev/null +++ b/charts/self-learning-platform/templates/gateway-httproute.yaml @@ -0,0 +1,40 @@ +{{- if .Values.gateway.enabled -}} +{{- $fullName := include "self-learning-platform.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +apiVersion: gateway.networking.k8s.io/v1 +kind: HTTPRoute +metadata: + name: {{ $fullName }} + labels: + {{- include "self-learning-platform.labels" . | nindent 4 }} + {{- with .Values.gateway.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + parentRefs: + {{- if .Values.gateway.create }} + - name: {{ $fullName }}-gateway + namespace: {{ .Release.Namespace }} + {{- else }} + {{- toYaml .Values.gateway.parentRefs | nindent 4 }} + {{- end }} + {{- if .Values.gateway.hostnames }} + hostnames: + {{- toYaml .Values.gateway.hostnames | nindent 4 }} + {{- end }} + rules: + {{- range .Values.gateway.rules }} + - {{- if .matches }} + matches: + {{- toYaml .matches | nindent 8 }} + {{- end }} + {{- if .filters }} + filters: + {{- toYaml .filters | nindent 8 }} + {{- end }} + backendRefs: + - name: {{ $fullName }} + port: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/charts/self-learning-platform/templates/gateway.yaml b/charts/self-learning-platform/templates/gateway.yaml new file mode 100644 index 0000000..0979a23 --- /dev/null +++ b/charts/self-learning-platform/templates/gateway.yaml @@ -0,0 +1,13 @@ +{{- if and .Values.gateway.enabled .Values.gateway.create -}} +{{- $fullName := include "self-learning-platform.fullname" . -}} +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: {{ $fullName }}-gateway + labels: + {{- include "self-learning-platform.labels" . | nindent 4 }} +spec: + gatewayClassName: {{ required "gateway.className is required when gateway.create is true" .Values.gateway.className }} + listeners: + {{- toYaml .Values.gateway.listeners | nindent 4 }} +{{- end }} diff --git a/charts/self-learning-platform/values.yaml b/charts/self-learning-platform/values.yaml index c1e21a2..eb713a2 100644 --- a/charts/self-learning-platform/values.yaml +++ b/charts/self-learning-platform/values.yaml @@ -284,6 +284,44 @@ ingress: # hosts: # - self-learning-platform.local +# -- Gateway API configuration (Gateway + HTTPRoute resources) +#
Ref: https://gateway-api.sigs.k8s.io/ +#
Requires Gateway API CRDs installed in the cluster. +#
TLS is configured at the Gateway listener level, not the HTTPRoute. +gateway: + enabled: false + # -- Set to true to let the chart create and manage the Gateway resource. + # -- Set to false to attach to a pre-existing Gateway via parentRefs. + create: false + # -- GatewayClass name — required when create is true + className: "" + # -- Gateway listeners — used only when create is true + listeners: + - name: http + protocol: HTTP + port: 80 + # -- References to parent Gateway resources. + # -- Ignored when create is true (auto-wired to the chart-managed Gateway). + parentRefs: + - name: "" + namespace: "" + # sectionName: "" + # -- Hostnames to match (leave empty to match all hostnames) + hostnames: [] + # - self-learning-platform.local + # -- Route rules (backendRefs are auto-generated from service config) + rules: + - matches: + - path: + type: PathPrefix + value: / + # -- Additional request/response filters + filters: [] + # -- Additional labels for the HTTPRoute + labels: {} + # -- Annotations for the HTTPRoute + annotations: {} + # -- Resource limits and requests resources: requests: