From 6e70d2df6fd5ece90a4c242a87118429e39ffaf1 Mon Sep 17 00:00:00 2001 From: Narsing Metpally Date: Mon, 10 Jan 2022 15:07:46 -0700 Subject: [PATCH] Add PodDisruptionBudget Kind when checking for existing versions (#923) 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 https://github.com/cortexproject/cortex-helm-chart/pull/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. --- charts/consul/templates/server-disruptionbudget.yaml | 2 +- charts/consul/test/unit/server-disruptionbudget.bats | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/consul/templates/server-disruptionbudget.yaml b/charts/consul/templates/server-disruptionbudget.yaml index 866698aac8..edf9c1c57f 100644 --- a/charts/consul/templates/server-disruptionbudget.yaml +++ b/charts/consul/templates/server-disruptionbudget.yaml @@ -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 diff --git a/charts/consul/test/unit/server-disruptionbudget.bats b/charts/consul/test/unit/server-disruptionbudget.bats index db6ae1bca1..eb076ac775 100755 --- a/charts/consul/test/unit/server-disruptionbudget.bats +++ b/charts/consul/test/unit/server-disruptionbudget.bats @@ -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" ]