What You Will Learn
Intermediate
- Pod lifecycle phases
- Three types of probes
- How to configure them
Three Probe Types
| Probe | What it checks | Failure action |
|---|---|---|
| Liveness | Is the app alive? | Restart container |
| Readiness | Is the app ready to serve? | Remove from Service (no traffic) |
| Startup | Has the app started? | Restart (for slow-starting apps) |
probes.yamlyaml
apiVersion: v1
kind: Pod
metadata:
name: my-app
spec:
containers:
- name: app
image: my-app:latest
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
startupProbe:
httpGet:
path: /startup
port: 8080
failureThreshold: 30
periodSeconds: 10Liveness vs Readiness
Liveness = should I RESTART you? Readiness = should I SEND TRAFFIC to you? An app can be alive but not ready (still loading data).Practical Exercise
Add livenessProbe to a Pod YAML (HTTP GET /health)
Add readinessProbe (HTTP GET /ready)
Apply and check: kubectl describe pod
Simulate failure: make /health return 500
Watch: K8s restarts the container
Key Takeaways
- Liveness: app alive? If not, RESTART container.
- Readiness: app ready? If not, REMOVE from Service (no traffic).
- Startup: app started? For slow-starting apps (JVM, etc).
- Probe types: httpGet, tcpSocket, exec.
- initialDelaySeconds: wait before first probe.
Comments
Comments
Post a Comment