Container Probes
Probe types
| Probe | When fails | Action |
|---|
| Liveness | Unhealthy while running | Restart container |
| Readiness | Not ready for traffic | Removed from Service endpoints |
| Startup | Slow/failed start | Kill container; delays liveness until success |
- Order: startup runs first → then readiness + liveness concurrently
- Readiness is most important in practice
Verification methods
| Method | YAML | Success |
|---|
| Exec | exec.command | Exit code 0 |
| HTTP | httpGet path/port | Status 200–399 |
| TCP | tcpSocket.port | Connection opens |
| gRPC | grpc | gRPC health protocol |
- Use named ports in probes:
port: nodejs-port
Timing (all probes)
| Field | Default | Meaning |
|---|
initialDelaySeconds | 0 | Wait before first check |
periodSeconds | 10 | Interval between checks |
timeoutSeconds | 1 | Max check duration |
failureThreshold | 3 | Failures before action |
successThreshold | 1 | Successes to recover after fail |
YAML examples
readinessProbe:
httpGet:
path: /
port: nodejs-port
initialDelaySeconds: 2
periodSeconds: 8
livenessProbe:
exec:
command: ["/bin/sh", "-c", "test -f /tmp/healthy"]
startupProbe:
httpGet:
path: /healthz
port: 8080
failureThreshold: 30
periodSeconds: 10
kubectl
kubectl get po <n>
kubectl describe po <n>
Failures
| Symptom | Cause |
|---|
CrashLoopBackOff | Wrong liveness → restarts |
| No traffic | Wrong readiness: Pod stays, removed from endpoints |
Exam tips
- Liveness too aggressive on slow apps → CrashLoop: use startupProbe
- Readiness failure ≠ Pod restart (only removed from Service)
httpGet must use correct path and port (named port preferred)