<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Deep Boda</title>
    <description>The latest articles on DEV Community by Deep Boda (@deepboda).</description>
    <link>https://dev.to/deepboda</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2006876%2F6889d676-9039-4f66-979a-16313b6d284f.jpg</url>
      <title>DEV Community: Deep Boda</title>
      <link>https://dev.to/deepboda</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/deepboda"/>
    <language>en</language>
    <item>
      <title>Five broken pods. Kubernetes said Running for all five.</title>
      <dc:creator>Deep Boda</dc:creator>
      <pubDate>Sat, 05 Dec 2026 11:40:58 +0000</pubDate>
      <link>https://dev.to/deepboda/five-broken-pods-kubernetes-said-running-for-all-five-d4e</link>
      <guid>https://dev.to/deepboda/five-broken-pods-kubernetes-said-running-for-all-five-d4e</guid>
      <description>&lt;p&gt;I broke five Deployments on purpose in a lab cluster. A missing env var, a command that doesn't exist in the image, a memory limit that's too low, a migration written as a Deployment, and a liveness probe on the wrong port.&lt;/p&gt;

&lt;p&gt;Then I asked Kubernetes how they were doing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl get pods -n breakfix -o 'custom-columns=NAME:.metadata.name,PHASE:.status.phase,LAST:.status.containerStatuses[0].lastState.terminated.reason,EXIT:.status.containerStatuses[0].lastState.terminated.exitCode,RESTARTS:.status.containerStatuses[0].restartCount'
NAME                             PHASE     LAST         EXIT   RESTARTS
cache-warmer-676bdc54f6-b2w97    Running   OOMKilled    137    5
db-migrate-657dcb95cd-s45rc      Running   Completed    0      5
orders-api-5c9f9944f9-tbghc      Running   Error        1      5
report-worker-66cc4877f7-jpbrt   Running   StartError   128    5
web-dc8fdcb94-26gqv              Running   Completed    0      6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;PHASE says Running for all five. Every single one was in a crash loop.&lt;/p&gt;

&lt;p&gt;The plain &lt;code&gt;kubectl get pods&lt;/code&gt; isn't much better. The STATUS word keeps changing between CrashLoopBackOff, Error, RunContainerError and Running, depending on which second you look. The problem underneath doesn't change at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read Last State, not STATUS
&lt;/h2&gt;

&lt;p&gt;That long command above is the first thing I run now. It prints how each pod last died, which is the only part that matters. Keep the single quotes. On a Mac, zsh reads &lt;code&gt;[0]&lt;/code&gt; as a file pattern and stops with &lt;code&gt;no matches found&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For one pod, &lt;code&gt;kubectl describe pod &amp;lt;pod&amp;gt;&lt;/code&gt; and look for Last State. In the lab I got four different answers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reason: Error, Exit Code: 1.&lt;/strong&gt; The app exited on its own, so ask the app. &lt;code&gt;kubectl logs&lt;/code&gt; said &lt;code&gt;FATAL: DATABASE_URL is not set&lt;/code&gt;. A missing env var, a missing Secret key, a config file that isn't there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reason: StartError, Exit Code: 128.&lt;/strong&gt; The command in the YAML doesn't exist in the image. Mine said &lt;code&gt;exec: "node": executable file not found in $PATH&lt;/code&gt;. Nothing of mine ever ran, so the logs are empty and you can stare at them all day. Check the image itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run --rm --entrypoint sh &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;image&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; -c &lt;span class="s1"&gt;'which node'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reason: OOMKilled, Exit Code: 137.&lt;/strong&gt; The kernel killed it for memory. That's a different problem with a different fix, the limit against what the app really uses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reason: Completed, Exit Code: 0.&lt;/strong&gt; This one confused me. A clean exit, restarting forever. Two causes, and only Events at the bottom of &lt;code&gt;describe&lt;/code&gt; tell them apart:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only &lt;code&gt;Back-off restarting failed container&lt;/code&gt;: the task really finished. A one-off job, like a migration, written as a Deployment. Kubernetes keeps restarting it because Deployments are supposed to run forever. Make it a Job.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Container nginx failed liveness probe, will be restarted&lt;/code&gt;: Kubernetes is killing a healthy app. The probe was on port 8080 and nginx listens on 80. nginx shuts down cleanly when it gets SIGTERM, so the kill shows up as Completed, exit 0, like nothing happened.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The logs trap
&lt;/h2&gt;

&lt;p&gt;Right after a crash I ran &lt;code&gt;kubectl logs --previous&lt;/code&gt; and got this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;unable to retrieve container logs for containerd://d655270519f4302d1bef5757568e3169a73335b068b434af0d55b84cef14658d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Plain &lt;code&gt;kubectl logs&lt;/code&gt;, same pod, same moment, worked fine. About 20 seconds later, once the pod had moved into back-off, &lt;code&gt;--previous&lt;/code&gt; worked too. So if one of them comes back empty, run the other one before deciding there are no logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I check now, in order
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Last State reason and exit code, before opening any logs&lt;/li&gt;
&lt;li&gt;Exit 1: &lt;code&gt;kubectl logs&lt;/code&gt;, then &lt;code&gt;--previous&lt;/code&gt; if empty&lt;/li&gt;
&lt;li&gt;Exit 128: compare &lt;code&gt;command&lt;/code&gt; and &lt;code&gt;args&lt;/code&gt; with the image&lt;/li&gt;
&lt;li&gt;Exit 0: Events, liveness kill or a job that finished&lt;/li&gt;
&lt;li&gt;Exit 137: memory&lt;/li&gt;
&lt;li&gt;After the fix, watch RESTARTS. When it stops climbing, it's fixed&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The two charts behind this, with the full &lt;code&gt;describe&lt;/code&gt; output for each case, are in my &lt;a href="https://deepboda.in/shop/kubernetes-break-fix-free?utm_source=devto&amp;amp;utm_medium=post" rel="noopener noreferrer"&gt;free Kubernetes sampler&lt;/a&gt;. It has the 14 kubectl commands I actually use too. Pay nothing, or what you like.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>sre</category>
      <category>debugging</category>
    </item>
  </channel>
</rss>
