In my K8S workloads, I implement Readiness probe and Liveness probe for pods health check.
I'm wondering that should I set the interval (periodSeconds
) as low as 1 sec, as it will consume more resources, right?
Is there best practices when doing the pod health check?
Firstly, it is important to understand the difference between Liveness and Readiness. The tl;dr is: Liveness is about whether K8s should kill and restart the container, Readiness is about whether the container is able to accept requests. It is likely that you want different parameters for both.
Whether K8s takes any action based on the outcome of the probe depends on the failureThreshold
. This is the number of times in a row the probe has to fail before K8s does something. If you combine this with periodSeconds
you can tune the sensitivity of your probes.
In general you want to balance:
Here is one way of thinking about it:
periodSeconds
and smaller failureThreshold
periodSeconds
and larger failureThreashold
.