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 co
We use a pretty convenient command line to force re-deployment of fresh images on integration pod.
We noticed that our alpine containers all run their "sustaining" command on PID 5. Therefore, sending it a SIGTERM
signal takes the container down. imagePullPolicy
being set to Always
has the kubelet re-pull the latest image when it brings the container back.
kubectl exec -i [pod name] -c [container-name] -- kill -15 5
The whole reason for having kubernetes is so it manages the containers for you so you don't have to care so much about the lifecyle of the containers in the pod.
Since you have a deployment
setup that uses replica set
. You can delete the pod using kubectl delete pod test-1495806908-xn5jn
and kubernetes will manage the creation of a new pod with the 2 containers without any downtime. Trying to manually restart single containers in pods negates the whole benefits of kubernetes.
There are cases when you want to restart a specific container instead of deleting the pod and letting Kubernetes recreate it.
Doing a kubectl exec POD_NAME -c CONTAINER_NAME /sbin/killall5
worked for me.
(I changed the command from reboot
to /sbin/killall5
based on the below recommendations.)