Sobes.tech
Middle+

What is the difference between liveness probe and readiness probe?

sobes.tech AI

Answer from AI

Liveness probe and readiness probe are mechanisms in Kubernetes for checking the status of containers, but they serve different purposes:

  • Liveness probe checks if the container is alive. If the check fails, Kubernetes restarts the container. This helps automatically recover containers that are "hung" or in an incorrect state.

  • Readiness probe checks if the container is ready to accept traffic. If the check fails, the container is temporarily excluded from services (Endpoints), and traffic is not directed to it. This is useful when the container is starting up but not yet ready to handle requests.

Example: an application may have a long startup time, so the readiness probe will return false to avoid sending requests, while the liveness probe will return true to prevent restarting the container. If the application hangs, the liveness probe will trigger and restart the container.