kubectl-node-restart
is a kubectl plugin that sequentially and gracefully performs a rolling restart of Nodes within a Kubernetes cluster
- install
krew
using instructions here - run
kubectl krew update
- run
kubectl krew install node-restart
- perform rolling restart of all nodes in a cluster
kubectl node-restart [--context cluster] all
- restart only specific nodes selected through labels
kubectl node-restart --selector node-role.kubernetes.io/master
- execute a command prior to reboot labels
kubectl node-restart all --command "echo 'hello world'"
- perform a dry-run
kubectl node-restart all --dry-run
- restart node(s) without first draining
kubectl node-restart all --force
- add a delay of 120seconds between node restarts
kubectl node-restart all --sleep 120
- Pull the Alpine image from a private registry
kubectl node-restart all --registry myregistry.local/library/alpine:3.9