Kubernetes : InitContainer that takes more than 5 minutes to finish never ends and get restarted

9/15/2020

At the very beginning of some of my statefulSets, one of my initContainers requieres to do a lot of operations.

It is not a problem at all. All those tasks are optimized to takes just some second. The problem comes when it detects that it is an initialization from scratch. If so, it needs to download a database snapshot from a repository and put it in place in the database volume. All that operation takes more than 7-8 minutes.It is a StatefulSet so it is done only at the very beginning as the volume is configured to persist. 

The problem here is that the initContainer doesn't finish and get "restarted" (just marked as failed as the runtime exceeded 5 minutes or so). How can I raise that time to allow the initContainer to finish?  To be honest, I am not sure if it is a specific timeout/max_runtime value assigned to the initContainer or globally to the pod initialization. I have been looking around for hours but don't manage to find what exactly is causing this. I assumed it could be something to be set or reconfigured in the kubelet but I couldn't find anything there. Please, help...

-- Nullzone
kubernetes
kubernetes-statefulset

2 Answers

9/15/2020

The nodes they have a --pod-eviction-timeout set to 5 minutes if you will increase this value your pod will no longer restart after 5 minutes.

You can check more here: Keycloak docs and here Keycloak docs - kube controller manager

-- Edwin
Source: StackOverflow

9/15/2020

hye,

the default is 5 minutes and you can adjust it to your needs by modifying the value in --pod-eviction-timeout.

let me know if it works. :)

-- tpaz1
Source: StackOverflow