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 an Init Container That Silently Blocks the Main Container From Ever Starting

- 03.10.26 - ErcanOPAK

☸️ The Pod That Was Technically Running and Never Actually Doing Anything

Init containers are designed to run to completion, in order, before any of a pod’s main containers start – which is exactly the right model for setup work like waiting on a dependency or seeding a config file, but becomes a silent trap the moment one of them doesn’t actually exit. A pod with a hung or endlessly retrying init container shows up as Running or Init:0/1 in kubectl get pods, which doesn’t scream ‘stuck’ the way CrashLoopBackOff does, so it’s easy to assume the application itself is just slow to start rather than realize it has never been given the chance to start at all.

🔎 The Problem

spec:
  initContainers:
    - name: wait-for-db
      image: busybox
      command: ['sh', '-c', 'until nc -z postgres 5432; do sleep 2; done']
  containers:
    - name: app
      image: myapp:latest

# If "postgres" is misspelled, on a different port, or the network
# policy silently blocks this pod from reaching it, this init
# container loops forever - it never fails, never crashes, just never
# finishes. kubectl get pods shows:
#
#   NAME       READY   STATUS     RESTARTS   AGE
#   myapp-xy   0/1     Init:0/1   0          47m
#
# The main "app" container has never run even once.

✅ Fix: Give Init Containers a Timeout and Watch Init Status, Not Just Pod Status

  • Build an explicit timeout into any init container’s wait logic (a maximum retry count, or a bounded sleep loop) so a genuinely unreachable dependency fails loudly instead of looping silently forever.
  • Check kubectl describe pod and specifically the Init Containers section and its events, not just the top-level pod status line, since that’s where the actual stuck command and its output are visible.
  • Add resource requests/limits and a liveness-style self-check even to init containers where it makes sense, so Kubernetes has a mechanism to notice and restart one that’s wedged rather than one that appears to be making progress forever.

⚠️ Why This Is Easy to Miss

  • Init:0/1 looks like ordinary startup progress rather than a stuck state, especially on a pod that’s expected to take a little while to come up, so it’s common to just wait longer before investigating.
  • There’s no error, no crash loop, and no log output from the main container at all to search through, because that container has never started – the only evidence is in the init container’s own logs, which people often forget to check separately.

A pod stuck in Init isn’t failing – it’s waiting, patiently and silently, for a gate that may never open on its own.

— Cloud Architect

Related posts:

Kubernetes: Cost Optimization with Resource Management

Kubernetes: Cost Optimization with Resource Management

Kubernetes: Use Horizontal Pod Autoscaler to Scale Based on CPU/Memory

Kubernetes: Use Horizontal Pod Autoscaler to Scale Based on CPU/Memory

Kubernetes: Fix a StatefulSet Stuck Because Its PVC Won't Resize

Kubernetes: Fix a StatefulSet Stuck Because Its PVC Won't Resize

Views: 10
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

The AI Prompt That Catches Missing ConfigureAwait Calls and Sync-Over-Async Deadlocks Hiding in Your C# Codebase
The AI Prompt That Strengthens a Weak Performance Review With Specific, Defensible Examples

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 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 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# 868 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 @ 631 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