Process Is Alive, But Is the Service Ready? How to Separate Readiness, Liveness, and Startup Probes in KubernetesNote · digest for November 26
Engineering control panel with three signal indicators for Kubernetes container lifecycle probes
Note3 sections≈ 5 min

Process Is Alive, But Is the Service Ready? How to Separate Readiness, Liveness, and Startup Probes in Kubernetes

Your Kubernetes pod shows Running, so can you send traffic to it? Not necessarily. Running only means the container started and its main process hasn't crashed. Your app could still be warming up a cache, or it might already be frozen in a deadlock.

To tell a running process apart from a ready service, kubelet checks containers using Kubernetes probes: readinessProbe, livenessProbe, and startupProbe.

The Probe Trio: Traffic, Restarts, and Slow Startups

readinessProbe decides whether a pod can receive new requests. After failureThreshold failures, kubelet sets Ready=False. The container keeps running, RESTARTS stays at zero, and the Service removes the pod from load balancing for new connections (existing HTTP/2 or WebSocket connections aren't dropped). Once the check passes again, traffic returns automatically.

livenessProbe is the emergency kill switch for a hung process. After failureThreshold failures, kubelet terminates the container and restartPolicy starts a fresh one. If your app exits on fatal errors on its own, you may not even need this probe.

startupProbe protects slow startups. Until it succeeds for the first time, both readiness and liveness stay disabled. Its startup window is failureThreshold * periodSeconds (for example, 30 * 10 gives up to 300 seconds), after which fast liveness checks take over.

Probes support httpGet (success: 200..399), grpc, tcpSocket (only checks an open port, not a frozen event loop), or exec (exit code 0). The Kubernetes documentation warns that frequent exec probes tax node CPU, so prefer httpGet or grpc for network services.

The Classic Trap: Shared Databases in Liveness and the 1-Second Timeout

Imagine your database freezes for 20 seconds during a failover or a heavy query. If /livez runs SELECT 1 against that database, after failureThreshold * periodSeconds (30 seconds by default), kubelet will kill every replica of your service at once. Restarting your app won't fix the database. Worse, when the database recovers, dozens of pods will cold-start together, open connection pools simultaneously, and easily knock it over again.

That's why livenessProbe must check only the health of the process itself, with zero calls to shared databases. External dependencies belong in readinessProbe—and even there, be careful: if your service can serve stale responses from cache, marking all replicas NotReady causes an unnecessary outage.

The second trap is the defaults: initialDelaySeconds: 0, periodSeconds: 10, failureThreshold: 3, successThreshold: 1 (required to be 1 for liveness and startup), and just timeoutSeconds: 1. One garbage collection pause or CPU throttling spike causing three timeouts in a row sends the pod into CrashLoopBackOff. Set timeouts explicitly based on your p99 latency.

Manifest and Three Test Scenarios with kubectl

Kubernetes doesn't create /livez and /readyz for you—your app must expose them. Here is a baseline pod manifest with all three probes (the same containers block works in a Deployment):

apiVersion: v1
kind: Pod
metadata:
  name: demo-api
  labels:
    app: demo-api
spec:
  containers:
  - name: api
    image: example/demo-api:1.0
    ports:
    - name: http
      containerPort: 8080
    # Startup window up to 300s (30 * 10s); until it passes,
    # readiness and liveness are disabled
    startupProbe:
      httpGet:
        path: /livez
        port: http
      periodSeconds: 10
      timeoutSeconds: 2
      failureThreshold: 30
    # 3 failures at 5s intervals pull the pod from traffic without restarting
    readinessProbe:
      httpGet:
        path: /readyz
        port: http
      periodSeconds: 5
      timeoutSeconds: 2
      successThreshold: 1
      failureThreshold: 3
    # Liveness check: process health only
    livenessProbe:
      httpGet:
        path: /livez
        port: http
      periodSeconds: 10
      timeoutSeconds: 2
      failureThreshold: 3

After deploying, test three scenarios. First, delay /livez for less than 300 seconds and confirm startupProbe prevents early restarts. Next, return 200 from /livez and 503 from /readyz: the pod shows Running with READY 0/1 while RESTARTS stays at 0; switch back to 200 and it becomes 1/1. Finally, make /livez return 500 or hang past timeoutSeconds to observe a restart.

# Watch READY and RESTARTS in real time
kubectl get pods -l app=demo-api -w

# Inspect Unhealthy / Killing events and the Ready condition
kubectl describe pod demo-api

# Confirm a NotReady pod is removed from Service endpoints
kubectl get endpointslices -l kubernetes.io/service-name=demo-api

In kubectl get pods, the difference is immediate: a readiness failure drops READY while RESTARTS stays flat, whereas a liveness failure increments restarts and logs Unhealthy and Killing events in describe pod. get endpointslices confirms the unready replica is out of rotation.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 4