Skip to content

Commit 4e67d5a

Browse files
jlukenoffwslulciuc
andauthored
Update helm Ingress template to be cross-compatible with recent k8s versions (#2275)
* Update ingress template to render conditionally based on k8s version Signed-off-by: John Lukenoff <johnlukenoff@asana.com> * Extraneous end Signed-off-by: John Lukenoff <johnlukenoff@asana.com> Signed-off-by: John Lukenoff <johnlukenoff@asana.com> Co-authored-by: Willy Lulciuc <willy@datakin.com>
1 parent a346e0a commit 4e67d5a

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

chart/templates/ingress.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
{{- if .Values.ingress.enabled -}}
2+
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
3+
apiVersion: networking.k8s.io/v1
4+
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
5+
apiVersion: networking.k8s.io/v1beta1
6+
{{- else -}}
27
apiVersion: extensions/v1beta1
8+
{{- end }}
39
kind: Ingress
410
metadata:
511
name: {{ include "common.names.fullname" . }}
@@ -15,6 +21,9 @@ metadata:
1521
{{ $key }}: {{ include "common.tplvalues.render" (dict "value" $value "context" $) | quote }}
1622
{{- end }}
1723
spec:
24+
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
25+
ingressClassName: {{ .Values.ingress.className }}
26+
{{- end }}
1827
{{- if .Values.ingress.tls }}
1928
tls:
2029
{{- range .Values.ingress.tls }}
@@ -31,12 +40,32 @@ spec:
3140
http:
3241
paths:
3342
- path: /api/
43+
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
44+
pathType: Prefix
45+
{{- end }}
3446
backend:
47+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
48+
service:
49+
name: {{ include "common.names.fullname" $ }}
50+
port:
51+
name: http
52+
{{- else }}
3553
serviceName: {{ include "common.names.fullname" $ }}
3654
servicePort: http
55+
{{- end }}
3756
- path: /
57+
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
58+
pathType: Prefix
59+
{{- end }}
3860
backend:
61+
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
62+
service:
63+
name: {{ include "common.names.fullname" $ }}-web
64+
port:
65+
name: http
66+
{{- else }}
3967
serviceName: {{ include "common.names.fullname" $ }}-web
4068
servicePort: http
69+
{{- end }}
4170
{{- end }}
4271
{{- end }}

0 commit comments

Comments
 (0)