From bc8e66ba48fa0edfa63dcef9557b6bcb3d342c52 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 24 Mar 2021 17:02:46 +0100 Subject: [PATCH] deploy: fix CSIStorageCapacity check on alpha clusters "kubectl api-resources" does not list v1alpha1.storage.k8s.io even when it is enabled, presumably because it gets superseeded by v1beta1.storage.k8s.io. That means we need to go back to trying to use the resource and grepping the output. To get around "-o pipefail", the return code is explicitly ignored inside the pipe. --- deploy/kubernetes-distributed/deploy.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/deploy/kubernetes-distributed/deploy.sh b/deploy/kubernetes-distributed/deploy.sh index 022d93e49..718156d6f 100755 --- a/deploy/kubernetes-distributed/deploy.sh +++ b/deploy/kubernetes-distributed/deploy.sh @@ -144,13 +144,19 @@ case "$CSI_PROVISIONER_TAG" in "") csistoragecapacities_api=v1alpha1;; # unchanged, assume version from YAML *) csistoragecapacities_api=v1beta1;; # set, assume that it is more recent *and* a version that uses v1beta1 (https://github.com/kubernetes-csi/external-provisioner/pull/584) esac -resources=$(kubectl api-resources) -if echo "$resources" | grep -q "csistoragecapacities.*storage.k8s.io/$csistoragecapacities_api"; then - have_csistoragecapacity=true -else +get_csistoragecapacities=$(kubectl get csistoragecapacities.${csistoragecapacities_api}.storage.k8s.io 2>&1 || true) +if echo "$get_csistoragecapacities" | grep -q "the server doesn't have a resource type"; then have_csistoragecapacity=false +else + have_csistoragecapacity=true + echo "csistoragecapacities.${csistoragecapacities_api}.storage.k8s.io:" + show_lines=4 + echo "$get_csistoragecapacities" | head -n $show_lines | sed -e 's/^/ /' + if [ $(echo "$get_csistoragecapacities" | wc -l) -gt $show_lines ]; then + echo " ..." + fi fi -echo "deploying with CSIStorageCapacity: $have_csistoragecapacity" +echo "deploying with CSIStorageCapacity $csistoragecapacities_api: $have_csistoragecapacity" # deploy hostpath plugin and registrar sidecar echo "deploying hostpath components"