Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save berndverst/66e7158126863514874a3aba024543f4 to your computer and use it in GitHub Desktop.
Save berndverst/66e7158126863514874a3aba024543f4 to your computer and use it in GitHub Desktop.
Restarting a AKS kubernetes node gracefully in one line
AKSNODE=aks-nodepool1-32072832-0; kubectl cordon $AKSNODE && kubectl drain $AKSNODE --ignore-daemonsets=true && echo "$AKSNODE restarting" && az vm restart -g MC_containergroupeast_managedkube_eastus -n $AKSNODE && sleep 10 && kubectl uncordon $AKSNODE && until [ $(kubectl get node $AKSNODE --output=json | jq -c '.status.conditions | map(select(.type == "Ready"))[0].status') = '"True"' ]; do echo "sleeping 10 seconds\n" && sleep 10; done && echo "$AKSNODE successfully restarted"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment