Skip to content

Commit

Permalink
Merge pull request kubernetes#4888 from guessi/support-policy-v1
Browse files Browse the repository at this point in the history
[Helm] Support policy/v1 for PodDisruptionBudget for v1.21+
  • Loading branch information
k8s-ci-robot authored May 17, 2022
2 parents a8a311a + b57d917 commit 128bfa5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/cluster-autoscaler/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ name: cluster-autoscaler
sources:
- https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler
type: application
version: 9.18.0
version: 9.18.1
12 changes: 12 additions & 0 deletions charts/cluster-autoscaler/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ Return the appropriate apiVersion for podsecuritypolicy.
{{- end -}}
{{- end -}}

{{/*
Return the appropriate apiVersion for podDisruptionBudget.
*/}}
{{- define "podDisruptionBudget.apiVersion" -}}
{{- $kubeTargetVersion := default .Capabilities.KubeVersion.GitVersion .Values.kubeTargetVersionOverride }}
{{- if semverCompare "<1.21-0" $kubeTargetVersion -}}
{{- print "policy/v1beta1" -}}
{{- else -}}
{{- print "policy/v1" -}}
{{- end -}}
{{- end -}}

{{/*
Return the service account name used by the pod.
*/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/cluster-autoscaler/templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.podDisruptionBudget -}}
apiVersion: policy/v1beta1
apiVersion: {{ template "podDisruptionBudget.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
labels:
Expand Down

0 comments on commit 128bfa5

Please sign in to comment.