Startup, readiness and liveness probes
Startup, readiness and liveness probes
Without probes Kubernetes knows only “the process runs”. Probes tell it whether the application works.
| Probe | Question | On failure |
|---|---|---|
| startupProbe | has it finished booting? | the other probes wait; after failureThreshold -> restart |
| readinessProbe | can it take traffic now? | removed from Service endpoints - no restart |
| livenessProbe | is it hung? | container restarted |
graph LR
S[container starts] --> SP{startup OK?}
SP -->|no, too long| R[restart]
SP -->|yes| L[liveness + readiness run]
L -->|readiness fails| NR[not Ready - no traffic]
L -->|liveness fails| R
containers:
- name: app
image: nginx:1.27
startupProbe:
httpGet: { path: /, port: 80 }
failureThreshold: 30 # 30 x 2 s = up to 60 s to start
periodSeconds: 2
readinessProbe:
httpGet: { path: /ready, port: 80 }
periodSeconds: 5
livenessProbe:
httpGet: { path: /healthz, port: 80 }
periodSeconds: 10
failureThreshold: 3
Handlers: httpGet (2xx/3xx = OK), tcpSocket, exec (exit 0 = OK), grpc.
Tuning: initialDelaySeconds, periodSeconds, timeoutSeconds (1 s!),
failureThreshold, successThreshold.
Probes and rollouts
A rolling update waits for readiness. A new version that never becomes ready stalls the rollout - the old Pods keep serving. No readiness probe means “ready as soon as the process starts” - traffic hits an app that is still warming up.
Pitfalls
- Liveness must not check dependencies. Database down -> every Pod restarted -> outage made worse. Put dependency checks in readiness.
- Liveness too strict or
timeoutSecondstoo low -> restart loops under load. - Slow starters: use a startupProbe, not a huge
initialDelaySeconds.