From e974d72cb353a225f3c49dd2c5a6b3c6187536ef Mon Sep 17 00:00:00 2001 From: Andy Thompson Date: Tue, 14 Jun 2022 19:00:40 +0100 Subject: [PATCH 1/3] Add configurable pathType and ingressClassName to Ingress --- chart/templates/ingress.yaml | 23 +++++++++-------------- chart/values.yaml | 3 ++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/chart/templates/ingress.yaml b/chart/templates/ingress.yaml index cc3320bf..bb005b63 100644 --- a/chart/templates/ingress.yaml +++ b/chart/templates/ingress.yaml @@ -1,6 +1,6 @@ {{- if .Values.ingress.enabled -}} {{- $fullName := include "chart.fullname" . -}} -{{- $ingressPath := .Values.ingress.path -}} +{{- $ingress := .Values.ingress -}} apiVersion: {{ include "ingress.apiVersion" . }} kind: Ingress metadata: @@ -10,36 +10,31 @@ metadata: helm.sh/chart: {{ include "chart.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- with .Values.ingress.annotations }} +{{- with $ingress.annotations }} annotations: {{ toYaml . | indent 4 }} {{- end }} spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} + {{- with (pick $ingress "ingressClassName" "tls") }} + {{- . | toYaml | nindent 2 }} {{- end }} -{{- end }} rules: {{- range .Values.ingress.hosts }} - host: {{ . | quote }} http: paths: {{- if eq "networking.k8s.io/v1" (include "ingress.apiVersion" $) }} - - path: {{ $ingressPath }} - pathType: Prefix + - path: {{ $ingress.path }} + pathType: {{ $ingress.pathType | default "ImplementationSpecific" }} backend: service: name: {{ $fullName }} port: name: http {{- else }} - - path: {{ $ingressPath }} + {{- with (pick $ingress "path" "pathType") }} + {{- . | toYaml | nindent 12 }} + {{- end }} backend: serviceName: {{ $fullName }} servicePort: http diff --git a/chart/values.yaml b/chart/values.yaml index e4623c89..87db3cf7 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -42,8 +42,9 @@ service: ingress: enabled: false - apiVersion: ~ annotations: {} + apiVersion: ~ + ingressClassName: ~ path: / pathType: ~ hosts: [] From fcaacacafcc3faa04d8d5d4951345a84dfe7cef2 Mon Sep 17 00:00:00 2001 From: Andy Thompson Date: Tue, 14 Jun 2022 19:11:31 +0100 Subject: [PATCH 2/3] Avoid defining new values if not specified --- chart/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chart/values.yaml b/chart/values.yaml index 87db3cf7..9cdcc44e 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -44,9 +44,9 @@ ingress: enabled: false annotations: {} apiVersion: ~ - ingressClassName: ~ + #ingressClassName: ~ path: / - pathType: ~ + #pathType: ~ hosts: [] tls: [] From 79322f7c1ef07cccb5cc364afd531fc6858adf6e Mon Sep 17 00:00:00 2001 From: Andy Thompson Date: Tue, 14 Jun 2022 19:15:45 +0100 Subject: [PATCH 3/3] Fix missing array dash in v1beta ingress --- chart/templates/ingress.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chart/templates/ingress.yaml b/chart/templates/ingress.yaml index bb005b63..e9382a96 100644 --- a/chart/templates/ingress.yaml +++ b/chart/templates/ingress.yaml @@ -32,7 +32,7 @@ spec: port: name: http {{- else }} - {{- with (pick $ingress "path" "pathType") }} + - {{- with (pick $ingress "path" "pathType") }} {{- . | toYaml | nindent 12 }} {{- end }} backend: