Probe types
| Probe | Failure Action | Purpose |
|---|---|---|
| livenessProbe | Restart container | App alive? Recover from deadlocks |
| readinessProbe | Remove from Service endpoints | App ready for traffic? |
| startupProbe | Restart container (blocks liveness/readiness) | Slow-starting apps; delays other probes until passes |
- Order: startup first → then readiness + liveness concurrently
All three probes with all config fields
spec:
containers:
- name: app
image: myapp:1.0
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10 # wait before first probe
periodSeconds: 10 # how often to probe
timeoutSeconds: 1 # probe timeout
failureThreshold: 3 # failures before action
successThreshold: 1 # successes to mark healthy (liveness: always 1)
readinessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
successThreshold: 1 # readiness: can be >1
startupProbe:
exec:
command:
- cat
- /tmp/ready # exit 0 = success
failureThreshold: 30 # 30 × 10s = 5 min for slow startup
periodSeconds: 10
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.port | gRPC health protocol (k8s 1.24+) |
gRPC probe
livenessProbe:
grpc:
port: 9090
service: "" # optional
initialDelaySeconds: 10
periodSeconds: 10
httpGet with HTTPS
livenessProbe:
httpGet:
path: /healthz
port: 8443
scheme: HTTPS
httpHeaders:
- name: Custom-Header
value: Awesome
Timing defaults
| 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 |
kubectl
kubectl get po <n> # READY 0/1 if readiness failing
kubectl describe po <n> # probe config + events
Failures
| Symptom | Cause |
|---|---|
CrashLoopBackOff | Wrong liveness → restarts |
| No traffic | Wrong readiness: Pod stays, removed from endpoints |
Exam gotchas
- readinessProbe failing ≠ restart: Pod stays Running but removed from Service endpoints; auto-rejoins when fixed
- Liveness too aggressive on slow apps → CrashLoop: use startupProbe
httpGet: correct path and port (named port preferred)