A web API can be alive, warming up, and unable to serve requests at the same time. A single health endpoint flattens those states. In Kubernetes, each probe triggers a different action, so the endpoint should answer a correspondingly different question.
Separate the decisions
- Startup: Has initialization finished? Use a startup probe for slow migrations, warmups, or runtimes. It gates the other probes until it succeeds.
- Readiness: Should this replica receive new requests? Return an error while it warms up or cannot serve useful traffic. Kubernetes marks the endpoint unready.
- Liveness: Would restarting this container help? Keep this check focused on failures local to the process, such as an event loop that has stopped processing work.
Give startup room
The fragment below belongs under a container in a Pod template. The startup probe allows roughly two minutes of failed attempts. Measure your own cold start first and give it margin for realistic load.
startupProbe:
httpGet:
path: /startup
port: 8080
periodSeconds: 5
failureThreshold: 24
readinessProbe:
httpGet:
path: /ready
port: 8080
periodSeconds: 5
livenessProbe:
httpGet:
path: /live
port: 8080
periodSeconds: 10
failureThreshold: 3
Test an outage while it is safe
Disconnect a dependency in a test environment and watch what happens to the replicas. If every container restarts when a shared database stalls, the restart loop can make recovery harder by creating fresh connections at the worst moment. Keep that dependency out of liveness. Decide whether readiness should fail based on whether the replica can still serve anything useful.
During a rollout, compare Pod events with application logs. A readiness failure explains why a running Pod receives no traffic. A rising restart count points to a different question.