Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

kubernetes

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.

like image 439
Ravexina Avatar asked Aug 07 '20 20:08

Ravexina


People also ask

What is readiness and liveness probes Kubernetes?

containers. readinessprobe attribute of the pod configuration. Liveness Probe. Liveness probes determine whether or not an application running in a container is in a healthy state. If the liveness probe detects an unhealthy state, then Kubernetes kills the container and tries to redeploy it.

What is readiness probe in Kubernetes?

A readiness probe indicates whether applications running in a container are ready to receive traffic. If so, Services in Kubernetes can send traffic to the pod, and if not, the endpoint controller removes the pod from all services.

What happens if readiness probe fails?

If the readiness probe fails, the endpoints controller removes the Pod's IP address from the endpoints of all Services that match the Pod. The default state of readiness before the initial delay is Failure . If a container does not provide a readiness probe, the default state is Success .


2 Answers

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)

like image 199
Matus Dubrava Avatar answered Oct 09 '22 22:10

Matus Dubrava


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.

like image 32
Yarden Shoham Avatar answered Oct 09 '22 22:10

Yarden Shoham