What are liveness and readiness probes in Kubernetes? How do they differ?
sobes.tech AI
Answer from AI
In Kubernetes, liveness probe and readiness probe are mechanisms for checking the container's health, which help manage the pod's lifecycle.
-
Liveness probe checks if the container is alive. If the check fails, Kubernetes restarts the container. This helps recover from hangs or unresponsive states.
-
Readiness probe checks if the container is ready to accept traffic. If the check fails, the container is temporarily excluded from services so that it does not receive requests, but it is not restarted.
Differences:
- Liveness affects container restart.
- Readiness affects traffic routing.
Example: you have a web server that loads configuration at startup. Until the loading is complete, the readiness probe returns an error, and traffic is not directed to the container. If the server hangs, the liveness probe fails — the container is restarted.