Skip to content

Instantly share code, notes, and snippets.

@sheppduck
Created May 2, 2019 18:05
Show Gist options
  • Save sheppduck/1ecefd5cc7c710f9e89dd18ac722e47b to your computer and use it in GitHub Desktop.
Save sheppduck/1ecefd5cc7c710f9e89dd18ac722e47b to your computer and use it in GitHub Desktop.

Revisions

  1. sheppduck created this gist May 2, 2019.
    19 changes: 19 additions & 0 deletions sc8l_d3l3te.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/bin/bash
    # Scale DOWN all Turbonetes PODs to 0
    function turbo_stop_all_pods {
    turbo_stop_all_pods=$(kubectl get deploy -n turbonomic --no-headers=true | cut -d ' ' -f1 | xargs -I % kubectl scale --replicas=0 deployment/% -n turbonomic)
    while true; do
    if `kubectl get pods -n turbonomic | grep -v STATUS | wc -l` -gt 0 then
    echo -e "turbo_STOP_all_pods: Waiting on Turbonetes POD(s) to TERMINATE, so far: \n`kubectl get pods -n turbonomic | grep -v NAME`"
    elif
    [[ "$counter" -gt 30 ]]; then;
    echo "MAX Counter Reached! One or more PODs are stuck ##TERMINATING##, intervening to kill it/them"
    for p in $(kubectl get pods | grep Terminating | awk '{print $1}') ; do kubectl delete pod $p --grace-period=0 --force ; done
    else
    counter=$((counter++))
    echo "Counter has tried: $counter time(s), (30 - $counter) Attempts Remain!!"
    sleep 15
    fi

    done
    echo "All Turbonetes PODs are Terminated - Done waiting, exiting"