I have a pod test-1495806908-xn5jn
with 2 containers. I'd like to restart one of them called container-test
. Is it possible to restart a single container within a pod and how? If not, how do I restart the pod?
The pod was created using a deployment.yaml
with:
kubectl create -f deployment.yaml
There was an issue in
coredns
pod, I deleted such pod byIts pod will restart automatically.
Not through
kubectl
, although depending on the setup of your cluster you can "cheat" anddocker kill the-sha-goes-here
, which will cause kubelet to restart the "failed" container (assuming, of course, the restart policy for the Pod says that is what it should do)That depends on how the Pod was created, but based on the Pod name you provided, it appears to be under the oversight of a ReplicaSet, so you can just
kubectl delete pod test-1495806908-xn5jn
and kubernetes will create a new one in its place (the new Pod will have a different name, so do not expectkubectl get pods
to returntest-1495806908-xn5jn
ever again)All the above answers have mentioned deleting the pod...but if you have many pods of the same service then it would be tedious to delete each one of them...
Therefore, I propose the following solution, restart:
1) Set scale to zero :
The above command will terminate all your pods with the name
<<name>>
2) To start the pod again, set the replicas to more than 0
The above command will start your pods again with 2 replicas.