How do liveness, readiness and startup probes differ in Kubernetes?
Answer
A liveness probe asks whether a container is stuck and should be restarted. A readiness probe asks whether it should receive service traffic and can change throughout its lifetime. A startup probe protects slow initialization by delaying liveness and readiness checks until startup succeeds. Test each failure independently: readiness failure should remove traffic without an unnecessary restart, liveness failure should recover the container, and startup timing should cover the slowest credible initialization.
Strong answer includes
- distinguishes restart from traffic eligibility
- explains startup-probe protection
- tests each probe independently
Practical example
A Java service takes up to 90 seconds to warm up its cache on startup. Without a startup probe, the default liveness probe kills the pod repeatedly during warm-up because it hasn't responded yet, creating a crash loop. The team adds a startup probe with a 120-second budget, then tests it by artificially slowing startup to 100 seconds in staging and confirming the pod survives, while a separate test that makes the readiness endpoint fail confirms the pod stays alive but is pulled from the service's endpoint list until it recovers.