diff --git a/imgproxy/templates/_versions.tpl b/imgproxy/templates/_versions.tpl index 195682a..3a0efe6 100644 --- a/imgproxy/templates/_versions.tpl +++ b/imgproxy/templates/_versions.tpl @@ -45,6 +45,20 @@ {{- end -}} {{- end -}} +{{/* API version of pod disrutption budget */}} +{{- define "imgproxy.versions.podDisruptionBudget" }} + {{- $kubeVersion := $.Capabilities.KubeVersion.Version }} + {{- $apiVersions := $.Capabilities.APIVersions }} + + {{- if $kubeVersion | semverCompare ">=1.21.0-0" -}} + {{- "policy/v1" -}} + {{- else if $apiVersions.Has "policy/v1" }} + {{- "policy/v1" -}} + {{- else if $apiVersions.Has "policy/v1beta1" }} + {{- "policy/v1beta1" -}} + {{- end -}} +{{- end -}} + {{/* Check if preemption policy is supported for PriorityClass. */}} {{- define "imgproxy.versions.features.priorityClassPreemptionPolicy" -}} {{- $.Capabilities.KubeVersion.Version | semverCompare ">= 1.19.0-0" }} diff --git a/imgproxy/templates/pod-disruption-budget.yaml b/imgproxy/templates/pod-disruption-budget.yaml index ad336d7..150fecb 100644 --- a/imgproxy/templates/pod-disruption-budget.yaml +++ b/imgproxy/templates/pod-disruption-budget.yaml @@ -1,6 +1,8 @@ +{{- $apiVersion := include "imgproxy.versions.podDisruptionBudget" . }} {{- with .Values.resources.podDisruptionBudget -}} -{{- if .enabled }} -apiVersion: policy/v1beta1 +{{- if (.enabled | and $apiVersion) }} +--- +apiVersion: {{ $apiVersion }} kind: PodDisruptionBudget metadata: name: {{ template "imgproxy.fullname" $ }}-pdb