Skip to content
Loopedin Labs

Kubernetes probes

Three probes, three different jobs. Mix them up and the probes cause the outage.

Mini Rush · practice

Three questions before you read

Guessing first makes the answers stick. No sign-in.

Each probe answers a different question. Get them wrong and healthy pods get restarted.

Three probes, three jobs

ProbeQuestion it answersOn failure
startupProbeHas the app finished booting?the container is killed and restarted
livenessProbeIs the process stuck beyond repair?the container is restarted
readinessProbeShould it receive traffic right now?the pod stops receiving Service traffic, with no restart

While a startup probe is configured and hasn't succeeded, the kubelet runs neither the liveness nor the readiness probe. After that, liveness and readiness run on their own schedules for the pod's whole life.

Defaults worth knowing

FieldDefault
initialDelaySeconds0
periodSeconds10
timeoutSeconds1
failureThreshold3
successThreshold1 (must be 1 for liveness and startup)

A 1-second timeout is tight for an endpoint that touches disk or a database. A slow probe counts as a failure.

A sane setup

startupProbe:
  httpGet: { path: /livez, port: 8080 }
  periodSeconds: 10
  failureThreshold: 30        # up to ~300s to boot
livenessProbe:
  httpGet: { path: /livez, port: 8080 }   # process-only check
  periodSeconds: 10
  failureThreshold: 3
readinessProbe:
  httpGet: { path: /readyz, port: 8080 }  # can it serve a request now?
  periodSeconds: 5
  failureThreshold: 2

Probe types are httpGet (any status from 200 to 399 passes), tcpSocket, exec (exit code 0 passes) and grpc.

Debug commands

kubectl describe pod <pod>      # Events: 'Liveness probe failed', 'Readiness probe failed'
kubectl get pod <pod> -o jsonpath='{.status.containerStatuses[*].restartCount}'
kubectl get endpointslices -l kubernetes.io/service-name=<svc>
kubectl exec <pod> -- wget -qO- http://127.0.0.1:8080/readyz

If Events show Liveness probe failed and then Killing, the kubelet restarted the container because of the probe. The app didn't crash on its own.

Gotchas

  • The probe connects to the pod IP, so an app bound to 127.0.0.1 fails httpGet and tcpSocket probes.
  • Under CPU throttling, a 1-second timeoutSeconds makes a healthy app fail its probes.
  • A rolling update waits for readiness. New pods that never become Ready stall the rollout, which protects you.
  • exec probes start a process in the container on every check. Running them every second is expensive.

Common wrong fix

Deleting the liveness probe because it keeps restarting pods. That turns a visible problem into a silent one, and a deadlocked process now sits in rotation until someone notices. Find out why the probe fails: a slow boot needs a startupProbe, a slow endpoint needs a cheaper check or a longer timeout, and a dependency check belongs in readiness, not liveness.