Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Kubernetes, why does readinessProbe have the option periodSeconds?

I understand what a readinessProbe does, but I don't see why it should have a periodSeconds. Once it's determined that the pod is ready, it should stop checking. Wouldn't checking periodically then be up to the livenessProbe? Or am I missing something?

like image 966
sffortytwo Avatar asked Nov 15 '25 15:11

sffortytwo


2 Answers

Readiness probes determine whether or not a container is ready to serve requests. If the readiness probe returns a failed state, then Kubernetes removes the IP address for the container from the endpoints of all Services.

We use readiness probes to instruct Kubernetes that a running container should not receive any traffic. This is useful when waiting for an application to perform time-consuming initial tasks, such as establishing network connections, loading files, and warming caches.

The readiness probe is configured in the spec.containers.readinessprobe attribute of the pod configuration.

This periodSeconds field specifies that the kubelet should perform a readiness probe for every “x” seconds that is mentioned in the yaml. This Specifies the frequency of the checks to the readiness probe to check. Default to 10 seconds. Minimum value is 1.

like image 140
Hemanth Kumar Avatar answered Nov 18 '25 19:11

Hemanth Kumar


ReadinesProbe and livenessProbe serve for different purposes.

ReadinessProbe checks if a service is ready to serve requests. If the readinessProbe fails, the container will be taken out of service for as long as the probe fails. If the readinessProbe reports up again, the container will be taken back into service again and receive requests.

In contrast, if the livenessProbe fails, it will be considered as not recoverable and the container will be terminated and restarted.

For both, periodSeconds makes sense. Even for the livenessProbe, when failure is considered only after X consecutive failed checks.

like image 40
user2311578 Avatar answered Nov 18 '25 19:11

user2311578



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!