Skip to content

Commit

Permalink
Fix apiVersion for PodDisruptionBudget in k8s v1.21+
Browse files Browse the repository at this point in the history
  • Loading branch information
nepalez committed Jun 18, 2022
1 parent 9c6ae59 commit 4e85e82
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 14 additions & 0 deletions imgproxy/templates/_versions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
Expand Down
6 changes: 4 additions & 2 deletions imgproxy/templates/pod-disruption-budget.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4e85e82

Please sign in to comment.