Restarting a specific pod inside a Deployment

2/21/2018

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.

-- Ramboo19
kubernetes

2 Answers

2/21/2018

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 :)

-- Radek 'Goblin' Pieczonka
Source: StackOverflow

2/21/2018

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.

-- Lukas Eichler
Source: StackOverflow