Tag Archives: kubectl

Startup Probe vs Liveness and Readiness: Key Differences in Kubernetes Devops

1. What is Startup Probe?

πŸ‘‰ Startup probe = check if application has started successfully

  • Runs only during startup (not continuous)
  • Used for slow-starting apps (Java, Spring Boot, DB-heavy apps)
  • Until it passes:
    • ❌ Liveness NOT executed
    • ❌ Readiness NOT executed

βœ… This prevents Kubernetes from killing app too early.

2. Why we need Startup Probe (real problem)

Without startup probe:

  • App takes 40 sec to start
  • Liveness starts in 10 sec
    πŸ‘‰ Kubernetes thinks app failed
    πŸ‘‰ Restarts pod β†’ CrashLoopBackOff

With startup probe:

  • Kubernetes waits until app fully starts
  • Then starts liveness & readiness

βœ… Fixes unnecessary restarts

3. Three Main Differences (easy table)

FeatureStartup ProbeLiveness ProbeReadiness Probe
PurposeCheck app startedCheck app aliveCheck app ready
RunsOnly at startupContinuousContinuous
On failureRestart containerRestart containerRemove traffic
Special behaviorDisables other probes until successIndependentIndependent

Simple Startup Probe Example (YAML)

apiVersion: v1
kind: Pod
metadata:
name: startup-demo
spec:
containers:
- name: app
image: nginx
ports:
- containerPort: 80
startupProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 5

What happens:

  • Kubernetes sends HTTP request /
  • If not ready β†’ retry
  • If fails many times β†’ restart
  • If success β†’ βœ… start liveness & readiness

Another Example (Exec type – real usage)

startupProbe:
exec:
command:
- cat
- /tmp/app-ready
initialDelaySeconds: 3
periodSeconds: 5

Use case:

  • App creates file /tmp/app-ready after startup
  • Until then β†’ probe fails
  • Once file exists β†’ app marked started

Commands (same as other probes)

kubectl apply -f startup.yaml
kubectl get pods
kubectl describe pod startup-demo

Real DevOps Example (important πŸ”₯)

Scenario – Spring Boot app

  • Startup time: 60 sec
  • Without startup probe β†’ killed repeatedly
  • With startup probe β†’ works fine

βœ… This is VERY common issue in EKS / production

Short Explain:

Startup β†’ app started or not

Liveness β†’ app alive or not

Readiness β†’ ready for traffic or not