Skip to content
beginner Phase 9 · Observability

Liveness, Readiness & Startup Probes

Configure health probes for application liveness, readiness, and startup monitoring.

45m
0 problems
Topic Progress 0%

Three Probes, Three Jobs

Three Probes, Three Jobs

  • Liveness: failure restarts the container. Use it to detect hangs and deadlocks — nothing else.
  • Readiness: failure removes the pod from Service endpoints. Traffic stops; no restart.
  • Startup probe: runs until it succeeds, disabling liveness/readiness for that period — the correct tool for slow-booting apps.

A liveness endpoint that checks the database will restart healthy-during-dependency-outage containers and multiply the outage. Readiness, by contrast, is exactly where dependency checks belong: the pod keeps running but stops receiving traffic until dependencies recover.

Probe Configuration

Probe Configuration

startupProbe:
  httpGet: { path: /healthz, port: 8080 }
  failureThreshold: 30
  periodSeconds: 10        # up to 5 minutes to boot
livenessProbe:
  httpGet: { path: /live, port: 8080 }
  periodSeconds: 10
  timeoutSeconds: 1
  failureThreshold: 3
readinessProbe:
  httpGet: { path: /ready, port: 8080 }
  periodSeconds: 5
  successThreshold: 1

Handlers: httpGet (200–399 passes), tcpSocket, exec (exit 0 passes), and grpc (status OK) for gRPC servers. Defaults are period 10s, timeout 1s, failureThreshold 3, initialDelaySeconds 0 — always set them explicitly so intent is reviewable.

Pitfalls and Interview Angles

Pitfalls and Interview Angles

Restart storms. Liveness hitting a slow dependency → restarts → more load on the dependency → loop. Symptom: kubectl get pod shows climbing RestartCount with ready periods in between.

Slow starters killed. Without a startup probe, liveness begins after initialDelaySeconds — a boot that takes longer than the delay is killed repeatedly. Give the startup probe enough attempts to cover worst-case boot.

All traffic missing one pod. Readiness path wrong or successThreshold misread → pod runs but endpoints exclude it; confirm with kubectl get endpoints and kubectl describe pod.

Interview angle: state the exact effect of each probe failing, and justify your timing numbers against real boot and dependency behavior.

Quiz

1. What happens when a liveness probe fails consistently?

Question 1 options

2. A Java app takes 4 minutes to warm up and gets OOM/restart loops. What do you add?

Question 2 options

3. Pods run fine but a Service sends no traffic. Which probe explains it?

Question 3 options

Flashcards

Question

Liveness vs readiness

Answer

Liveness failure restarts the container; readiness failure only removes it from Service endpoints.

Question

Startup probe

Answer

Disables liveness/readiness until it succeeds — for slow-initializing apps; size = failureThreshold × periodSeconds.

Question

Probe handlers

Answer

httpGet (2xx/3xx), tcpSocket, exec (exit 0), grpc (OK status).

Question

Probe timing defaults

Answer

periodSeconds 10, timeoutSeconds 1, successThreshold 1, failureThreshold 3, initialDelaySeconds 0.

Revision Notes

Key Takeaways

  • 1. Separate concerns: liveness for hangs, readiness for dependency state, startup for slow boots
  • 2. A bad liveness check causes restart storms; a bad readiness check silently black-holes traffic
  • 3. Verify with RestartCount, describe events, and endpoints — not assumptions

Interview Tips

  • • Name the consequence of each probe failing before showing YAML — interviewers want the mental model
  • • Defend timing numbers: failureThreshold × periodSeconds must exceed worst-case dependency blips

Cheat Sheet

liveness → restart; readiness → endpoint membership; startup → gates both until warm. Handlers httpGet/tcp/exec/grpc. Defaults 10s/1s/3. Never check DB in liveness; verify endpoints + RestartCount.

Continue Learning