Skip to main content
All probe fields are the same as readiness probes. The only difference is using the livenessProbe field instead of readinessProbe.

What are liveness probes?

Liveness probes determine whether a container is alive. If the probe fails, kubelet restarts the container. This is useful when a container is running but the application inside is no longer responding — for example, an API server that is stuck but whose process has not exited. A successful probe means the container is healthy. A failed probe triggers a container restart. Probe types:

HTTP

Sends an HTTP GET request to the container. A 2xx or 3xx response is healthy.

TCP

Opens a TCP socket to the container. A successful connection is healthy.

exec

Runs a command inside the container. An exit code of 0 is healthy.

Usage

liveness-probes.yaml
apiVersion: v1
kind: Pod
metadata:
  name: sample-pod
spec:
  containers:
    - name: web-app
      image: webapp
      livenessProbe:
        httpGet:
          path: /api/v1/health
          port: 8000
        initialDelaySeconds: 5 # wait before performing the 1st probe
        periodSeconds: 3       # how often to perform the probe
        failureThreshold: 5    # restart after this many consecutive failures (default 3)

Key probe fields

FieldDescription
initialDelaySecondsSeconds to wait after the container starts before the first probe
periodSecondsHow often the probe is performed
failureThresholdNumber of consecutive failures before the container is restarted (default: 3)

Build docs developers (and LLMs) love