Skip to content

Commit

Permalink
added pdb version detection (#260)
Browse files Browse the repository at this point in the history
* 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 <cai19930303@gmail.com>

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.
  • Loading branch information
yuweisung committed Oct 19, 2022
1 parent 89f28bc commit 816d88c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions charts/pulsar/templates/bookkeeper-pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
5 changes: 5 additions & 0 deletions charts/pulsar/templates/broker-pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
5 changes: 5 additions & 0 deletions charts/pulsar/templates/proxy-pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
5 changes: 5 additions & 0 deletions charts/pulsar/templates/zookeeper-pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down

0 comments on commit 816d88c

Please sign in to comment.