From 816d88c942e5f1d13e1f11d67708dd16aa02c388 Mon Sep 17 00:00:00 2001 From: Yuwei Sung Date: Tue, 18 Oct 2022 22:52:11 -0500 Subject: [PATCH] added pdb version detection (#260) * added pdb version detection * refresh * Update bookkeeper-pdb.yaml update the capabilities syntax * Update broker-pdb.yaml update capability syntax * Update proxy-pdb.yaml update capability version syntax * Update zookeeper-pdb.yaml update capability version syntax * Update zookeeper-pdb.yaml fix typo * Update bookkeeper-pdb.yaml Co-authored-by: Marvin Cai Fixes pod disruption budget version warning ### Motivation PDB policy api version, v1beta1 is deprecated in k8s1.21+ (not available in 1.25+). ### Modifications zookeeper-pdb, proxy-pdb, broker-pdb and bookkeepr-pdb templates are modified. If k8s api-resources container policy/v1, the *-pdb.yaml will generate respective apiVersion. ### Verifying this change - [ ] Make sure that the change passes the CI checks. --- charts/pulsar/templates/bookkeeper-pdb.yaml | 5 +++++ charts/pulsar/templates/broker-pdb.yaml | 5 +++++ charts/pulsar/templates/proxy-pdb.yaml | 5 +++++ charts/pulsar/templates/zookeeper-pdb.yaml | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/charts/pulsar/templates/bookkeeper-pdb.yaml b/charts/pulsar/templates/bookkeeper-pdb.yaml index 74e1503..3af8290 100644 --- a/charts/pulsar/templates/bookkeeper-pdb.yaml +++ b/charts/pulsar/templates/bookkeeper-pdb.yaml @@ -19,7 +19,12 @@ {{- if .Values.components.bookkeeper }} {{- if .Values.bookkeeper.pdb.usePolicy }} +# pdb version detection +{{- if semverCompare "<1.21-0" .Capabilities.KubeVersion.Version }} apiVersion: policy/v1beta1 +{{- else }} +apiVersion: policy/v1 +{{- end }} kind: PodDisruptionBudget metadata: name: "{{ template "pulsar.fullname" . }}-{{ .Values.bookkeeper.component }}" diff --git a/charts/pulsar/templates/broker-pdb.yaml b/charts/pulsar/templates/broker-pdb.yaml index c03aca6..ec7555c 100644 --- a/charts/pulsar/templates/broker-pdb.yaml +++ b/charts/pulsar/templates/broker-pdb.yaml @@ -19,7 +19,12 @@ {{- if .Values.components.broker }} {{- if .Values.broker.pdb.usePolicy }} +# pdb version detection +{{- if semverCompare "<1.21-0" .Capabilities.KubeVersion.Version }} apiVersion: policy/v1beta1 +{{- else }} +apiVersion: policy/v1 +{{- end }} kind: PodDisruptionBudget metadata: name: "{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}" diff --git a/charts/pulsar/templates/proxy-pdb.yaml b/charts/pulsar/templates/proxy-pdb.yaml index befdccc..f39970d 100644 --- a/charts/pulsar/templates/proxy-pdb.yaml +++ b/charts/pulsar/templates/proxy-pdb.yaml @@ -19,7 +19,12 @@ {{- if or .Values.components.proxy .Values.extra.proxy }} {{- if .Values.proxy.pdb.usePolicy }} +# pdb version detection +{{- if semverCompare "<1.21-0" .Capabilities.KubeVersion.Version }} apiVersion: policy/v1beta1 +{{- else }} +apiVersion: policy/v1 +{{- end }} kind: PodDisruptionBudget metadata: name: "{{ template "pulsar.fullname" . }}-{{ .Values.proxy.component }}" diff --git a/charts/pulsar/templates/zookeeper-pdb.yaml b/charts/pulsar/templates/zookeeper-pdb.yaml index 387a05a..70f88f9 100644 --- a/charts/pulsar/templates/zookeeper-pdb.yaml +++ b/charts/pulsar/templates/zookeeper-pdb.yaml @@ -20,7 +20,12 @@ # deploy zookeeper only when `components.zookeeper` is true {{- if .Values.components.zookeeper }} {{- if .Values.zookeeper.pdb.usePolicy }} +# pdb version detection +{{- if semverCompare "<1.21-0" .Capabilities.KubeVersion.Version }} apiVersion: policy/v1beta1 +{{- else }} +apiVersion: policy/v1 +{{- end }} kind: PodDisruptionBudget metadata: name: "{{ template "pulsar.fullname" . }}-{{ .Values.zookeeper.component }}"