Difference between container restart due to liveness problems or due to stop request

12/2/2016

I am working with Kubernetes and a pod is composed by different containers.

I need to apply different behaviours when two specific events happen:

  1. a container (for whatever reason) have problems and need to be restarted. This happens when liveness probe fails
  2. a pod is scheduled to be stopped. For example I am rolling out a new version and kubernetes terminates the previous one and spin up the new one

From what I understood in both the cases kubernetes invokes the preStop hook and sends a SIGTERM, so it's impossible for me to understand in which of the two situations I am. Is that right? Am I missing something?

Thanks

-- Michele Orsi
docker
docker-container
kubernetes
kubernetes-health-check

0 Answers