Why Kubernetes Probes Matter?
Kubernetes itself does not know your application logic. It only knows:
- Is the container running?
- Is the app ready to receive traffic?
- Has the app fully started?
Probes answer these questions, so Kubernetes can:
- Restart broken pods
- Stop sending traffic to unhealthy pods
- Handle slow startups gracefully
The 3 Types of Probes
1. Liveness Probe – “Is my app alive?”
Purpose
- Detects deadlocked or hung applications
- If this probe fails → pod is restarted
When to use
- App is running but not responding
- Memory leak, thread deadlock, infinite loop, etc.
Spring Boot example
/actuator/health/liveness
2. Readiness Probe – “Can I send traffic to this pod?”
Purpose
- Controls traffic routing
- If this probe fails → pod is removed from Service endpoints
- Pod is NOT restarted
When to use
-
App is up but:
- DB is down
- Kafka not reachable
- Cache not warmed up
Spring Boot example
/actuator/health/readiness
3. Startup Probe – “Has the app finished starting?”
Purpose
- Protects slow-starting apps
- Disables liveness & readiness checks until startup completes
When to use
-
Spring Boot apps with:
- DB migrations
- Large context initialization
- Cold JVM startup
Spring Boot example
- Same endpoint as liveness, but with relaxed timing
How Spring Boot Actuator Helps
Spring Boot already gives you production-ready health endpoints.
Enable probe-aware health groups
In application.yml:
management:
endpoint:
health:
probes:
enabled: true
endpoints:
web:
exposure:
include: health
This enables:
/actuator/health/liveness/actuator/health/readiness
Typical Health Behavior
-
/health/liveness
- Used By: Liveness Probe
- Meaning: App is not dead
-
/health/readiness
- Used By: Readiness Probe
- Meaning: App can handle traffic
-
/health
- Used By: Humans / Monitoring
- Meaning: Overall app health
Kubernetes Pod Configuration (Recommended)
Deployment YAML (Spring Boot)
containers:
- name: springboot-app
image: my-spring-app:1.0
ports:
- containerPort: 8080
startupProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
failureThreshold: 30
periodSeconds: 10
livenessProbe:
httpGet:
path: /actuator/health/liveness
port: 8080
initialDelaySeconds: 0
periodSeconds: 10
failureThreshold: 3
readinessProbe:
httpGet:
path: /actuator/health/readiness
port: 8080
periodSeconds: 5
failureThreshold: 3
How This Works Together
-
Pod starts
- Only
startupProbeis active
- Only
-
Startup completes
- Startup probe succeeds
-
Readiness probe
- Traffic starts flowing
-
Liveness probe
- Continuous health monitoring
-
If readiness fails
- Traffic stops
-
If liveness fails
- Pod restarts
Spring Boot Example
Readiness depends on DB
If DB is down:
/readiness→DOWN/liveness→ stillUP- Pod stays alive but no traffic is sent
This is exactly what you want in production.
Common Mistakes
-
Using the same endpoint for all probes
- Causes unnecessary restarts
-
No startup probe
- Spring Boot gets killed during startup
-
Aggressive liveness timings
- JVM GC pauses trigger restarts
-
Exposing all actuator endpoints publicly
- Security risk
Quick Rule of Thumb
- Startup Probe → “Give my app time”
- Readiness Probe → “Send traffic only when ready”
- Liveness Probe → “Restart me if I’m stuck”