Kubernetes readinessProbe initialDelaySeconds Doesn't working

1/23/2022

I try to tell to K8s that my Pod is ready by the time there is a connection to MongoDB and Redis and an Express server is on. I have configured: initialDelaySeconds: 60 but the Pod is getting ready too soon after 20s, approximately:

enter image description here

See the 21s in the above picture..

Note: even if I configure to 5s, it takes around 20s anyways.

-- Raz Buchnik
kubernetes

1 Answer

1/27/2022

I came along with this. Configuring a startupProbe before the readinessProbe fixed the issue for me.

      startupProbe:
        httpGet:
          path: /health/?startup_probe=1
          port: 3003
        initialDelaySeconds: 3
        periodSeconds: 1
        timeoutSeconds: 5
      readinessProbe:
        httpGet:
          path: /health
          port: 3003
        initialDelaySeconds: 3
        periodSeconds: 3
        timeoutSeconds: 5

Such a way fixed the issue and also makes sure that the Pod is up and running even after its ready.

Notice that I added a startup_probe param so in the startupProbe which is only one time it will make a big check against the databases and in the readinessProbe it will just check against the API without invoking databases calls.

-- Raz Buchnik
Source: StackOverflow