☸️ Fix a Liveness Probe Restarting a Pod Mid-Migration
A liveness probe exists to restart a container that’s genuinely stuck, but kubelet starts running it on the schedule you configure regardless of whether the application inside has actually finished starting up. An app that runs a database migration or a cache warmup before it can serve the health endpoint will get killed by a liveness probe whose initialDelaySeconds was tuned for the ordinary startup time, not the slower first-run path — and because the restarted container starts the exact same migration over again, the pod can loop through CrashLoopBackOff indefinitely without ever completing it.
🔎 The Problem
livenessProbe:
httpGet:
path: /healthz
port: 8080
initialDelaySeconds: 15 # fine for a normal start
periodSeconds: 10
failureThreshold: 3
# Migration on first boot takes 90+ seconds -> probe starts failing at 15s,
# kills the container at ~45s, migration restarts from scratch next boot
✅ Fix: A Liveness Probe Restarting a Pod Mid-Migration
- Add a startupProbe with a generous failureThreshold * periodSeconds budget that covers the slowest realistic startup path, including a cold migration run; liveness and readiness probes don’t start until the startup probe succeeds.
- Keep the liveness probe’s own timing tuned for steady-state behavior once the startup probe has already confirmed the app is up, instead of stretching initialDelaySeconds to cover both cases.
- Make the migration step idempotent and resumable regardless of this fix, since any orchestrator can still kill a pod mid-task for unrelated reasons (node pressure, a rolling node upgrade).
🚨 Why This Is Dangerous
- Without a startup probe, a slow first boot after a schema change can turn into an unbootable CrashLoopBackOff across every replica at once, right when the migration was the one thing the deployment most needed to finish cleanly.
A liveness probe doesn’t know the difference between a hung process and one that’s simply still getting ready — that’s exactly the job a startup probe is there to do instead.





