4

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?

1 Answer 1

4

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.

2
  • If you need to run specific commands everytime container restarts. You can use postStart Command to handle that Nov 28, 2018 at 19:47
  • I understand. I think I have a valid requirement. I want to create something temporary in my initContainer that is used and discarded by the main container. But has to be repeated if the main container fails (restarted). Doing this with a side car container seems impossible... Nov 29, 2018 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.