When a liveness probe reaches its failure threshold
With the default liveness settings, the next check starts within a 10-second period and two more follow. Each can fail immediately or take up to 1 second to time out. The third failure completes in an estimated 20 to 31 seconds. The model starts from a healthy streak with no check in flight and uses the periodic schedule of the Kubernetes v1.36.0 kubelet. It leaves out scheduling delays and errors that yield no probe result.
The kubelet must process that result before termination starts. A preStop hook can use the configured grace period before the runtime sends the stop signal. The runtime can forcibly kill a container that does not exit. Whether a new instance starts depends on the restart policy, and backoff can delay repeated starts. Each step can add time before you see a restart.
Startup probe failureThreshold and periodSeconds
A startup probe lets a slow application start before liveness and readiness checks begin. In kubelet v1.36.0, liveness and readiness count initialDelaySeconds from container start and also wait for observed startup success. The later condition controls when the next check can run. Enter the observed startup time to include this gate in the first-check estimate.
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 10The Kubernetes example uses 30 checks at 10-second intervals. With zero initial delay, the model puts the first check at 0 to 10 seconds, so the 30th can start at 290 seconds and time out by 301 seconds. Allow margin for your slowest expected start and for the check to succeed.
Readiness checks and Service routing
Once the app answers again, the recovery estimate includes the time to finish successThreshold successful checks. With a 10-second period and a 1-second timeout, the next check could start after 10 seconds and take 0.9 seconds to succeed. The kubelet may check sooner while the container is unready. Pod readiness also depends on other containers and readiness gates, and Pod status and Service endpoint updates take additional time to publish.
The timeout pitfall
Choose timeoutSeconds to allow for healthy responses under load. The kubelet runs one check of a probe at a time, so a timeout longer than periodSeconds can delay later checks. A shared link captures the selected probe type and its inputs.
FAQ
What does the default 20 to 31 seconds for liveness mean?
It is an estimate from the time a previously healthy app starts failing until the third failed check completes. The model assumes a periodic schedule and no check in flight when the app fails. The kubelet acts on the result later. Stopping the container and starting a replacement can add time.
What is the difference between liveness, readiness and startup probes?
A liveness or startup probe that reaches its failure threshold tells the kubelet to stop the container. The restart policy determines whether it starts another. A readiness probe changes the container’s readiness, which feeds into Pod readiness and Service routing. Liveness and readiness wait for a configured startup probe to pass.
How do I pick failureThreshold for a startup probe?
With initialDelaySeconds at 0 and periodSeconds at 10, a threshold of 24 can run its last check 230 seconds after start. For an app that can take 240 seconds, choose at least 25 and leave extra room for a check to succeed. The common failureThreshold × periodSeconds estimate assumes a full period before the first check.
Do liveness and readiness probes need initialDelaySeconds with a startup probe?
The v1.36.0 kubelet checks elapsed time since container start against initialDelaySeconds and also waits to observe startup success. Both conditions must be met. If your startup probe already covers slow startup, an initial delay of 0 on the other probes lets the first check run once the startup gate opens.
What happens after a liveness probe fails?
After a liveness failure reaches the threshold, the kubelet asks the runtime to stop the container. A preStop hook can consume its grace period, and the runtime can force termination if the container stays up. The probe’s terminationGracePeriodSeconds overrides the Pod’s if set. The restart policy governs whether a new container is started, and backoff can delay repeated attempts.
Should timeoutSeconds be shorter than periodSeconds?
A check that waits longer than periodSeconds for its timeout can delay the next one because the kubelet runs one check of a probe at a time. With periodSeconds 5 and failureThreshold 3, the upper estimate is 35 seconds at timeoutSeconds 10 and 16 seconds at timeoutSeconds 1. Allow enough time for healthy responses under load.