Skip to content

Commit bc8e66b

Browse files
committed
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.
1 parent 35c63f9 commit bc8e66b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

deploy/kubernetes-distributed/deploy.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,19 @@ case "$CSI_PROVISIONER_TAG" in
144144
"") csistoragecapacities_api=v1alpha1;; # unchanged, assume version from YAML
145145
*) 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)
146146
esac
147-
resources=$(kubectl api-resources)
148-
if echo "$resources" | grep -q "csistoragecapacities.*storage.k8s.io/$csistoragecapacities_api"; then
149-
have_csistoragecapacity=true
150-
else
147+
get_csistoragecapacities=$(kubectl get csistoragecapacities.${csistoragecapacities_api}.storage.k8s.io 2>&1 || true)
148+
if echo "$get_csistoragecapacities" | grep -q "the server doesn't have a resource type"; then
151149
have_csistoragecapacity=false
150+
else
151+
have_csistoragecapacity=true
152+
echo "csistoragecapacities.${csistoragecapacities_api}.storage.k8s.io:"
153+
show_lines=4
154+
echo "$get_csistoragecapacities" | head -n $show_lines | sed -e 's/^/ /'
155+
if [ $(echo "$get_csistoragecapacities" | wc -l) -gt $show_lines ]; then
156+
echo " ..."
157+
fi
152158
fi
153-
echo "deploying with CSIStorageCapacity: $have_csistoragecapacity"
159+
echo "deploying with CSIStorageCapacity $csistoragecapacities_api: $have_csistoragecapacity"
154160

155161
# deploy hostpath plugin and registrar sidecar
156162
echo "deploying hostpath components"

0 commit comments

Comments
 (0)