Liveness & Readiness Probes

Difficulty: Intermediate

Question

Explain liveness, readiness and startup probes in Kubernetes. What does each one do when it fails, and how do you configure them safely?

Answer

Probes are health checks the kubelet runs against your containers. A liveness probe failing makes the kubelet restart the container; a readiness probe failing removes the Pod from Service endpoints so it stops receiving traffic, without restarting it; and a startup probe holds off the other two until a slow-starting app has finished booting.

What each probe answers

ProbeQuestion it asksAction on failureTypical check
LivenessIs the process stuck or deadlocked?Restart the containerLightweight /livez endpoint
ReadinessCan it serve traffic right now?Remove from EndpointSlices/readyz that checks warm-up and critical deps
StartupHas it finished starting?Restart if it never succeedsSame endpoint as liveness, with a long budget

Readiness keeps running for the whole life of the Pod, so a Pod can go not-ready under load or during a dependency outage and come back on its own.

Probe mechanisms and timing fields

  • Mechanisms: httpGet (2xx or 3xx is success), tcpSocket, exec (exit code 0) and grpc (GA since v1.27).
  • periodSeconds (default 10), timeoutSeconds (default 1), failureThreshold (default 3), successThreshold (default 1, must be 1 for liveness and startup), initialDelaySeconds (default 0).
  • The time a startup probe allows is roughly failureThreshold × periodSeconds. For a Java app that needs up to 2 minutes, use failureThreshold: 24 with periodSeconds: 5 instead of a large initialDelaySeconds on the liveness probe.

Why they matter during deploys

During a rolling update, Kubernetes only counts a new Pod as available once its readiness probe passes. Without one, traffic goes to Pods that are still loading caches or opening DB pools, causing 502s during every deploy. A good readiness probe is the main ingredient of zero-downtime deployments.

Common mistakes that cause outages

  • Checking dependencies in liveness. If liveness calls the database and the database blips, every Pod restarts at once and you get a cascading failure. Liveness should only check the process itself.
  • Using the same endpoint and thresholds for liveness and readiness, so a slow Pod gets killed instead of just taken out of rotation.
  • Too aggressive timeouts (1 second default) on a busy JVM, leading to restart loops under load and CrashLoopBackOff.
  • No startup probe on slow apps, so liveness kills them before they ever finish booting.
  • Readiness checking a shared dependency too strictly, which can mark all Pods not-ready and take the whole service offline when it could have degraded gracefully.
Probe lifecycle of a container. Startup gates the others; readiness controls traffic; liveness controls restarts.
  1. Container starts: Only the startup probe runs at first.
  2. Startup probe succeeds: Liveness and readiness probes begin.
  3. Readiness passes: Pod IP is added to Service endpoints.
  4. Readiness fails under load: Pod leaves rotation but keeps running.
  5. Liveness fails repeatedly: Kubelet kills and restarts the container.

Code examples

All three probes on a slow-starting Spring Boot app

containers:
  - name: orders
    image: ghcr.io/acme/orders:3.2.0
    ports:
      - containerPort: 8080
    startupProbe:
      httpGet: { path: /actuator/health/liveness, port: 8080 }
      periodSeconds: 5
      failureThreshold: 24        # up to 120s to boot
    livenessProbe:
      httpGet: { path: /actuator/health/liveness, port: 8080 }
      periodSeconds: 10
      timeoutSeconds: 2
      failureThreshold: 3         # restart after ~30s of failure
    readinessProbe:
      httpGet: { path: /actuator/health/readiness, port: 8080 }
      periodSeconds: 5
      failureThreshold: 2         # leave rotation quickly

Spring Boot Actuator exposes separate liveness and readiness groups. Liveness only checks the app itself, while readiness can include warm-up state.

Seeing probe failures

kubectl describe pod orders-6c9f7-abcde | grep -A5 -i "probe\|Events"
kubectl get pods -w   # watch READY column flip and RESTARTS increase

Probe failures appear as Unhealthy events in describe output, with the HTTP status or error.

Key points

  • Liveness failure restarts the container; readiness failure only removes it from traffic.
  • Startup probe disables liveness and readiness until it succeeds.
  • Never check external dependencies in a liveness probe.
  • Default timeoutSeconds is 1; raise it for busy or JVM-based apps.
  • Readiness probes are what make rolling updates zero-downtime.

Common follow-up questions

  • What happens if you configure a liveness probe that checks the database?
  • How do probes interact with a rolling update's maxUnavailable?
  • What is CrashLoopBackOff and how would you debug it?
  • How would you implement graceful shutdown alongside readiness?

Interview tips

  • State the failure action for each probe clearly; that is the core of the question.
  • Describe a cascading-restart scenario caused by a bad liveness probe; it shows production experience.
  • Tie readiness probes to zero-downtime deploys to connect the concept to business impact.

Concepts covered

Liveness Probe, Readiness Probe, Startup Probe, Self-healing, EndpointSlice

More Kubernetes & Orchestration questions