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. 教学模型——数字用于说明行为,并非基准测试。

概念

相关挑战

参考资料