Kubernetes Startup Probe Health Check
Design a Kubernetes startup probe response for slow-starting applications. Startup probes disable liveness checks during initialization, preventing premature restarts.
Detailed Explanation
Kubernetes Startup Probe
Startup probes protect slow-starting applications from being killed by liveness probes before they finish initializing. The startup probe runs only during container startup and disables liveness and readiness probes until it succeeds.
Response Format
{
"status": "ok",
"started": true,
"checks": {
"databaseMigration": { "status": "completed" },
"cacheWarmup": { "status": "completed" },
"configLoaded": { "status": "completed" }
}
}
During initialization:
{
"status": "fail",
"started": false,
"checks": {
"databaseMigration": { "status": "completed" },
"cacheWarmup": { "status": "in_progress" },
"configLoaded": { "status": "completed" }
}
}
Probe Configuration
startupProbe:
httpGet:
path: /startup
port: 8080
initialDelaySeconds: 0
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 30 # 30 * 5s = 150s max startup time
Common Startup Tasks
| Task | Typical Duration | Impact |
|---|---|---|
| Database migrations | 10-60s | Schema must be ready |
| Cache warmup | 5-30s | Cold cache causes latency |
| Config loading | 1-5s | App needs configuration |
| Connection pooling | 2-10s | DB pool initialization |
| Service registration | 1-3s | Service mesh enrollment |
Why Use Startup Probes
Without startup probes, you must set initialDelaySeconds on liveness probes high enough for worst-case startup time. Startup probes decouple startup time from ongoing health checks, allowing tight liveness probe intervals while supporting slow starts.
Use Case
Java/JVM applications, services running database migrations at startup, or applications that need to warm caches before serving traffic in Kubernetes environments.