Skip to content

Commit

Permalink
feat(helm): add support for k8s 1.22 Ingress (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
andytson authored Jun 14, 2022
1 parent 9aeb242 commit e41d42f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
20 changes: 20 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,23 @@ Create chart name and version as used by the chart label.
{{- define "chart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "capabilities.kubeVersion" }}
{{- if .Values.global.kubeVersion -}}
{{- .Values.global.kubeVersion -}}
{{- else -}}
{{- .Capabilities.KubeVersion -}}
{{- end -}}
{{- end -}}

{{- define "ingress.apiVersion" }}
{{- if .Values.ingress.apiVersion -}}
{{- .Values.ingress.apiVersion -}}
{{- else if semverCompare "<1.14-0" (include "capabilities.kubeVersion" .) -}}
{{- print "extensions/v1beta1" -}}
{{- else if semverCompare "<1.19-0" (include "capabilities.kubeVersion" .) -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "networking.k8s.io/v1" -}}
{{- end }}
{{- end }}
12 changes: 11 additions & 1 deletion chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "chart.fullname" . -}}
{{- $ingressPath := .Values.ingress.path -}}
apiVersion: extensions/v1beta1
apiVersion: {{ include "ingress.apiVersion" . }}
kind: Ingress
metadata:
name: {{ $fullName }}
Expand Down Expand Up @@ -30,9 +30,19 @@ spec:
- host: {{ . | quote }}
http:
paths:
{{- if eq "networking.k8s.io/v1" (include "ingress.apiVersion" $) }}
- path: {{ $ingressPath }}
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
name: http
{{- else }}
- path: {{ $ingressPath }}
backend:
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
{{- end }}
5 changes: 5 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ fullnameOverride: ""

cmdArgs: ""

global:
kubeVersion: ~

server:
port: 9000
servlet:
Expand All @@ -39,8 +42,10 @@ service:

ingress:
enabled: false
apiVersion: ~
annotations: {}
path: /
pathType: ~
hosts: []
tls: []

Expand Down

0 comments on commit e41d42f

Please sign in to comment.