Skip to main content
In Kubernetes, liveness probes periodically check whether a container is still running correctly. If a probe fails, Kubernetes kills and restarts the container, restoring application availability without manual intervention.

Basic Docker Behavior

When you run an application in Docker, any crash stops the container until you restart it manually:
If the nginx process crashes:

Kubernetes Automatic Restarts

Kubernetes continuously monitors container exit codes and restarts crashed containers automatically:
Each time the container exits unexpectedly, the RESTARTS count increments. However, if an application stays running but becomes unresponsive (for example, trapped in an infinite loop), Kubernetes still considers it healthy—until you explicitly tell it how to check deeper.
Without a liveness probe, Kubernetes cannot detect hung or unresponsive applications that have not exited.

Introducing Liveness Probes

A liveness probe defines how Kubernetes determines container health. You choose one of three probe types: When a container fails its liveness probe, Kubernetes restarts it automatically.

HTTP Liveness Probe Example

Explanation:
  1. initialDelaySeconds: 15
    Waits 15 seconds before the first health check.
  2. periodSeconds: 10
    Probes every 10 seconds.
  3. failureThreshold: 3
    Restarts the container after three consecutive failures.

Additional Probe Examples

Below are more probe configurations—applicable to both liveness and readiness probes:
By leveraging these probe types, you ensure Kubernetes can detect both crashed and unresponsive containers, automatically restoring service availability.

Watch Video