Restart Deployment or StatefulSets to Redistribute Pods across Nodes
The document explains how to redistribute pods across nodes by restarting deployment or StatefulSets.
While using Kubernetes, it may be necessary to redistribute pods across nodes to balance the load, apply updates, or manage resource usage. One way to achieve this is to restart the deployment or statefulsets, which will terminate the current pods and create new ones, causing them to be rescheduled across the available nodes.
The steps to accomplish this task are given below.
Prerequisites
You need
kubectl
installed and configured to access your Kubernetes cluster.Ensure you have the necessary permissions to manage deployments and statefulsets in your cluster.
Procedure
Determine the name of the deployment or statefulset you want to restart. You can list them using command below.
To restart a deployment, you can use the
kubectl rollout restart
command. This will update the deployment's pods to the latest state and cause them to be rescheduled.Restarting a statefulset is slightly different. You need to update the annotation to trigger a restart.
After restarting the deployment or statefulset, you should verify that the pods are being redistributed and running correctly.
Check the status of the pods and ensure they are running on different nodes as expected.
Last updated