Reputation: 189
I want to restart a pod (that is part of a deployment), without having to restart/replace the entire deployment.
I have tried kubectl replace --force -f file.yaml
but that restarts the whole deployment. I want to just restart the current pod that is live.
Any thoughts are appreciated.
Upvotes: 9
Views: 20529
Reputation: 22874
Why not just kubectl delete pod <pod>
? It will remove your single pod and schedule new in it's place.
If rescheduling is a problem, you could try to kill the process running inside the container in pod with something like kubectl exec <pod> <container> kill 1
, but some processes might not be willing to surrender easily :)
Upvotes: 16
Reputation: 5903
Pods are ephemeral resources in Kubernetes and cannot be restarted.
If you delete a pods from a deployment Kubernetes will try to reconcile the state of the deployment by starting another pod effectively restarting your pod.
Upvotes: 4