From eeca55cfe2d28164292d647016ad9e00924f7b4b Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Mon, 30 Apr 2018 12:02:09 -0700 Subject: [PATCH] Remove stash crds before uninstalling operator (#458) --- hack/deploy/stash.sh | 53 +++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/hack/deploy/stash.sh b/hack/deploy/stash.sh index 0deb542de..384bfb018 100755 --- a/hack/deploy/stash.sh +++ b/hack/deploy/stash.sh @@ -209,31 +209,6 @@ while test $# -gt 0; do done if [ "$STASH_UNINSTALL" -eq 1 ]; then - # delete webhooks and apiservices - kubectl delete validatingwebhookconfiguration -l app=stash || true - kubectl delete mutatingwebhookconfiguration -l app=stash || true - kubectl delete apiservice -l app=stash - # delete stash operator - kubectl delete deployment -l app=stash --namespace $STASH_NAMESPACE - kubectl delete service -l app=stash --namespace $STASH_NAMESPACE - kubectl delete secret -l app=stash --namespace $STASH_NAMESPACE - # delete RBAC objects, if --rbac flag was used. - kubectl delete serviceaccount -l app=stash --namespace $STASH_NAMESPACE - kubectl delete clusterrolebindings -l app=stash - kubectl delete clusterrole -l app=stash - kubectl delete rolebindings -l app=stash --namespace $STASH_NAMESPACE - kubectl delete role -l app=stash --namespace $STASH_NAMESPACE - - echo "waiting for stash operator pod to stop running" - for (( ; ; )); do - pods=($(kubectl get pods --all-namespaces -l app=stash -o jsonpath='{range .items[*]}{.metadata.name} {end}')) - total=${#pods[*]} - if [ $total -eq 0 ] ; then - break - fi - sleep 2 - done - # https://github.com/kubernetes/kubernetes/issues/60538 if [ "$STASH_PURGE" -eq 1 ]; then for crd in "${crds[@]}"; do @@ -257,8 +232,36 @@ if [ "$STASH_UNINSTALL" -eq 1 ]; then # delete crd kubectl delete crd ${crd}.stash.appscode.com || true done + + echo "waiting 5 seconds ..." + sleep 5; fi + # delete webhooks and apiservices + kubectl delete validatingwebhookconfiguration -l app=stash || true + kubectl delete mutatingwebhookconfiguration -l app=stash || true + kubectl delete apiservice -l app=stash + # delete stash operator + kubectl delete deployment -l app=stash --namespace $STASH_NAMESPACE + kubectl delete service -l app=stash --namespace $STASH_NAMESPACE + kubectl delete secret -l app=stash --namespace $STASH_NAMESPACE + # delete RBAC objects, if --rbac flag was used. + kubectl delete serviceaccount -l app=stash --namespace $STASH_NAMESPACE + kubectl delete clusterrolebindings -l app=stash + kubectl delete clusterrole -l app=stash + kubectl delete rolebindings -l app=stash --namespace $STASH_NAMESPACE + kubectl delete role -l app=stash --namespace $STASH_NAMESPACE + + echo "waiting for stash operator pod to stop running" + for (( ; ; )); do + pods=($(kubectl get pods --all-namespaces -l app=stash -o jsonpath='{range .items[*]}{.metadata.name} {end}')) + total=${#pods[*]} + if [ $total -eq 0 ] ; then + break + fi + sleep 2 + done + echo echo "Successfully uninstalled Stash!" exit 0