Readiness probe vs liveness probe?
Options
- They are identical, and both restart the container when they fail
- Failing readiness removes the pod from traffic; failing liveness restarts it (Correct option)
- Liveness controls the traffic; readiness restarts the container
- Both checks delete the pod from the cluster when they fail once
Answer
Readiness failing removes the pod from Service traffic; liveness failing restarts the container
Why
Kubernetes regularly calls health endpoints of your app.
- Readiness: 'can you handle requests right now?' If not (still starting, warming a cache), the Pod gets no traffic, but is not restarted.
- Liveness: 'are you still working at all?' If not (stuck, deadlocked), the container is restarted.
Don't check the database in the liveness probe: a database outage would restart all your Pods at once.
Remember
Readiness = send traffic? Liveness = restart?