K8s Readiness Probe: Complete YAML Guide
Kubernetes readiness probe explained with YAML examples. Configure HTTP, TCP, exec, and gRPC readiness probes with liveness and startup probe comparison.
💡 Quick Answer: Use readinessProbe to control when a pod receives traffic (fails = removed from Service). Use livenessProbe to restart unhealthy containers (fails = container restart). Use startupProbe for slow-starting apps. Always set
initialDelaySecondsto give your app time to start, and don’t make livenessProbe depend on external services.
The Problem
Kubernetes needs to know if your application is healthy and ready to receive traffic. Without proper health checks, Kubernetes might send traffic to broken pods or fail to restart crashed applications.
The Solution
Configure three types of probes:
- Liveness Probe - Is the container alive? (Restart if not)
- Readiness Probe - Is the container ready for traffic? (Remove from service if not)
- Startup Probe - Has the container started? (Protect slow-starting containers)
Understanding the Difference
| Probe | Purpose | Failure Action |
|---|---|---|
| Liveness | Detect deadlocks/hangs | Restart container |
| Readiness | Detect temporary unavailability | Remove from Service endpoints |
| Startup | Wait for slow startup | Prevent liveness checks during startup |
Basic HTTP Probe Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- name: my-app
image: my-app:1.0
ports:
- containerPort: 8080
# Liveness: Restart if this fails
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
# Readiness: Remove from service if this fails
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 3
failureThreshold: 3Probe Types
HTTP Probe (Most Common)
livenessProbe:
httpGet:
path: /healthz
port: 8080
httpHeaders:
- name: Authorization
value: Bearer tokenTCP Probe (For non-HTTP services)
livenessProbe:
tcpSocket:
port: 3306Command Probe (For custom checks)
livenessProbe:
exec:
command:
- cat
- /tmp/healthygRPC Probe (Kubernetes 1.24+)
livenessProbe:
grpc:
port: 50051
service: my.health.ServiceProbe Parameters Explained
| Parameter | Default | Description |
|---|---|---|
initialDelaySeconds | 0 | Wait before first probe |
periodSeconds | 10 | How often to probe |
timeoutSeconds | 1 | Probe timeout |
successThreshold | 1 | Consecutive successes to be healthy |
failureThreshold | 3 | Consecutive failures to be unhealthy |
Startup Probe for Slow Applications
For applications that take a long time to start (Java apps, ML models):
startupProbe:
httpGet:
path: /healthz
port: 8080
# Allow up to 5 minutes for startup (30 * 10 seconds)
failureThreshold: 30
periodSeconds: 10
livenessProbe:
httpGet:
path: /healthz
port: 8080
# Once startup succeeds, use tighter liveness checks
periodSeconds: 10
failureThreshold: 3Best Practices
✅ DO
# Separate endpoints for liveness and readiness
livenessProbe:
httpGet:
path: /healthz # Only checks if app is alive
readinessProbe:
httpGet:
path: /ready # Checks dependencies (DB, cache, etc.)❌ DON’T
# Don't check external dependencies in liveness probe!
livenessProbe:
httpGet:
path: /ready # This checks DB connection
# If DB is slow, ALL pods restart = cascading failure!Recommended Health Check Implementations
Liveness endpoint (/healthz):
- Return 200 if the process is running
- Don’t check external dependencies
- Fast response (< 100ms)
Readiness endpoint (/ready):
- Check database connections
- Check cache availability
- Check required external services
- Return 503 if not ready
Complete Example: Node.js Application
// healthz - for liveness (simple)
app.get('/healthz', (req, res) => {
res.status(200).json({ status: 'alive' });
});
// ready - for readiness (checks dependencies)
app.get('/ready', async (req, res) => {
try {
// Check database
await db.ping();
// Check Redis
await redis.ping();
res.status(200).json({ status: 'ready' });
} catch (error) {
res.status(503).json({
status: 'not ready',
error: error.message
});
}
});Common Mistakes
1. Liveness checks external dependencies
# BAD: If DB is slow, all pods restart
livenessProbe:
httpGet:
path: /api/users # Queries database2. Timeout too short
# BAD: Probe times out during GC pauses
livenessProbe:
httpGet:
path: /healthz
timeoutSeconds: 1 # Too short for Java apps3. No startup probe for slow apps
# BAD: App takes 60s to start, but liveness starts at 10s
livenessProbe:
initialDelaySeconds: 10 # App not ready yet = restart loop4. ReadinessProbe too aggressive
# BAD: Single failure removes from service
readinessProbe:
failureThreshold: 1 # Flaky during deploymentsDebugging Probes
Check probe status:
kubectl describe pod my-app-xxx
# Look for "Liveness" and "Readiness" in ConditionsCheck events for probe failures:
kubectl get events --field-selector reason=UnhealthyTest the endpoint manually:
kubectl exec -it my-app-xxx -- curl localhost:8080/healthzSummary
You’ve learned how to:
- Configure liveness, readiness, and startup probes
- Choose the right probe type for your use case
- Implement health check endpoints correctly
- Avoid common pitfalls that cause cascading failures
Key takeaway: Keep liveness probes simple, use readiness probes for dependency checks.
References
📘 Go Further with Kubernetes Recipes
Love this recipe? There’s so much more! This is just one of 100+ hands-on recipes in our comprehensive Kubernetes Recipes book.
Inside the book, you’ll master:
- ✅ Production-ready deployment strategies
- ✅ Advanced networking and security patterns
- ✅ Observability, monitoring, and troubleshooting
- ✅ Real-world best practices from industry experts
“The practical, recipe-based approach made complex Kubernetes concepts finally click for me.”
👉 Get Your Copy Now — Start building production-grade Kubernetes skills today!
Frequently Asked Questions
What is a readiness probe in Kubernetes?
A readiness probe tells Kubernetes when a pod is ready to accept traffic. If the readiness probe fails, the pod is removed from Service endpoints (no traffic routed to it) but NOT restarted. Use readiness probes for applications that need warm-up time, dependency checks, or graceful degradation.
What’s the difference between liveness and readiness probes?
Liveness probes detect if a container is deadlocked or hung — a failing liveness probe causes Kubernetes to restart the container. Readiness probes detect if a container can handle requests — a failing readiness probe removes the pod from load balancing but doesn’t restart it. Use both together for robust health checking.
How do I configure a readiness probe?
readinessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3This checks /healthz every 10 seconds. After 3 consecutive failures, the pod is marked unready and removed from Service endpoints.
Frequently Asked Questions
What is a readiness probe in Kubernetes?
A readiness probe tells Kubernetes whether a pod is ready to receive traffic. If the readiness probe fails, the pod is removed from Service endpoints — no traffic is routed to it. Unlike liveness probes, a failed readiness probe does NOT restart the pod.
What is the difference between liveness and readiness probes?
Liveness probe: Is the container alive? On failure → restart the container. Use to detect deadlocks and hangs. Readiness probe: Is the container ready for traffic? On failure → remove from Service endpoints. Use for slow startup and dependency checks.
Should I use liveness probes?
Be careful with liveness probes. Never check external dependencies (database, cache) in liveness probes — if the DB is down, restarting your app won’t fix it and creates a thundering herd. Set initialDelaySeconds high enough and use failureThreshold: 3 minimum.
What is a startup probe?
Startup probes (Kubernetes 1.20+) run only during container startup. Once the startup probe succeeds, liveness and readiness probes take over. Use startup probes for slow-starting applications (Java, ML models).
What probe types are available?
HTTP GET (success = 200-399), TCP socket (success = port open), exec command (success = exit code 0), and gRPC health check (Kubernetes 1.27+).
See also: CrashLoopBackOff Troubleshooting, HPA Guide
Frequently Asked Questions
What is a readiness probe in Kubernetes?
A readiness probe tells Kubernetes whether a pod is ready to receive traffic. If the readiness probe fails, the pod is removed from Service endpoints — no traffic is routed to it until it passes again. Unlike liveness probes, a failing readiness probe does NOT restart the container.
What is the difference between readiness and liveness probes?
Readiness probes control traffic routing — a failing pod is removed from the Service but keeps running. Liveness probes control pod lifecycle — a failing pod is killed and restarted. Use readiness for “not ready yet” (warming up, loading data). Use liveness for “stuck and needs restart” (deadlock, hung process).
Should I use the same endpoint for readiness and liveness probes?
No. Liveness probes should check only that the process is alive (simple /healthz). Readiness probes should check that the app can serve requests (database connected, cache warm, dependencies available). A liveness probe that checks the database can cause cascading restarts if the DB goes down briefly.
What is the default readiness probe in Kubernetes?
If no readiness probe is configured, Kubernetes considers the pod ready as soon as the container starts. This can cause errors if the application needs warm-up time. Always configure readiness probes for production workloads.
How do I configure a gRPC readiness probe?
Use grpc.port in the probe spec (Kubernetes 1.24+). The container must implement the gRPC Health Checking Protocol. Example: readinessProbe: { grpc: { port: 50051 }, initialDelaySeconds: 5 }.

Recommended
Kubernetes Recipes — The Complete Book100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Get the Book →Learn by Doing
CopyPasteLearn — Hands-on Cloud & DevOps CoursesMaster Kubernetes, Ansible, Terraform, and MLOps with interactive, copy-paste-run lessons. Start free.
Browse Courses →🎓 Deepen Your Skills — Hands-on Courses
Courses by CopyPasteLearn.com — Learn IT by Doing
