Skip to content

Commit

Permalink
Remove stash crds before uninstalling operator (#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha authored Apr 30, 2018
1 parent b531906 commit eeca55c
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions hack/deploy/stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit eeca55c

Please sign in to comment.