Kubernetes Readiness Probe Health Check
Design a Kubernetes readiness probe response that checks dependency availability. Failing readiness probes remove pods from service endpoints without restarting.
Kubernetes
Detailed Explanation
Kubernetes Readiness Probe
The readiness probe tells Kubernetes whether your pod can handle traffic. Unlike liveness, a failed readiness probe removes the pod from service endpoints without restarting it.
Response Format
{
"status": "ok",
"dependencies": {
"database": {
"status": "ok",
"responseTime": "12ms",
"message": "Connection pool healthy"
},
"redis": {
"status": "ok",
"responseTime": "3ms",
"message": "Cache connected"
},
"external-api": {
"status": "ok",
"responseTime": "89ms",
"message": "Payment service responding"
}
}
}
Probe Configuration
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 2
What to Check
| Check | Include? | Why |
|---|---|---|
| Database connection | Yes | Can't serve requests without it |
| Cache availability | Yes | Performance critical |
| External API health | Depends | If requests require it |
| Disk space | Sometimes | If writes are needed |
| Configuration loaded | Yes | Ensures correct behavior |
Liveness vs Readiness
| Aspect | Liveness | Readiness |
|---|---|---|
| Path | /healthz | /ready |
| Failure action | Restart pod | Remove from service |
| Check scope | Internal only | Dependencies too |
| Recovery | Automatic restart | Automatic re-add |
Best Practice
Keep readiness probe timeouts short (3-5 seconds). If a dependency check takes longer, consider it failed. Use circuit breakers to prevent slow dependencies from blocking the probe.
Use Case
Kubernetes services where pods should stop receiving traffic when their dependencies (database, cache, external APIs) become unavailable, enabling graceful traffic shifting.