Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Kubernetes

Kubernetes: Fix a Liveness Probe Restarting a Pod Mid-Migration

- 29.11.26 - ErcanOPAK

☸️ 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.

— Cloud Architect

Related posts:

Kubernetes: Use Resource Quotas to Prevent One Namespace from Draining Cluster

Kubernetes: Use Resource Quotas to Prevent One Namespace from Draining Cluster

Kubernetes: Implementing a GitOps Workflow with ArgoCD

Kubernetes: Implementing a GitOps Workflow with ArgoCD

Kubernetes: Set Resource Limits for Stability

Kubernetes: Set Resource Limits for Stability

Views: 3
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

C#: Fix a TaskCompletionSource Never Completing After a Timeout
C#: Fix a Switch Expression Missing an Exhaustiveness Warning

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 996 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 995 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 866 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 629 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com