Skip to content

Liveness Probe

In one line

A liveness probe checks if a container is still running properly; if it fails, Kubernetes restarts the container.

In simple words

A liveness probe is a Kubernetes mechanism that checks whether your container is alive and healthy. If the probe fails, Kubernetes kills and restarts the container — this is called self-healing.

This is useful for catching deadlocks, memory leaks, or other situations where the process is still running but is not functioning. Without a liveness probe, a deadlocked process would stay running forever, not serving any requests.

A liveness probe can be an HTTP request, a TCP check, or a command executed inside the container. For example, you might check /health — if it returns 200, the container is alive; if it returns non-200 or times out, Kubernetes restarts it.

Example

yaml
apiVersion: v1
kind: Pod
metadata:
  name: my-app
spec:
  containers:
    - name: my-app
      image: my-app:latest
      livenessProbe:
        httpGet:
          path: /health
          port: 8080
        initialDelaySeconds: 30
        periodSeconds: 10

This liveness probe calls /health on port 8080 every 10 seconds after an initial 30-second delay. If it fails, the container is restarted.

How it works

  1. Kubernetes calls the liveness probe at regular intervals.
  2. If the probe succeeds, the container is considered alive.
  3. If the probe fails, Kubernetes kills the container.
  4. The container restarts (according to its restartPolicy).

Common confusions

  • Confused with: Readiness Probe

    The difference: A liveness probe determines if a container should be restarted; a readiness probe determines if a container should receive traffic. A container can be alive but not ready.

Related terms

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary