From c2e1263b522d594e8ab7faed601e698cf00bbeec Mon Sep 17 00:00:00 2001 From: mdan16 Date: Sun, 11 Aug 2024 11:39:00 +0000 Subject: [PATCH] Uninstall for v1.20 --- scripts/uninstall.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 1d8d2d4..c23288f 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -2,11 +2,40 @@ echo "Uninstalling synology-csi pods ..." plugin_name="csi.san.synology.com" -deploy_k8s_version="v1.19" +min_support_minor=19 +max_support_minor=20 +deploy_k8s_version="v1".$min_support_minor SCRIPT_PATH="$(realpath "$0")" SOURCE_PATH="$(realpath "$(dirname "$SCRIPT_PATH")"/../)" +parse_version(){ + ver=$(kubectl version | grep Server | awk '{print $3}') + major=$(echo "${ver##*v}" | cut -d'.' -f1) + minor=$(echo "${ver##*v}" | cut -d'.' -f2) + + if [[ "$major" != 1 ]]; then + echo "Version not supported: $ver" + exit 1 + fi + + case "$minor" in + 19|20) + deploy_k8s_version="v1".$minor + ;; + *) + if [[ $minor -lt $min_support_minor ]]; then + deploy_k8s_version="v1".$min_support_minor + else + deploy_k8s_version="v1".$max_support_minor + fi + ;; + esac + echo "Uninstall Version: $deploy_k8s_version" +} + + +parse_version kubectl delete -f "$SOURCE_PATH"/deploy/kubernetes/$deploy_k8s_version/snapshotter --ignore-not-found kubectl delete -f "$SOURCE_PATH"/deploy/kubernetes/$deploy_k8s_version --ignore-not-found -echo "End of synology-csi uninstallation." \ No newline at end of file +echo "End of synology-csi uninstallation."