diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 74b7d0a6..23e2de27 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -364,3 +364,23 @@ Usage: {{- tpl (.value | toYaml) .context }} {{- end }} {{- end -}} + +{{/* +Return the appropriate apiVersion for ingress +*/}} +{{- define "temporal.ingress.apiVersion" -}} +{{- if semverCompare "<1.14-0" (include "temporal.kubeVersion" $) -}} +{{- print "extensions/v1beta1" -}} +{{- else if semverCompare "<1.19-0" (include "temporal.kubeVersion" $) -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "networking.k8s.io/v1" -}} +{{- end -}} +{{- end -}} + +{{/* +Return the target Kubernetes version +*/}} +{{- define "temporal.kubeVersion" -}} + {{- default .Capabilities.KubeVersion.Version }} +{{- end -}} diff --git a/templates/web-ingress.yaml b/templates/web-ingress.yaml index 594cf163..a9e48818 100644 --- a/templates/web-ingress.yaml +++ b/templates/web-ingress.yaml @@ -1,9 +1,5 @@ {{- if .Values.web.ingress.enabled -}} - {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }} -apiVersion: networking.k8s.io/v1beta1 - {{- else if .Capabilities.APIVersions.Has "extensions/v1beta1" }} -apiVersion: extensions/v1beta1 - {{- end }} +apiVersion: {{ include "temporal.ingress.apiVersion" . }} kind: Ingress metadata: name: {{ include "temporal.componentname" (list . "web") }} @@ -37,8 +33,17 @@ spec: http: paths: - path: /{{ rest $url | join "/" }} + {{ if eq (include "temporal.ingress.apiVersion" $) "networking.k8s.io/v1" }} + pathType: Prefix + backend: + service: + name: {{ include "temporal.fullname" $ }}-web + port: + number: {{ $.Values.web.service.port }} + {{ else }} backend: serviceName: {{ include "temporal.fullname" $ }}-web servicePort: {{ $.Values.web.service.port }} + {{- end}} {{- end}} {{- end }}