diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index 1703db6..833bf6d 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -61,3 +61,14 @@ Create the name of the service account to use {{ default "default" .Values.serviceAccount.name }} {{- end -}} {{- end -}} + +{{/* +Return supported apiVersion for poddisruptionbudget +*/}} +{{- define "policy.apiVersion" -}} +{{- if trimPrefix "v" .Capabilities.KubeVersion.Version | semverCompare "<1.21.0" -}} +{{- print "policy/v1beta1" -}} +{{- else -}} +{{- print "policy/v1" -}} +{{- end -}} +{{- end -}} diff --git a/templates/poddisruptionbudget.yaml b/templates/poddisruptionbudget.yaml index 473a2e0..1bce159 100644 --- a/templates/poddisruptionbudget.yaml +++ b/templates/poddisruptionbudget.yaml @@ -1,6 +1,6 @@ --- {{- if .Values.maxUnavailable }} -apiVersion: policy/v1beta1 +apiVersion: {{ include "policy.apiVersion" . }} kind: PodDisruptionBudget metadata: name: {{ include "varnish.fullname" . }}