Kubernetes — Liveness and Readiness Probes

Liveness and Readiness probes are used to control the health of an application running inside a Pod’s container.

Liveness Probe(container get recreated if check fails)

Suppose that a Pod is running our application inside a container, but due to some reason let’s say memory leak, cpu usage, application deadlock etc the application is not responding to our requests, and stuck in error state.

Liveness probe checks the container health as we tell it do, and if for some reason the liveness probe fails, it restarts the container.if liveness probe is giving non zero that means your application is not alive then minimum it will try three times and if it fails all three times the container will get created.

Readiness Probe(doesnt send the traffic to that pod)

In some cases we would like our application to be alive, but not serve traffic unless some conditions are met e.g, populating a dataset, waiting for some other service to be alive etc. In such cases we use readiness probe. If the condition inside readiness probe passes, only then our application can serve traffic.