The Real Fullstack

The Kubernetes CrashLoop

The app starts fine on a laptop. Why does Kubernetes keep killing it before it finishes starting?

エンジニア8 分デバッグラボコード課題
kubernetesyamlspring-bootflyway

この課題はまだ日本語に翻訳されていません。英語版を表示しています。

ミッション:Read the evidence, identify why the container is restarted, and fix it without losing the ability to restart truly stuck pods.背景 · 学習目標 ▾

Brightcart's checkout service went into CrashLoopBackOff after a release with 42 database migrations. Somebody already doubled the memory limit — nothing changed. The pod logs end mid-migration every time.

ミッション: Read the evidence, identify why the container is restarted, and fix it without losing the ability to restart truly stuck pods.

学習目標

  • Read kubelet events and exit codes to find who kills a container.
  • Use startup probes for slow-starting applications.
  • Move one-off work (migrations) out of every replica's startup.
シミュレーションシミュレーション値
kubeletcheckout podPostgreSQL
シミュレーションを実行
startupProbe:                       # liveness/readiness wait until this succeeds  httpGet: { path: /actuator/health/liveness, port: 8080 }  periodSeconds: 5  failureThreshold: 36              # up to 3 minutes to startlivenessProbe:  httpGet: { path: /actuator/health/liveness, port: 8080 }  periodSeconds: 10# migrations: run once per release in a Job / init step, not in every replica's startup

簡略化

Two symptoms with deterministic fixes. Real crash loops also come from config errors, OOM kills and failing dependencies. 教育用モデルです。数値は挙動を示すためのもので、ベンチマークではありません。

コンセプト

関連する課題

参考資料