Kubernetes - Readiness Probe execution after container started
Asked Answered
S

2

7

Is there a way to prevent readiness probe from execution once container has successfully started? I suppose that liveness probe should be enough to monitor container health.

Selfabnegation answered 1/6, 2017 at 13:45 Comment(0)
U
10

The readiness and liveness probes serve slightly different purposes.

The readiness probe controls whether the pod IP is included in the list of endpoints for a service, and so also whether a target for a route when it is exposed via an external URL.

The liveness probe determines whether a pod is still running normally or whether it should be restarted.

Technically an application could still be running fine, but is perhaps backlogged, and so you want to use the readiness probe to temporarily remove it from the set of endpoints for a service to avoid further requests being routed its way and simply being blocked in the request queue for that specific pod when another pod could handle it.

So I personally would agree the duplication seems strange, but it is that way so the different situations can be distinguished.

Unmannered answered 1/6, 2017 at 19:57 Comment(1)
To add on top of Graham's answer: - the liveness response should be implemented to make sure the app is working at all. That's why the liveness probe should not point to a static file (unless that's a static-only file server). Remember the pod is getting killed and replaced with a new one if the liveness probe failure threshold is met. - the readiness response should check if the application is ready to handle another request. It can be as simple as making a basic DB query, or as smart as checking the resources consumption. Failure never kills the pod, just gives it time to recover.Innuendo
N
1

This problem should be now addressed with Startup probes.

The startup probe is called during startup and is used to determine when the container is ready to accept requests. If a startup probe is configured, the liveness and readiness checks are disabled until the startup probe succeeds.

Startup probes can be set at an aggressive pace to ensure that your application is available as soon as possible.

Readiness probe can be set at a less aggressive pace to handle "backlog" like situations mentioned in the accepted answer.

And Liveness probe when you need a pod restart.

Niven answered 14/8, 2022 at 14:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.