What is the difference between rollout restart pod and delete pod in k8s? Are they both restarting the pod?
2 Answers
In Kubernetes, the rollout restart and delete commands are used to restart or delete pods, respectively. However, they work in different ways and have different effects on the pods and the overall system.
The rollout restart command is used to restart a deployment or a replica set in Kubernetes. This means that it will replace the existing pods in the deployment or replica set with new ones, which will have the latest version of the application code and any updated configuration. This is useful for deploying updates to an application or for restarting a deployment that is not functioning properly.
On the other hand, the delete command is used to delete a pod directly, without affecting the deployment or replica set. This will remove the pod from the system and free up the resources it was using. This is useful for removing pods that are no longer needed or for troubleshooting issues with individual pods.
Overall, both the rollout restart and delete commands can be used to restart pods in Kubernetes, but they work in different ways and have different effects on the system. The rollout restart command is used to restart an entire deployment or replica set, while the delete command is used to delete individual pods.
For other folks who end up here, kubectl rollout
does not apply to pods. Per the command line help (kubectl rollout -h
):
Valid resource types include:
* deployments
* daemonsets
* statefulsets
As I write this, if you try to run a rollout restart on a pod, you will likely get an error message like this:
$ kubectl rollout restart pod test-zrdcs
error: pods "test-zrdcs" restarting is not supported
For pod resources, a delete will do what it says on the tin and attempt to delete the pod. If the pod is managed by a higher level resource (e.g. replica set or deployment) then that object may replace the deleted pod.
This is the version of kubectl
I'm using right now:
$ kubectl version --client --short
Client Version: v1.25.4