Support policy/v1 for PodDisruptionBudget for v1.21+

Remove warning of policy/v1beta1 deprecation
```
Warning: policy/v1beta1 PodDisruptionBudget is deprecated in v1.21+, unavailable in v1.25+; use policy/v1 PodDisruptionBudget
```

Reference:
- https://kubernetes.io/docs/reference/using-api/deprecation-guide/#poddisruptionbudget-v125

Signed-off-by: guessi <guessi@gmail.com>
This commit is contained in:
guessi 2022-05-15 15:50:11 +08:00
parent a13c59c243
commit b57d917632
3 changed files with 14 additions and 2 deletions

View File

@ -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

View File

@ -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.
*/}}

View File

@ -1,5 +1,5 @@
{{- if .Values.podDisruptionBudget -}}
apiVersion: policy/v1beta1
apiVersion: {{ template "podDisruptionBudget.apiVersion" . }}
kind: PodDisruptionBudget
metadata:
labels: