Kubernetes node as unavailable and reschedule
Darshana Kasthuriarachchi
Senior Technical Lead - Cloud Engineering | CKA | OCP | ITIL | MBA
To mark a Kubernetes node as unavailable and reschedule all the pods running on it, you can use the following steps
1. kubectl cordon Kubernetes02
2. kubectl drain Kubernetes02 --ignore-daemonsets --delete-emptydir-data
This safely evicts all the pods running on the node. It ensures that the pods are rescheduled to other available nodes, respecting the PodDisruptionBudget and other constraints.
3. kubectl get nodes
kubectl get pods -o wide
4. kubectl drain Kubernetes02 --ignore-daemonsets --delete-emptydir-data --force
--force: Removes pods not managed by a replication controller, replica set, job, or daemonset. Use this with caution, as it will forcibly evict unmanaged pods.