Pods stuck in PodInitializing state indefinitely Pods stuck in PodInitializing state indefinitely kubernetes kubernetes

Pods stuck in PodInitializing state indefinitely


To try and figure this out I would run the command:

kubectl get pods - Add the namespace param if required.

Then copy the pod name and run:

kubectl describe pod {POD_NAME}

That should give you some information as to why it's stuck in the initializing state.


I think that you could miss that it is the expected behavior of the init containers. The rule is that in case of initContainers failure a Pod will not restart if restartPolicy is set to Never otherwise the Kubernetes will keep restarting it until it succeeds.

Also:

If the init container fails, the Pod in the main container never gets started, and stays in "PodInitializing" indefinitely.

According to documentation:

A Pod cannot be Ready until all Init Containers have succeeded. The ports on an Init Container are not aggregated under a service. A Pod that is initializing is in the Pending state but should have a condition Initializing set to true.

*I can see that you tried to change this behavior, but I am not sure if you can do that with CronJob, I saw examples with Jobs. But I am just theorizing, and if this post did not help you solve your issue I can try to recreate it in lab environment.


Since you have already figured out that initcontainers are meant to run to completion, successfully. If you can't get rid of init containers, what i would do in this case is to make sure that the init container ends successfully all the time. The result of the init container can be written in an emptydir volume, something like a status file, shared by both your init container and your work container. I would delegate to the work container the responsibility of deciding what to do in case the init container ends unsuccessfully.