From f946d8c16bc625994bc23b901e9da52f1d53842e Mon Sep 17 00:00:00 2001 From: Grant Griffiths Date: Tue, 10 Dec 2019 13:41:12 -0800 Subject: [PATCH] Only deploy snapshotclass for k8s >= 1.17 Signed-off-by: Grant Griffiths --- deploy/util/deploy-hostpath.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/deploy/util/deploy-hostpath.sh b/deploy/util/deploy-hostpath.sh index bb5148a04..4a87a757b 100755 --- a/deploy/util/deploy-hostpath.sh +++ b/deploy/util/deploy-hostpath.sh @@ -104,6 +104,7 @@ function rbac_version () { function version_gt() { versions=$(for ver in "$@"; do ver=${ver#release-}; echo ${ver#v}; done) greaterVersion=${1#"release-"}; + greaterVersion=${1#"kubernetes-"}; greaterVersion=${greaterVersion#"v"}; test "$(printf '%s' "$versions" | sort -V | head -n 1)" != "$greaterVersion" } @@ -218,6 +219,9 @@ while [ $(kubectl get pods 2>/dev/null | grep '^csi-hostpath.* Running ' | wc -l done # deploy snapshotclass -echo "deploying snapshotclass" -SNAPSHOTCLASS_PATH="${BASE_DIR}/snapshotter/csi-hostpath-snapshotclass.yaml" -kubectl apply -f $SNAPSHOTCLASS_PATH +echo "deploying snapshotclass based on snapshotter version" +snapshotter_version="$(rbac_version "${BASE_DIR}/hostpath/csi-hostpath-snapshotter.yaml" csi-snapshotter false)" +driver_version="$(basename $PWD)" +if [ version_gt $driver_version "1.16" ]; then + kubectl apply -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${snapshotter_version}/examples/kubernetes/snapshotclass.yaml" +fi