From 655ac7ed08ff1ad6dd909d2eaa0f2c505dfcb1de Mon Sep 17 00:00:00 2001 From: spwoodcock Date: Mon, 2 Feb 2026 21:21:53 +0000 Subject: [PATCH] fix: helm chart, a few fixes to gateway and httroute after prod testing --- chart/templates/gateway.yaml | 9 +++++++-- chart/templates/httproute.yaml | 33 ++++++++++++++++++++++++--------- chart/values.yaml | 14 +++++++++----- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/chart/templates/gateway.yaml b/chart/templates/gateway.yaml index b43028f..9914d0c 100644 --- a/chart/templates/gateway.yaml +++ b/chart/templates/gateway.yaml @@ -1,9 +1,14 @@ {{- if .Values.gateway.enabled -}} +{{- $gatewayName := .Values.gateway.name -}} +{{- if not $gatewayName -}} +{{- $gatewayName = printf "%s-gateway" (include "chart.fullname" .) -}} +{{- end -}} +{{- $gatewayNs := default .Release.Namespace .Values.gateway.namespace -}} apiVersion: gateway.networking.k8s.io/v1 kind: Gateway metadata: - name: {{ default (include "chart.fullname" .) .Values.gateway.name }} - namespace: {{ default .Release.Namespace .Values.gateway.namespace }} + name: {{ $gatewayName }} + namespace: {{ $gatewayNs }} labels: {{- include "chart.labels" . | nindent 4 }} {{- with .Values.gateway.annotations }} diff --git a/chart/templates/httproute.yaml b/chart/templates/httproute.yaml index 38a527a..5d656c8 100644 --- a/chart/templates/httproute.yaml +++ b/chart/templates/httproute.yaml @@ -1,7 +1,14 @@ {{- if .Values.httpRoute.enabled -}} {{- $fullName := include "chart.fullname" . -}} {{- $svcPort := .Values.service.port -}} -{{- $defaultGatewayName := (default $fullName .Values.gateway.name) -}} +{{- $defaultGatewayName := .Values.gateway.name -}} +{{- if not $defaultGatewayName -}} +{{- $defaultGatewayName = printf "%s-gateway" $fullName -}} +{{- end -}} +{{- $defaultGatewayNs := .Release.Namespace -}} +{{- if .Values.gateway.enabled -}} +{{- $defaultGatewayNs = default .Release.Namespace .Values.gateway.namespace -}} +{{- end -}} apiVersion: gateway.networking.k8s.io/v1 kind: HTTPRoute metadata: @@ -14,13 +21,15 @@ metadata: {{- end }} spec: parentRefs: + {{- if .Values.httpRoute.parentRefs }} {{- range $ref := .Values.httpRoute.parentRefs }} - name: {{ default $defaultGatewayName $ref.name | quote }} + {{- $refNs := $ref.namespace | default $defaultGatewayNs -}} + namespace: {{ $refNs | quote }} {{- with $ref.sectionName }} sectionName: {{ . | quote }} - {{- end }} - {{- with $ref.namespace }} - namespace: {{ . | quote }} + {{- else }} + sectionName: "http" {{- end }} {{- with $ref.kind }} kind: {{ . | quote }} @@ -29,20 +38,26 @@ spec: group: {{ . | quote }} {{- end }} {{- end }} + {{- else }} + # Default parentRef when parentRefs is empty or not set + - name: {{ $defaultGatewayName | quote }} + namespace: {{ $defaultGatewayNs | quote }} + sectionName: "http" + {{- end }} {{- with .Values.httpRoute.hostnames }} hostnames: {{- toYaml . | nindent 4 }} {{- end }} rules: {{- range .Values.httpRoute.rules }} - {{- with .matches }} - - matches: + - {{- with .matches }} + matches: {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .filters }} + {{- end }} + {{- with .filters }} filters: {{- toYaml . | nindent 8 }} - {{- end }} + {{- end }} backendRefs: - name: {{ $fullName }} port: {{ $svcPort }} diff --git a/chart/values.yaml b/chart/values.yaml index b534067..9f5fa18 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -37,21 +37,25 @@ ingress: # Gateway API (optional) gateway: enabled: false - name: "" # default: release fullname - namespace: "" # default: release namespace + name: "" # default: release fullname + "-gateway" suffix + namespace: "" # to override the namespace annotations: {} gatewayClassName: "" # required when enabled=true listeners: - name: http protocol: HTTP port: 80 + allowedRoutes: + namespaces: + from: Same # Allow routes from the same namespace httpRoute: enabled: false annotations: {} - parentRefs: - - name: "" # default: gateway.name (if set) else release fullname - sectionName: http + # parentRefs: # Omit entirely to use default (auto-references gateway in same namespace) + # - name: "" # default: gateway.name or {release-name}-gateway + # namespace: "" # to override the namespace + # sectionName: "http" hostnames: - bentopdf.local rules: