What is the role of timeoutSeconds in kubernetes liveness/readiness probes?

8/7/2020

I'm wondering what timeoutSeconds actually does in a liveness or readiness probes?

The documentation states that:

timeoutSeconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1.

No more explanation or demonstration of how to use it and what actually it does.

So what is this parameter's job and how can it be differentiated from periodSeconds?

I was lucky to find this answer but it's still fuzzy to me. Specially after I saw this diagram from here:

enter image description here

I also tried playing around with the values to find out how things work and what is the effect of this parameter but no luck as events do not seem to take place immediately.

-- Ravexina
kubernetes

2 Answers

8/7/2020

The periodSeconds specifies how often a container running within a pod will be probed (tested) and the timeoutSeconds specifies how quickly the container needs to respond to the probe.

Let's say that you have set periodSeconds to 3 and timeoutSeconds to 1. In this setup, container will be probed every 3 seconds and each time it is being probed, it has 1 second to respond otherwise it fails that one probe (even if it responds later to that probe, say in 2 seconds).

The diagram is quite precise. It tells you that nothing is happening during the initialDelaySeconds which is a time the container has before it starts being probed (so that it has enough time to start all the necessary processes). After this time expires, it starts being probed.

It successfully responds to the first probe within timeoutSeconds, then there is a delay periodSeconds before it is probed again. This time it fails to respond within timeoutSeconds and there is another periodSeconds delay and it fails again and again and then then pod is being restarted because that is how it was configured in this case (to restart after 3 consecutively failed probes, given by failureThreshold)

-- Matus Dubrava
Source: StackOverflow

8/7/2020

It's the maximum amount of seconds allowed for the (assuming you're using an HTTP readiness probe) web server to respond to the request.

-- Yarden Shoham
Source: StackOverflow