I want to scale up/down the number of machines to increase/decrease the number of nodes in my Kubernetes cluster. When I add one machine, I’m able to successfully register it with Kubernetes; therefore, a new node is created as expected. However, it is not clear to me how to smoothly shut down the machine later. A good workflow would be:
- Mark the node related to the machine that I am going to shut down as unschedulable;
- Start the pod(s) that is running in the node in other node(s);
- Gracefully delete the pod(s) that is running in the node;
- Delete the node.
If I understood correctly, even kubectl drain
(discussion) doesn't do what I expect since it doesn’t start the pods before deleting them (it relies on a replication controller to start the pods afterwards which may cause downtime). Am I missing something?
How should I properly shutdown a machine?