Kubernetes - force pod restart if container fails to re-trigger init containers

11/28/2018

I found in my pod that if a container fails or is killed due to failing liveness probe, the container is restarted, but the pod is not.

This means that initContainers are not run again in a case of a crashed container.

In my case, I do need to run one of the initContainers every time the main container fails.

Is this possible? Am I missing something?

-- Eldad Assis
kubernetes

1 Answer

11/28/2018

Currently, this is simply not supported: livenessProbe is a "container level" probe and if this probe fails only the said container is restarted, not the whole Pod

Though, you'll be glad to know that this behaviour is currently being implemented on this PR: https://github.com/kubernetes/community/pull/2342.

As a workaround before it's done and you eventually update, you'd have to rethink why you really need your initContainers in the first place, and consider a different co-ordination between your pod containers (be they initContainers or not) through a shared volume or some other scenarios depending on your use case.

-- Clorichel
Source: StackOverflow