25

Kubernetes' liveness and readiness probes for pods (deployment) can be configured with this initial delay ---- meaning the probe will start after this many seconds after the container is up. If it is not specified, what is the default value? I can't seem to find it. The default value for periodSeconds is documented as 10 second.

Thanks

Etienne Neveu
  • 12,604
  • 9
  • 36
  • 59
RyanDing
  • 377
  • 1
  • 3
  • 9
  • 2
    InitialDelaySeconds is `0`. – Shahriar Feb 02 '18 at 04:02
  • If this were 0, the liveness check would easily fail as services normally take time to be live. When liveness fail, the containers will be restarted. The liveness check would fail again cause the containers to restart again. This does not seem to happen with our service where we have not set initialDelaySeconds. Our service definitely takes a few seconds to go live. – RyanDing Feb 02 '18 at 04:34
  • I searched the Kubernetes source code but could seem to find how this is handled when it is not set. – RyanDing Feb 02 '18 at 04:35
  • 2
    If it is not specified, default value is zero. Because, when json/yaml is unmarshaled into go struct, if you not set, it will be zero. – Shahriar Feb 02 '18 at 06:30
  • @RyanDing, after 0s probes will be executed 3 times after waiting for 10s. so if your app is live after 30s the liveness probe succeeds. – IPP Nerd Dec 14 '21 at 10:16

3 Answers3

44

It seems that the default value of 0 is missing from the documentation.

The health or readiness check algorithm works like this:

  1. Wait for initialDelaySeconds
  2. Perform readiness check and wait timeoutSeconds for a timeout
  3. If the number of continued successes is greater than successThreshold return success
    If the number of continued failures is greater than failureThreshold return failure
    otherwise wait periodSeconds and start a new readiness check
Spikatrix
  • 20,225
  • 7
  • 37
  • 83
Lukas Eichler
  • 5,689
  • 1
  • 24
  • 43
  • 3
    Looks like the docs link is busted. This has current with defaults: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#configure-probes – Dustin May 05 '20 at 21:17
20

Given the pace at which the project changes, I wanted to make sure the code actually confirms this.

Found a test in the public Kubernetes repo that verifies the default settings for probes:

    expectedProbe := v1.Probe{
        InitialDelaySeconds: 0,
        TimeoutSeconds:      1,
        PeriodSeconds:       10,
        SuccessThreshold:    1,
        FailureThreshold:    3,
    }

See method TestSetDefaultProbe in

https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/v1/defaults_test.go

Enrico Marchesin
  • 4,650
  • 2
  • 20
  • 15
0

Default value of initialDelaySeconds is 0 as per the current Documentation.

For Ref - Documentation

enter image description here

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
Sahil Thummar
  • 1,926
  • 16
  • 16