Does periodSeconds in Kubernetes probe configuration count from the last probe time or the last response/failure time?

10/6/2020

For example, say I have a pod that performs a GET request for its liveness probe with a timeout of 5 seconds and a period of 10 seconds. Which of these timelines represents the timing of the probe?

The since-last-probe pattern:

0s: liveness probe initiated
5s: liveness probe times out
10s: liveness probe initiated again because 10 seconds have elapsed since the start of the last probe

Or the since-timeout pattern:

0s: liveness probe initiated
5s: liveness probe times out
15s: 10 seconds have elapsed since the timeout occurred, so the probe fires again

In the former there will always be 10 seconds between probes, but in the latter there could be anywhere from 10 to 15 seconds between probes depending on how quickly the request returns. Which method does Kubernetes use?

-- ssb
kubernetes

2 Answers

10/7/2020

Kubernetes livenessProbe works like this:

  • periodSeconds is calculated from the time when the last probe was sent
  • there are never two probes running at the same time, if the probe is not timed-out yet, a new probe waits

So, in your case (timeoutSeconds=5, periodSeconds=10), the probes will look as follows:

0s: liveness probe initiated
5s: liveness probe times out
10s: liveness probe initiated again because 10 seconds have elapsed since the start of the last probe

If you had the opposite (timeoutSeconds=10, periodSeconds=5), then the probes would look as follows:

0s: liveness probe initiated
10s: liveness probe times out
10s: liveness probe initiated again
-- RafaƂ Leszko
Source: StackOverflow

10/7/2020

As per kubernetes documentation -

The kubelet starts performing health checks 'x' seconds ( i.e. period ) after the container starts. This means that probe has passed and the period will start once u get success response from the api call itself, ultimately that means the container has started ( provided the HTTP method against endpoint mentioned in the probe has been written properly ).

For the failure cases, it is obvious that till time out it will wait for response to mark it healthy or unhealthy, then it will try for three times the same thing and will ultimately go for restart of containers if the probe fails.

-- Tushar Mahajan
Source: StackOverflow