fix: use .Capabilities.APIVersions.Has in Ingress template

Signed-off-by: chgl <chgl@users.noreply.github.com>
This commit is contained in:
chgl 2021-05-18 22:44:33 +02:00
parent ad848facd6
commit f7f8626ae4
2 changed files with 7 additions and 25 deletions

View file

@ -86,29 +86,11 @@ Create the name of the controller service account to use
Return the appropriate apiVersion for ingress
*/}}
{{- define "argo-workflows.ingress.apiVersion" -}}
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.Version -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" .Capabilities.KubeVersion.GitVersion -}}
{{- else if semverCompare "<1.19-0" .Capabilities.KubeVersion.Version -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end -}}
{{- end -}}
{{/*
Return the appropriate service layout for ingress
*/}}
{{- define "argo-workflows.ingress.service" -}}
{{- if semverCompare "<1.19-0" .kubeVersion -}}
- backend:
serviceName: {{ .serviceName }}
servicePort: {{ .servicePort }}
{{- else -}}
- backend:
service:
name: {{ .serviceName }}
port:
number: {{ .servicePort }}
pathType: ImplementationSpecific
{{- end -}}
{{- end -}}

View file

@ -19,7 +19,7 @@ metadata:
{{- toYaml .Values.server.ingress.labels | nindent 4 }}
{{- end }}
spec:
{{- if eq (include "argo-workflows.ingress.apiVersion" $) "networking.k8s.io/v1" }}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
{{- with .Values.server.ingress.ingressClassName }}
ingressClassName: {{ . }}
{{- end }}
@ -35,11 +35,11 @@ spec:
{{- end }}
{{- range $p := $paths }}
- path: {{ $p }}
{{- if eq (include "argo-workflows.ingress.apiVersion" $) "networking.k8s.io/v1" }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
pathType: Prefix
{{- end }}
backend:
{{- if eq (include "argo-workflows.ingress.apiVersion" $) "networking.k8s.io/v1" }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
service:
name: {{ $serviceName }}
port:
@ -62,11 +62,11 @@ spec:
{{- end }}
{{- range $p := $paths }}
- path: {{ $p }}
{{- if eq (include "argo-workflows.ingress.apiVersion" $) "networking.k8s.io/v1" }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
pathType: Prefix
{{- end }}
backend:
{{- if eq (include "argo-workflows.ingress.apiVersion" $) "networking.k8s.io/v1" }}
{{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/Ingress" }}
service:
name: {{ $serviceName }}
port: