Skip to Content
Mengty Learns
Kubernetes

Kubernetes Probes: Liveness, Readiness, Startup

How livenessProbe, readinessProbe, and startupProbe differ, what each failure triggers, and how failing readiness removes a Pod from EndpointSlices.

explanationintermediateTested with kubernetes 1.37 (docs)Updated Nov 26, 2026

TL;DR

Readiness controls traffic (failure removes the Pod from EndpointSlices without restarting it), liveness controls restarts (failure kills a deadlocked container), and startup protects slow boots by delaying liveness and readiness until the first success.

Intent

TL;DR

Separate traffic-gating (readinessProbe) from process-restarting (livenessProbe) and slow-boot protection (startupProbe) so you don't trigger restart loops or cascading outages.

Problem

Without probes, Kubernetes assumes a Pod is ready the millisecond its container process starts—sending user traffic to an app that is still warming caches or loading config. Conversely, putting a heavy database check inside livenessProbe causes kubelet to restart every Pod in the fleet whenever the database has a 5-second hiccup.

Solution

ProbeFailure actionUse it for
readinessProbeSets Ready=False; removes Pod IP from EndpointSliceTemporary inability to serve traffic (warming up, draining, overloaded)
livenessProbeKills and restarts the containerUnrecoverable deadlocks where only a restart fixes the process
startupProbeDelays liveness & readiness; kills container if failureThreshold expiresLegacy/heavy apps that take 30–120s to boot

Real-world analogy

▶ Flow: watch it work

Failing Readiness Probe → Removed from EndpointSlice → No Traffic

Overview of Failing Readiness Probe → Removed from EndpointSlice → No Traffic. 4 steps.
Overview4 steps in this flow

Press Start or tap any step dot to trace the path.

▸All steps (4)

Code

Minimal Deployment probe configuration for an HTTP service (such as labs/docker-multistage-next serving /healthz):

# Partial Pod container spec (not run against a cluster)
containers:
  - name: web
    image: ghcr.io/example/web:1.0.0
    ports:
      - containerPort: 3000
    startupProbe:
      httpGet:
        path: /healthz
        port: 3000
      failureThreshold: 12
      periodSeconds: 5
    readinessProbe:
      httpGet:
        path: /readyz
        port: 3000
      periodSeconds: 5
      failureThreshold: 2
    livenessProbe:
      httpGet:
        path: /healthz
        port: 3000
      periodSeconds: 15
      failureThreshold: 3

When you DON'T need this

  • Non-Kubernetes platforms: Static sites on Cloudflare Workers/Pages, Docker Compose (HEALTHCHECK), or serverless functions don't use Kubernetes probes or EndpointSlices.
  • Kubernetes Job / CronJob batch Pods: Batch jobs run to completion and exit; they don't serve Service traffic and shouldn't have readinessProbe or livenessProbe.
  • Cost / complexity trade-off: Probes cost almost nothing in CPU (a lightweight /healthz handler returning 200 OK takes microseconds), but poorly tuned timeouts (timeoutSeconds: 1 on a GC-pausing app) or DB-coupled liveness probes can cause self-inflicted outages. Keep /healthz cheap and local to the process.

When to use / when to avoid

When to use
  • Every long-running Kubernetes Deployment behind a Service should define a readinessProbe.
  • Add startupProbe if cold start can exceed liveness initialDelaySeconds.
When to avoid
  • Checking external databases or third-party APIs inside livenessProbe (causes cascading restarts).
  • Setting identical aggressive thresholds for liveness and readiness.

How to implement

Expose cheap local health endpoints

Have /healthz verify the process event loop is alive (no external DB calls) and /readyz verify local initialization is complete.

Configure readinessProbe first

Set periodSeconds and failureThreshold so rolling updates only shift traffic once new Pods are ready.

Add startupProbe for slow starters

Use startupProbe instead of a huge initialDelaySeconds on livenessProbe so fast boots become ready immediately while slow boots aren't killed.

Pros / Cons

Pros
  • Zero-downtime rolling updates: new Pods receive traffic only after passing readiness.
  • Self-healing for wedged processes via livenessProbe.
Cons
  • Badly designed liveness probes (calling external DBs) turn brief downstream blips into CrashLoopBackOff storms.
  • Too-tight timeoutSeconds can fail under normal GC or CPU spikes.

Relations

Check yourself

Check Yourself

1. A Pod's readinessProbe fails 3 times, while its livenessProbe continues to pass. What happens?

2. Why is querying Postgres inside a livenessProbe usually an anti-pattern?

Sources