Skip to content

Commit

Permalink
Add PodDisruptionBudget Kind when checking for existing versions (#923)
Browse files Browse the repository at this point in the history
Checking for existing version using just "policy/v1" doesn't work when running helm template,
and as a result helm will generate a version of PodDisruptionBudget that is not supported by the cluster 
(see cortexproject/cortex-helm-chart#277).

The workaround is to add Kind to the '.Capabilities.APIVersions.Has' check so that 'helm template' will generate the right version of the PodDisruptionBudget resource.
  • Loading branch information
mvnarsing authored Jan 10, 2022
1 parent 90b61a7 commit 6e70d2d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/consul/templates/server-disruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- if (and .Values.server.disruptionBudget.enabled (or (and (ne (.Values.server.enabled | toString) "-") .Values.server.enabled) (and (eq (.Values.server.enabled | toString) "-") .Values.global.enabled))) }}
# PodDisruptionBudget to prevent degrading the server cluster through
# voluntary cluster changes.
{{- if .Capabilities.APIVersions.Has "policy/v1" }}
{{- if .Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" }}
apiVersion: policy/v1
{{- else }}
apiVersion: policy/v1beta1
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/test/unit/server-disruptionbudget.bats
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ load _helpers
cd `chart_dir`
local actual=$(helm template \
-s templates/server-disruptionbudget.yaml \
--api-versions 'policy/v1' \
--api-versions 'policy/v1/PodDisruptionBudget' \
. | tee /dev/stderr |
yq -r '.apiVersion' | tee /dev/stderr)
[ "${actual}" = "policy/v1" ]
Expand Down

0 comments on commit 6e70d2d

Please sign in to comment.