<?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: Sagar</title>
    <description>The latest articles on DEV Community by Sagar (@sagar2395).</description>
    <link>https://dev.to/sagar2395</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%2F4196857%2F02a3f847-6a65-482f-b6a6-037c762af22e.jpg</url>
      <title>DEV Community: Sagar</title>
      <link>https://dev.to/sagar2395</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sagar2395"/>
    <language>en</language>
    <item>
      <title>Kubernetes rollout stuck in ImagePullBackOff: roll back to a revision you checked</title>
      <dc:creator>Sagar</dc:creator>
      <pubDate>Fri, 20 Nov 2026 08:21:52 +0000</pubDate>
      <link>https://dev.to/sagar2395/kubernetes-rollout-stuck-in-imagepullbackoff-roll-back-to-a-revision-you-checked-nde</link>
      <guid>https://dev.to/sagar2395/kubernetes-rollout-stuck-in-imagepullbackoff-roll-back-to-a-revision-you-checked-nde</guid>
      <description>&lt;p&gt;Your Deployment's rollout never finished: &lt;code&gt;kubectl rollout status&lt;/code&gt; sits on &lt;code&gt;Waiting for deployment "go-api" rollout to finish: 1 old replicas are pending termination...&lt;/code&gt;, and &lt;code&gt;kubectl get pods&lt;/code&gt; shows the old pod &lt;code&gt;Running&lt;/code&gt; next to a new one in &lt;code&gt;ErrImagePull&lt;/code&gt; or &lt;code&gt;ImagePullBackOff&lt;/code&gt;. That almost always means the new release points at an image the node cannot pull, so Kubernetes keeps the old pod serving and waits. The fix is a rollback, but not the one most people type first. &lt;code&gt;kubectl rollout undo&lt;/code&gt; without a revision number goes to "the previous revision", and if anyone runs it twice, the broken release comes back.&lt;/p&gt;

&lt;p&gt;I broke a small Go service on purpose to show the whole thing on a real cluster: a release with an image tag that was never pushed, the diagnosis, the rollback, the trap, and the rollback I'd actually run on a Friday evening. Every output below is copied from that recording.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a stuck rollout looks like
&lt;/h2&gt;

&lt;p&gt;A stuck rollout is a Deployment whose new ReplicaSet never gets a Ready pod, so the rollout neither finishes nor fails right away. Before the bad release, the service ran one pod on &lt;code&gt;go-api:v1.2.0&lt;/code&gt;, with one revision in its history:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl get deploy go-api -n go-api -o wide
NAME     READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES          SELECTOR
go-api   1/1     1            1           71s   go-api       go-api:v1.2.0   &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;go-api,...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I cut the selector short.) Then a new release went out with &lt;code&gt;go-api:v99.9.9&lt;/code&gt;, a tag nobody ever pushed. The pipeline goes red, or worse, it goes green because it only checked that &lt;code&gt;kubectl apply&lt;/code&gt; succeeded.&lt;/p&gt;

&lt;p&gt;The first question is the one people skip: is it deployed or not? Don't ask the pipeline. Ask the rollout.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout status deploy/go-api -n go-api
Waiting &lt;span class="k"&gt;for&lt;/span&gt; deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; rollout to finish: 1 old replicas are pending termination...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It never returns, so I stopped it with Ctrl-C. "1 old replicas are pending termination" tells you the old pod is still there because the new one hasn't become ready. Now the pods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl get pods -n go-api
NAME                      READY   STATUS         RESTARTS   AGE
go-api-5d8497557b-nrv9d   1/1     Running        0          2m59s
go-api-6c8fb7c7bf-v8gm4   0/1     ErrImagePull   0          39s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two pods. The old one, running and ready. The new one, not ready, because Kubernetes could not pull its image. If you run the command a few seconds later you may see &lt;code&gt;ImagePullBackOff&lt;/code&gt; instead: the kubelet alternates between the two as it retries, waiting longer between attempts up to five minutes (kubernetes.io, Images).&lt;/p&gt;

&lt;p&gt;And the users? The app's version endpoint, read from the browser while the rollout was stuck, still answered with the old build:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc1q26rhgvtbp9r77ai44.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fc1q26rhgvtbp9r77ai44.png" alt="The app's /version endpoint during the stuck rollout still returns &amp;quot;version&amp;quot;: &amp;quot;v1.2.0&amp;quot;" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nothing is down. That's exactly why this failure is easy to miss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why users don't notice: the rolling update waits
&lt;/h2&gt;

&lt;p&gt;A rolling update only removes an old pod once a new pod is Ready. The Deployment creates a new ReplicaSet for the new pod template and scales it up, and it scales the old one down only as new pods become available. With one replica and the default &lt;code&gt;maxUnavailable&lt;/code&gt; of 25% (rounded down to zero) and &lt;code&gt;maxSurge&lt;/code&gt; of 25% (rounded up to one), Kubernetes may add one extra pod but may not take the only available one away (kubernetes.io, Deployments: rolling update).&lt;/p&gt;

&lt;p&gt;The new pod can't pull its image, so it never becomes Ready, so the old pod is never removed. You have a stuck deploy, not an outage. The same mechanism that protects your users also hides the failure from anyone who only watches error rates.&lt;/p&gt;

&lt;h2&gt;
  
  
  Find the reason in the pod's events
&lt;/h2&gt;

&lt;p&gt;The pod's events name the image the kubelet tried to pull and the registry's answer. I described the new pod and paged to the Events section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl describe pod -n go-api go-api-6c8fb7c7bf-v8gm4
...
Events:
  Type     Reason     Age                 From               Message
  ----     ------     ----                ----               -------
  Normal   Scheduled  91s                 default-scheduler  Successfully assigned go-api/go-api-6c8fb7c7bf-v8gm4 to k3d-snowops-agent-0
  Normal   BackOff    19s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 89s&lt;span class="o"&gt;)&lt;/span&gt;   kubelet            spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Back-off pulling image &lt;span class="s2"&gt;"go-api:v99.9.9"&lt;/span&gt;
  Warning  Failed     19s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 89s&lt;span class="o"&gt;)&lt;/span&gt;   kubelet            spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Error: ImagePullBackOff
  Normal   Pulling    7s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 91s&lt;span class="o"&gt;)&lt;/span&gt;    kubelet            spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Pulling image &lt;span class="s2"&gt;"go-api:v99.9.9"&lt;/span&gt;
  Warning  Failed     6s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 89s&lt;span class="o"&gt;)&lt;/span&gt;    kubelet            spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Failed to pull image &lt;span class="s2"&gt;"go-api:v99.9.9"&lt;/span&gt;: failed to pull and unpack image &lt;span class="s2"&gt;"docker.io/library/go-api:v99.9.9"&lt;/span&gt;: failed to resolve reference &lt;span class="s2"&gt;"docker.io/library/go-api:v99.9.9"&lt;/span&gt;: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
  Warning  Failed     6s &lt;span class="o"&gt;(&lt;/span&gt;x4 over 89s&lt;span class="o"&gt;)&lt;/span&gt;    kubelet            spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Error: ErrImagePull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I joined the wrapped lines and lined up the columns. The text is unchanged.)&lt;/p&gt;

&lt;p&gt;Two things in there are worth reading slowly. The image is &lt;code&gt;go-api:v99.9.9&lt;/code&gt;, the tag that was never pushed. And the error does not say "tag not found". It says &lt;code&gt;pull access denied, repository does not exist or may require authorization&lt;/code&gt;. A short image name with no registry is resolved to &lt;code&gt;docker.io/library/...&lt;/code&gt;, and Docker Hub answers a missing repository with an authorization error. So that message can mean a missing image as easily as missing credentials. Check the name and tag before you go hunting for pull secrets.&lt;/p&gt;

&lt;p&gt;Each release of a Deployment is a ReplicaSet, and you can see both side by side with their images:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl get rs -n go-api -o wide
NAME                DESIRED   CURRENT   READY   AGE     CONTAINERS   IMAGES           SELECTOR
go-api-5d8497557b   1         1         1       4m21s   go-api       go-api:v1.2.0    &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;go-api,...
go-api-6c8fb7c7bf   1         1         0       2m1s    go-api       go-api:v99.9.9   &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;go-api,...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The old release has its pod ready. The new one has one pod and none ready.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiod1huvuxx4cxwmrq2j7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fiod1huvuxx4cxwmrq2j7.png" alt="Prometheus alert LabFaultImagePullBackOff firing on kube_pod_container_status_waiting_reason with reason ImagePullBackOff or ErrImagePull" width="800" height="403"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the lab, a Prometheus alert on &lt;code&gt;kube_pod_container_status_waiting_reason&lt;/code&gt; with &lt;code&gt;reason=~"ImagePullBackOff|ErrImagePull"&lt;/code&gt; fired a minute later. That metric comes from kube-state-metrics. If your error-rate alerts stayed quiet during a failed release, an alert like this is the gap.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the history before you undo anything
&lt;/h2&gt;

&lt;p&gt;Every change to a Deployment's pod template creates a numbered revision, and &lt;code&gt;kubectl rollout history&lt;/code&gt; lists them (kubernetes.io, checking rollout history):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout &lt;span class="nb"&gt;history&lt;/span&gt; deploy/go-api -n go-api
deployment.apps/go-api
REVISION  CHANGE-CAUSE
1         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;none&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
2         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;none&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The list only shows numbers. To see what a revision holds, ask for it by number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout &lt;span class="nb"&gt;history&lt;/span&gt; deploy/go-api -n go-api --revision=2
deployment.apps/go-api with revision &lt;span class="c"&gt;#2&lt;/span&gt;
Pod Template:
  ...
  Containers:
   go-api:
    Image:      go-api:v99.9.9
  ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I trimmed the labels, ports, resources and probes.) Revision 2 is the bad release. Revision 1 is the one to go back to.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does CHANGE-CAUSE show &lt;code&gt;&amp;lt;none&amp;gt;&lt;/code&gt;?
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;CHANGE-CAUSE&lt;/code&gt; is copied from the Deployment's &lt;code&gt;kubernetes.io/change-cause&lt;/code&gt; annotation when a revision is created, and nothing sets that annotation unless you do. The old &lt;code&gt;--record&lt;/code&gt; flag used to fill it and is deprecated. Set it yourself as part of the release, for example &lt;code&gt;kubectl annotate deploy/go-api -n go-api kubernetes.io/change-cause="release 1.3.0, image go-api:v1.3.0"&lt;/code&gt; right after the change. Then your history tells you which revision is which without opening each one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The first rollback works
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;kubectl rollout undo&lt;/code&gt; with no flags rolls the Deployment back to the previous revision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout undo deploy/go-api -n go-api
deployment.apps/go-api rolled back

$ kubectl rollout status deploy/go-api -n go-api
deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; successfully rolled out

$ kubectl get pods -n go-api
NAME                      READY   STATUS    RESTARTS   AGE
go-api-5d8497557b-nrv9d   1/1     Running   0          6m24s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time &lt;code&gt;rollout status&lt;/code&gt; answers at once. And look at the pod: same name as before the release, six minutes old, zero restarts. The rollback restarted nothing. The pod template went back to the one the old ReplicaSet already had, so the Deployment kept that ReplicaSet's pod and scaled the stuck one to zero. Users never saw a thing.&lt;/p&gt;

&lt;p&gt;Most people stop here. Look at the history first:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout &lt;span class="nb"&gt;history&lt;/span&gt; deploy/go-api -n go-api
deployment.apps/go-api
REVISION  CHANGE-CAUSE
2         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;none&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
3         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;none&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Revision 1 is gone. Undo didn't delete anything. It copied revision 1's pod template forward and made it the newest revision, number 3. Keep that in mind.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trap: undo, twice
&lt;/h2&gt;

&lt;p&gt;Now picture the Friday version of this. A colleague sees the red pipeline and runs the same rollback. Or the pipeline's retry does. Same command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout undo deploy/go-api -n go-api
deployment.apps/go-api rolled back

$ kubectl get pods -n go-api
NAME                      READY   STATUS         RESTARTS   AGE
go-api-5d8497557b-nrv9d   1/1     Running        0          7m6s
go-api-6c8fb7c7bf-tgdg8   0/1     ErrImagePull   0          7s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Rolled back", it says, and the broken pod is back. The history shows why:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout &lt;span class="nb"&gt;history&lt;/span&gt; deploy/go-api -n go-api
deployment.apps/go-api
REVISION  CHANGE-CAUSE
3         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;none&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
4         &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;none&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Undo means "the previous revision", whatever that is right now. After the first undo, the previous revision was the bad release, so the second undo restored it as revision 4. Two undos in a row put you exactly where you started. The command even reports success both times.&lt;/p&gt;

&lt;h2&gt;
  
  
  Roll back to a revision you checked
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;kubectl rollout undo --to-revision=N&lt;/code&gt; rolls back to the revision you name, and gives the same result no matter who ran what before you (kubectl rollout undo). So the safe order is: read the revision, then name it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout &lt;span class="nb"&gt;history&lt;/span&gt; deploy/go-api -n go-api --revision=3
deployment.apps/go-api with revision &lt;span class="c"&gt;#3&lt;/span&gt;
Pod Template:
  Labels:       &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;go-api
                ...
                pod-template-hash=5d8497557b
  ...
  Containers:
   go-api:
    Image:      go-api:v1.2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;v1.2.0&lt;/code&gt;, the build users were on. Now roll back to it by number and prove it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ kubectl rollout undo deploy/go-api -n go-api --to-revision=3
deployment.apps/go-api rolled back

$ kubectl rollout status deploy/go-api -n go-api
deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; successfully rolled out

$ kubectl get pods -n go-api
NAME                      READY   STATUS    RESTARTS   AGE
go-api-5d8497557b-nrv9d   1/1     Running   0          8m31s

$ kubectl get rs -n go-api -o wide
NAME                DESIRED   CURRENT   READY   AGE     CONTAINERS   IMAGES           SELECTOR
go-api-5d8497557b   1         1         1       8m43s   go-api       go-api:v1.2.0    &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;go-api,...
go-api-6c8fb7c7bf   0         0         0       6m23s   go-api       go-api:v99.9.9   &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;go-api,...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One pod, the same one as at the very start. The good ReplicaSet has its pod. The bad one is scaled to zero but still there, because it's still in the revision history. The next plain undo could find it again, which is why the release itself still has to be fixed. The version endpoint answered &lt;code&gt;v1.2.0&lt;/code&gt; again, and the lab's own check passed.&lt;/p&gt;

&lt;p&gt;Run this way, a second engineer typing the same command changes nothing. That's the property you want from anything people might run during an incident.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions people ask next
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does rollout undo revert ConfigMaps and Secrets?
&lt;/h3&gt;

&lt;p&gt;No. A revision is created only when the pod template (&lt;code&gt;.spec.template&lt;/code&gt;) changes, and a rollback restores only the pod template (kubernetes.io, rolling back a Deployment). If the release also changed a ConfigMap or a Secret that the pods read, undo puts the old image back but leaves the new config in place. Revert the config separately, or version it by name (for example &lt;code&gt;app-config-v2&lt;/code&gt;) so the pod template references it and a rollback brings the old name back too.&lt;/p&gt;

&lt;h3&gt;
  
  
  Will Argo CD or Flux overwrite my manual rollback?
&lt;/h3&gt;

&lt;p&gt;Often, yes. A GitOps controller makes the cluster match Git. With Argo CD's automated sync and self-heal on, a manual &lt;code&gt;rollout undo&lt;/code&gt; is drift and gets reverted (Argo CD automated sync). Flux reapplies the manifests on its reconcile interval. In a GitOps setup the rollback is a revert commit in Git. If you need the cluster fixed before that merges, pause the controller first (turn off auto-sync for the Argo CD application, or &lt;code&gt;flux suspend kustomization &amp;lt;name&amp;gt;&lt;/code&gt;), roll back by revision, then put the revert in Git and resume.&lt;/p&gt;

&lt;h3&gt;
  
  
  Doesn't Kubernetes give up on a stuck rollout by itself?
&lt;/h3&gt;

&lt;p&gt;It reports, it doesn't act. After &lt;code&gt;progressDeadlineSeconds&lt;/code&gt; (600 seconds by default) the Deployment gets a &lt;code&gt;Progressing&lt;/code&gt; condition with status &lt;code&gt;False&lt;/code&gt; and reason &lt;code&gt;ProgressDeadlineExceeded&lt;/code&gt;, and &lt;code&gt;kubectl rollout status&lt;/code&gt; exits with a non-zero code. Kubernetes takes no other action, so there is no automatic rollback (kubernetes.io, failed Deployment). That non-zero exit is useful: run &lt;code&gt;kubectl rollout status&lt;/code&gt; as a gate in the pipeline and a release that never finishes turns the pipeline red instead of green.&lt;/p&gt;

&lt;h3&gt;
  
  
  Roll back or fix forward?
&lt;/h3&gt;

&lt;p&gt;At 5pm on a Friday, roll back to a checked revision, then find out on Monday why the tag was missing. If you know the right tag and know it exists, &lt;code&gt;kubectl set image deploy/go-api go-api=go-api:&amp;lt;known-good-tag&amp;gt; -n go-api&lt;/code&gt; fixes forward. Either way, fix the source of the release (the manifest, the Helm values, the pipeline's tag) or the next deploy brings the bad tag back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other causes of a stuck rollout
&lt;/h2&gt;

&lt;p&gt;The same symptom, a rollout waiting on a new pod that never becomes Ready, has several causes besides an image that doesn't exist. Kubernetes lists insufficient quota, failing readiness probes, image pull errors, insufficient permissions, limit ranges and application runtime misconfiguration (kubernetes.io, failed Deployment). In practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pull errors with a real image&lt;/strong&gt;: a private registry without an &lt;code&gt;imagePullSecret&lt;/code&gt;, or a node that can't reach the registry. The event message tells these apart from a missing tag.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The pod starts but never gets Ready&lt;/strong&gt;: a readiness probe that fails on the new build. &lt;code&gt;describe pod&lt;/code&gt; shows &lt;code&gt;Readiness probe failed&lt;/code&gt; in the events.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The pod starts and crashes&lt;/strong&gt;: &lt;code&gt;CrashLoopBackOff&lt;/code&gt; on the new pod. The rollout waits exactly the same way. I wrote up how to find the real cause of a CrashLoopBackOff separately.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The pod is never created or never scheduled&lt;/strong&gt;: quota or limit range errors show up in &lt;code&gt;kubectl describe rs &amp;lt;new-replicaset&amp;gt;&lt;/code&gt;, and &lt;code&gt;Pending&lt;/code&gt; pods with &lt;code&gt;FailedScheduling&lt;/code&gt; events mean the cluster has no room.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The diagnosis order doesn't change: rollout status, the pods, the new pod's events, then the history.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it yourself
&lt;/h2&gt;

&lt;p&gt;On any test cluster, you can cause the same failure with one command on a throwaway Deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;set&lt;/span&gt; image deploy/&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;your-app&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;container&lt;span class="o"&gt;&amp;gt;=&amp;lt;&lt;/span&gt;its-image&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;:v99.9.9
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then work through it: rollout status, pods, events, history, undo, and undo again to see the trap.&lt;/p&gt;

&lt;p&gt;I ran this drill in SnowOps Labs, an open-source Kubernetes lab where you inject faults like this one into a real app and fix them (GitHub). Disclosure: I build it. The same fault is also a timed challenge there, par six minutes. My run took 1 minute 34 seconds with no hints.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frmwvjzj3ozrqumx2x22x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frmwvjzj3ozrqumx2x22x.png" alt="The SnowOps Labs Challenges page with &amp;quot;Restore the broken deploy&amp;quot; in progress and a timer against a six-minute par" width="800" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The ladder to remember
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;kubectl rollout status deploy/&amp;lt;name&amp;gt;&lt;/code&gt;: ask the rollout, not the pipeline.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl get pods&lt;/code&gt;: old pod Running, new pod &lt;code&gt;ErrImagePull&lt;/code&gt; or &lt;code&gt;ImagePullBackOff&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl describe pod &amp;lt;new-pod&amp;gt;&lt;/code&gt;: the Events name the image and the registry's answer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl rollout history deploy/&amp;lt;name&amp;gt; --revision=N&lt;/code&gt;: read the revision you want to go back to.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl rollout undo deploy/&amp;lt;name&amp;gt; --to-revision=N&lt;/code&gt;: never a bare undo during an incident.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl rollout status&lt;/code&gt; again, then fix the release itself.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;*This is part of a series I'm writing on debugging Kubernetes in production. You can find other videos on our Youtube channel &lt;a href="https://www.youtube.com/@snowopslearn" rel="noopener noreferrer"&gt;Snowops Learn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We also created a game &lt;a href="https://play.snowops.net" rel="noopener noreferrer"&gt;Snowops Night Shift&lt;/a&gt; in which you play as a Devops Engineer who gets new incidents daily, and you solve them based on kubernetes commands, logs and dashboards. The game is a simulation, but all logs and commands shown are from real cluster generated from &lt;a href="https://labs.snowops.net" rel="noopener noreferrer"&gt;Snowops Labs&lt;/a&gt;. &lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>sre</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Exit code 0, clean logs, six restarts: the liveness probe was killing a healthy app</title>
      <dc:creator>Sagar</dc:creator>
      <pubDate>Mon, 09 Nov 2026 09:39:49 +0000</pubDate>
      <link>https://dev.to/sagar2395/exit-code-0-clean-logs-six-restarts-the-liveness-probe-was-killing-a-healthy-app-3p0h</link>
      <guid>https://dev.to/sagar2395/exit-code-0-clean-logs-six-restarts-the-liveness-probe-was-killing-a-healthy-app-3p0h</guid>
      <description>&lt;p&gt;Your pod keeps restarting, but &lt;code&gt;kubectl get pods&lt;/code&gt; says &lt;code&gt;1/1 Running&lt;/code&gt;, the logs show no error, and the last exit code is &lt;code&gt;0&lt;/code&gt;. That pattern usually means nothing inside the container is failing. Something outside it is stopping a healthy app, and the usual suspect is a liveness probe. Run &lt;code&gt;kubectl describe pod&lt;/code&gt; and read the events at the bottom. If you see &lt;code&gt;Liveness probe failed: HTTP probe failed with statuscode: 404&lt;/code&gt;, the kubelet is killing your container on purpose.&lt;/p&gt;

&lt;p&gt;I broke a small Go service on purpose to show this on a real cluster. A values update changed one setting in its Deployment while a load generator sent it steady traffic. Every output below is copied from that recording (I lined up the columns, and cut long lines where noted).&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looked like from outside
&lt;/h2&gt;

&lt;p&gt;Users saw a flicker, not an outage. Most requests succeeded, and failures came in short bursts. The app's own request count dropped to almost nothing at the same moments, because with one replica there was no pod left to serve:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm5lgyn4kxl6629zjw8qf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm5lgyn4kxl6629zjw8qf.png" alt="Grafana: left, the app's own request rate drops to near zero in the shaded &amp;quot;no available pods&amp;quot; bands. Right, the load generator's requests show red failed tops in bursts" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The pod looked fine. Look at the restart count, though:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      READY   STATUS    RESTARTS        AGE
go-api-76995dc6c8-cfskf   1/1     Running   6 &lt;span class="o"&gt;(&lt;/span&gt;102s ago&lt;span class="o"&gt;)&lt;/span&gt;    5m42s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Six restarts in under six minutes, for a pod that was ready every time I looked. &lt;code&gt;kubectl get rs&lt;/code&gt; showed a new ReplicaSet about five minutes old and the old one scaled to zero, so a change to the pod template had just rolled out. Grafana's Pod Resources dashboard had caught the same pod in &lt;code&gt;CrashLoopBackOff&lt;/code&gt; between restarts:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fplmwzw17ourqquhijxwd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fplmwzw17ourqquhijxwd.png" alt="Grafana: container restarts for the go-api pod climb from 1 to 5 in five minutes, and the &amp;quot;Containers not running, by reason&amp;quot; panel shows CrashLoopBackOff for the same pod" width="800" height="254"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Running&lt;/code&gt; is a snapshot. After a few restarts the kubelet waits longer before each new start (kubernetes.io, container restarts), and in those gaps the same pod shows &lt;code&gt;CrashLoopBackOff&lt;/code&gt;. Look while a container is up and the pod reads healthy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The logs show a clean shutdown
&lt;/h2&gt;

&lt;p&gt;The previous container's last lines are where you'd expect a crash. There wasn't one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl logs go-api-76995dc6c8-cfskf &lt;span class="nt"&gt;--previous&lt;/span&gt; &lt;span class="nt"&gt;--tail&lt;/span&gt; 5 &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
...
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"time"&lt;/span&gt;:&lt;span class="s2"&gt;"2026-10-26T08:41:27.687561633Z"&lt;/span&gt;,&lt;span class="s2"&gt;"level"&lt;/span&gt;:&lt;span class="s2"&gt;"INFO"&lt;/span&gt;,&lt;span class="s2"&gt;"msg"&lt;/span&gt;:&lt;span class="s2"&gt;"request"&lt;/span&gt;,...,&lt;span class="s2"&gt;"path"&lt;/span&gt;:&lt;span class="s2"&gt;"/healthz"&lt;/span&gt;,&lt;span class="s2"&gt;"status"&lt;/span&gt;:404,...&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"time"&lt;/span&gt;:&lt;span class="s2"&gt;"2026-10-26T08:41:27.70856972Z"&lt;/span&gt;,&lt;span class="s2"&gt;"level"&lt;/span&gt;:&lt;span class="s2"&gt;"INFO"&lt;/span&gt;,&lt;span class="s2"&gt;"msg"&lt;/span&gt;:&lt;span class="s2"&gt;"received signal, shutting down"&lt;/span&gt;,&lt;span class="s2"&gt;"signal"&lt;/span&gt;:15&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"time"&lt;/span&gt;:&lt;span class="s2"&gt;"2026-10-26T08:41:27.709079931Z"&lt;/span&gt;,&lt;span class="s2"&gt;"level"&lt;/span&gt;:&lt;span class="s2"&gt;"INFO"&lt;/span&gt;,&lt;span class="s2"&gt;"msg"&lt;/span&gt;:&lt;span class="s2"&gt;"server stopped"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I dropped two normal &lt;code&gt;200&lt;/code&gt; request lines and the fields the terminal cut off.) Every line is &lt;code&gt;INFO&lt;/code&gt;. The app served requests, answered one request for &lt;code&gt;/healthz&lt;/code&gt; with a 404, then received signal 15 (SIGTERM) and stopped cleanly. It didn't crash. Something told it to stop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who stopped the container?
&lt;/h2&gt;

&lt;p&gt;The exit code tells you who to ask next. &lt;code&gt;kubectl describe pod&lt;/code&gt; has it under &lt;code&gt;Last State&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl describe pod go-api-76995dc6c8-cfskf &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
...
    Last State:     Terminated
      Reason:       Completed
      Exit Code:    0
      Started:      Mon, 26 Oct 2026 14:10:50 +0530
      Finished:     Mon, 26 Oct 2026 14:11:27 +0530
    Ready:          False
    Restart Count:  6
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Completed&lt;/code&gt; and exit code &lt;code&gt;0&lt;/code&gt; rule out the two usual stories. An app that crashes on its own exits with an error code, and its logs say why. A container the kernel kills for memory shows &lt;code&gt;OOMKilled&lt;/code&gt; and exit code 137 (kubernetes.io, determine the reason for pod failure). Exit code &lt;code&gt;0&lt;/code&gt; is this app's doing: it handles SIGTERM and shuts down gracefully. An app that ignores SIGTERM is killed after the grace period and shows 137 instead, so don't read the exit code alone. The events say who sent the signal.&lt;/p&gt;

&lt;p&gt;The container also lived exactly 37 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  The events name the kubelet
&lt;/h2&gt;

&lt;p&gt;The events are at the very end of the same &lt;code&gt;describe&lt;/code&gt; output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Events:
  Type     Reason     Age                   From      Message
  &lt;span class="nt"&gt;----&lt;/span&gt;     &lt;span class="nt"&gt;------&lt;/span&gt;     &lt;span class="nt"&gt;----&lt;/span&gt;                  &lt;span class="nt"&gt;----&lt;/span&gt;      &lt;span class="nt"&gt;-------&lt;/span&gt;
  ...
  Normal   Killing    2m23s &lt;span class="o"&gt;(&lt;/span&gt;x6 over 5m43s&lt;span class="o"&gt;)&lt;/span&gt; kubelet   spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Container go-api failed liveness probe, will be restarted
  Warning  BackOff    94s &lt;span class="o"&gt;(&lt;/span&gt;x7 over 2m23s&lt;span class="o"&gt;)&lt;/span&gt;   kubelet   spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Back-off restarting failed container go-api &lt;span class="k"&gt;in &lt;/span&gt;pod go-api-76995dc6c8-cfskf_go-api&lt;span class="o"&gt;(&lt;/span&gt;...&lt;span class="o"&gt;)&lt;/span&gt;
  ...
  Warning  Unhealthy  43s &lt;span class="o"&gt;(&lt;/span&gt;x19 over 6m3s&lt;span class="o"&gt;)&lt;/span&gt;   kubelet   spec.containers&lt;span class="o"&gt;{&lt;/span&gt;go-api&lt;span class="o"&gt;}&lt;/span&gt;: Liveness probe failed: HTTP probe failed with statuscode: 404
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I cut the Scheduled, Started, Pulled and Created lines and the pod's UID.) The kubelet, the agent on each node that runs the containers, asked the liveness probe's path 19 times, got a 404 every time, and killed the container six times. Higher up, the same output shows the probe:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    Liveness:   http-get http://:http/healthz &lt;span class="nv"&gt;delay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;15s &lt;span class="nb"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;5s &lt;span class="nv"&gt;period&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10s &lt;span class="c"&gt;#success=1 #failure=3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That explains the 37 seconds. The first probe runs 15 seconds after the start, then one every 10 seconds, and three failures in a row trigger a kill. The probes at roughly 15, 25 and 35 seconds all got a 404, and the app was gone at 37.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the probe fails
&lt;/h2&gt;

&lt;p&gt;An HTTP probe passes on any status from 200 to 399, and anything else counts as a failure (kubernetes.io, container probes). I opened both paths in the browser:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizew01oop6n9plg4xnuy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizew01oop6n9plg4xnuy.png" alt="Browser: go-api's /healthz answers &amp;quot;404 page not found&amp;quot;, while /health answers {&amp;quot;status&amp;quot;:&amp;quot;ok&amp;quot;}" width="800" height="300"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The app serves &lt;code&gt;/health&lt;/code&gt;. The values update had renamed the probe's path to &lt;code&gt;/healthz&lt;/code&gt;, the &lt;code&gt;/healthz&lt;/code&gt; convention many projects use, but not this app. One letter, and a perfectly healthy app was killed every 37 seconds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Liveness, readiness and startup probes do different jobs
&lt;/h3&gt;

&lt;p&gt;A readiness probe decides whether a pod gets traffic. When it fails, the pod leaves the Service but keeps running. A liveness probe decides whether the container is alive. When it fails, the kubelet restarts the container. A startup probe holds the other two off until the app has started once (kubernetes.io, configure probes). Here the readiness probe on &lt;code&gt;/ready&lt;/code&gt; passed between kills, which is why the pod kept reading &lt;code&gt;1/1&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tempting fix makes it slower, not better
&lt;/h2&gt;

&lt;p&gt;The quick fix many people try is to give the probe more patience. I raised &lt;code&gt;failureThreshold&lt;/code&gt; from 3 to 10 with &lt;code&gt;kubectl edit deploy go-api -n go-api&lt;/code&gt;. The restarts slowed down: ten failures ten seconds apart is about a hundred seconds per life instead of 37. The probe still asked for a path that returns 404, so the kills just came on a longer cycle. The lab's check still failed it, because it asks the probe's path the way the kubelet does.&lt;/p&gt;

&lt;p&gt;Deleting the probe is the same mistake made bigger. The dashboards go green, but nothing checks the app any more, so the next deadlock stays up serving errors until someone notices.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: point the probe at a path the app serves
&lt;/h2&gt;

&lt;p&gt;I put &lt;code&gt;failureThreshold&lt;/code&gt; back to 3 and changed the path to &lt;code&gt;/health&lt;/code&gt;, both in &lt;code&gt;kubectl edit&lt;/code&gt;. A one-line patch does the path:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nt"&gt;-n&lt;/span&gt; go-api patch deploy go-api &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s1"&gt;'[{"op":"replace","path":"/spec/template/spec/containers/0/livenessProbe/httpGet/path","value":"/health"}]'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;kubectl rollout undo deploy/go-api -n go-api&lt;/code&gt; works too. Then:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl rollout status deploy/go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
Waiting &lt;span class="k"&gt;for &lt;/span&gt;deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; rollout to finish: 1 old replicas are pending termination...
deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; successfully rolled out

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      READY   STATUS    RESTARTS   AGE
go-api-6bb665f764-mqm4m   1/1     Running   0          80s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Zero restarts after 80 seconds, more than twice the old lifetime. The pod's name tells one more story: &lt;code&gt;6bb665f764&lt;/code&gt; is the original ReplicaSet from before the bad change. With both settings back to what the chart sets, the pod template matched the old one again, so the Deployment scaled that ReplicaSet back up instead of making a new one (kubernetes.io, pod-template-hash).&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions people ask next
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Should a liveness probe check the database?
&lt;/h3&gt;

&lt;p&gt;No. A liveness endpoint that pings a dependency restarts every pod when that dependency blips, which turns a short database outage into an outage of your whole service. Liveness should check only that this process can make progress. Dependency checks belong in readiness, if anywhere.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I choose timeoutSeconds and failureThreshold?
&lt;/h3&gt;

&lt;p&gt;Size them so a slow moment isn't a death sentence, then check the arithmetic. Your app must start within &lt;code&gt;initialDelaySeconds&lt;/code&gt; plus &lt;code&gt;failureThreshold&lt;/code&gt; times &lt;code&gt;periodSeconds&lt;/code&gt;, or it is killed before it's ready, every time. If start-up is slow or varies, add a &lt;code&gt;startupProbe&lt;/code&gt; instead of stretching the liveness delay.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other reasons a liveness probe kills an app
&lt;/h2&gt;

&lt;p&gt;The event text tells them apart:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A path or port the app doesn't serve&lt;/strong&gt;: &lt;code&gt;statuscode: 404&lt;/code&gt;, or &lt;code&gt;connection refused&lt;/code&gt; for a wrong port. This drill.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A slow start&lt;/strong&gt;: the container dies at the same age on every restart, before it ever becomes ready. Add a startup probe.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A timeout under load&lt;/strong&gt;: &lt;code&gt;context deadline exceeded&lt;/code&gt;, and kills that come with traffic peaks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A dependency check&lt;/strong&gt;: every pod restarts at the same moment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To reproduce this on a test cluster, patch a Deployment's probe to a path its app doesn't serve:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nt"&gt;-n&lt;/span&gt; &amp;lt;ns&amp;gt; patch deploy &amp;lt;app&amp;gt; &lt;span class="nt"&gt;--type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s1"&gt;'[{"op":"replace","path":"/spec/template/spec/containers/0/livenessProbe/httpGet/path","value":"/healthz"}]'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran it as a drill in &lt;a href="https://labs.snowops.net" rel="noopener noreferrer"&gt;SnowOps Labs&lt;/a&gt; (disclosure: I build it).&lt;/p&gt;

&lt;h2&gt;
  
  
  The ladder to remember
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;RESTARTS&lt;/code&gt; climbing on a &lt;code&gt;Running&lt;/code&gt; pod is the first clue. Don't trust the snapshot.&lt;/li&gt;
&lt;li&gt;Read &lt;code&gt;Last State&lt;/code&gt; in &lt;code&gt;kubectl describe pod&lt;/code&gt;. Exit code &lt;code&gt;0&lt;/code&gt; or &lt;code&gt;Completed&lt;/code&gt; means read the events, not just the logs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Liveness probe failed&lt;/code&gt; in the events means the kubelet is the one stopping it.&lt;/li&gt;
&lt;li&gt;Open the probe's path yourself and compare it with what the app serves.&lt;/li&gt;
&lt;li&gt;Fix the probe. Don't delete it, and don't only raise the threshold.&lt;/li&gt;
&lt;li&gt;Prove it: zero restarts after more than one old lifetime.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;*This is part of a series I'm writing on debugging Kubernetes in production. You can also simulate this and many other scenarios and incident in our free and open source project &lt;a href="https://labs.snowops.net" rel="noopener noreferrer"&gt;snowopslabs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Github link - &lt;a href="https://www.github.com/sagar2395/snowopslabs" rel="noopener noreferrer"&gt;https://www.github.com/sagar2395/snowopslabs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>sre</category>
      <category>devops</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Kubernetes CPU throttling: p99 in seconds, no restarts, and a limit that's too low</title>
      <dc:creator>Sagar</dc:creator>
      <pubDate>Fri, 30 Oct 2026 08:15:33 +0000</pubDate>
      <link>https://dev.to/sagar2395/kubernetes-cpu-throttling-p99-in-seconds-no-restarts-and-a-limit-thats-too-low-39pm</link>
      <guid>https://dev.to/sagar2395/kubernetes-cpu-throttling-p99-in-seconds-no-restarts-and-a-limit-thats-too-low-39pm</guid>
      <description>&lt;p&gt;Your service is slow and nothing looks wrong. The p99 latency is in seconds, the median is fine, every pod is &lt;code&gt;Running&lt;/code&gt; and &lt;code&gt;Ready&lt;/code&gt; with &lt;code&gt;0&lt;/code&gt; restarts, and the nodes are nearly idle. That pattern usually means a CPU limit is throttling the container: it isn't killed, it's paused. Compare &lt;code&gt;kubectl top pod&lt;/code&gt; with the CPU limit in &lt;code&gt;kubectl describe pod&lt;/code&gt;. If the two numbers match, the pod is capped.&lt;/p&gt;

&lt;p&gt;I broke a small Go service on purpose to show this on a real cluster: a "cost review" lowered its CPU limit while a load generator sent it steady traffic. Every output below is copied from that recording (I lined up the columns).&lt;/p&gt;

&lt;h2&gt;
  
  
  What throttling looks like from outside
&lt;/h2&gt;

&lt;p&gt;A throttled pod passes every health check you'd normally look at. The latency alert fired because the p99 stayed above half a second, but the error rate was flat and the pod looked healthy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      READY   STATUS    RESTARTS   AGE
go-api-649df775bd-md4lq   1/1     Running   0          4m15s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The nodes weren't busy either, so this wasn't a neighbour stealing CPU:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl top nodes
NAME                    CPU&lt;span class="o"&gt;(&lt;/span&gt;cores&lt;span class="o"&gt;)&lt;/span&gt;   CPU&lt;span class="o"&gt;(&lt;/span&gt;%&lt;span class="o"&gt;)&lt;/span&gt;   MEMORY&lt;span class="o"&gt;(&lt;/span&gt;bytes&lt;span class="o"&gt;)&lt;/span&gt;   MEMORY&lt;span class="o"&gt;(&lt;/span&gt;%&lt;span class="o"&gt;)&lt;/span&gt;
k3d-snowops-agent-0-0   151m         3%       860Mi           10%
k3d-snowops-agent-1-0   154m         3%       444Mi           5%
k3d-snowops-server-0    399m         9%       3085Mi          38%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;kubectl rollout history&lt;/code&gt; showed a second revision, so the pod template had changed. That's the "what changed?" clue, but the history doesn't say what.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare top with the limit
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;kubectl top pod&lt;/code&gt; shows what a container uses, and &lt;code&gt;kubectl describe pod&lt;/code&gt; shows what it's allowed. Put them side by side:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl top pod &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      CPU&lt;span class="o"&gt;(&lt;/span&gt;cores&lt;span class="o"&gt;)&lt;/span&gt;   MEMORY&lt;span class="o"&gt;(&lt;/span&gt;bytes&lt;span class="o"&gt;)&lt;/span&gt;
go-api-649df775bd-md4lq   11m          29Mi

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl describe pod go-api-649df775bd-md4lq &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
...
    Limits:
      cpu:     11m
      memory:  128Mi
    Requests:
      cpu:     11m
      memory:  32Mi
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I cut the rest of the describe output.) 11m of CPU looks like an idle pod. It isn't. It's exactly the limit, and a pod that sits on its limit in every sample is using everything it's allowed. The lab picks this limit from a measurement of your machine, so your number will differ. The match is what matters.&lt;/p&gt;

&lt;p&gt;Grafana's Pod Resources dashboard made it plain. The &lt;code&gt;CPU throttled (share of periods)&lt;/code&gt; panel had go-api's pod throttled in nearly every period:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9g0h832p30vuib3ue0d8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9g0h832p30vuib3ue0d8.png" alt="Grafana panel &amp;quot;CPU throttled (share of periods)&amp;quot;: the go-api pod sits near 100% for the whole five minutes" width="799" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Grafana panel "CPU throttled (share of periods)": the go-api pod sits near 100% for the whole five minutes&lt;/p&gt;

&lt;p&gt;That panel is the ratio of two cAdvisor counters, which you can graph on any cluster with Prometheus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sum &lt;/span&gt;by &lt;span class="o"&gt;(&lt;/span&gt;namespace, pod&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;rate&lt;span class="o"&gt;(&lt;/span&gt;container_cpu_cfs_throttled_periods_total&lt;span class="o"&gt;{&lt;/span&gt;container!&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="o"&gt;}[&lt;/span&gt;2m]&lt;span class="o"&gt;))&lt;/span&gt;
  / &lt;span class="nb"&gt;sum &lt;/span&gt;by &lt;span class="o"&gt;(&lt;/span&gt;namespace, pod&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;rate&lt;span class="o"&gt;(&lt;/span&gt;container_cpu_cfs_periods_total&lt;span class="o"&gt;{&lt;/span&gt;container!&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="o"&gt;}[&lt;/span&gt;2m]&lt;span class="o"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why a CPU limit slows a pod instead of killing it
&lt;/h2&gt;

&lt;p&gt;A CPU limit is enforced as a quota of CPU time per scheduling period. The kernel gives the container its limit's share of each period (100 ms by default), and once the container has spent it, the container waits for the next period (kubernetes.io, how pods with resource limits are run). A memory limit is different: go over it and the container is killed with &lt;code&gt;OOMKilled&lt;/code&gt;. A CPU limit only holds the container back (kubernetes.io, assign CPU resources).&lt;/p&gt;

&lt;p&gt;So most requests land early in a period and finish fast. The unlucky ones arrive after the quota is spent, queue behind the work in progress, and wait one period or several. That's how the median stays flat while the p99 climbs to seconds, with no error anywhere.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does kubectl top show low CPU while the pod is throttled?
&lt;/h3&gt;

&lt;p&gt;Because a capped pod can never use more than its cap. &lt;code&gt;kubectl top&lt;/code&gt; reports what the container actually used, averaged over a short window (kubernetes.io, resource metrics pipeline). It can't show what the pod wanted. A pod pinned at its limit reads as a small, flat, round number. And a multi-threaded app can be throttled even when its average is below the limit, because several threads can burn a period's quota in a few milliseconds. Watch the throttled ratio, not only usage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding replicas didn't fix it
&lt;/h2&gt;

&lt;p&gt;Scaling out is the usual reflex for a slow service, so I tried it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl scale deploy/go-api &lt;span class="nt"&gt;--replicas&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3 &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
deployment.apps/go-api scaled

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl top pod &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      CPU&lt;span class="o"&gt;(&lt;/span&gt;cores&lt;span class="o"&gt;)&lt;/span&gt;   MEMORY&lt;span class="o"&gt;(&lt;/span&gt;bytes&lt;span class="o"&gt;)&lt;/span&gt;
go-api-649df775bd-gx4p8   8m           7Mi
go-api-649df775bd-md4lq   9m           25Mi
go-api-649df775bd-n2q6c   9m           7Mi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each pod got a third of the traffic and still sat just under the same 11m ceiling. The throttled panel showed all three throttled in roughly half or more of their periods:&lt;/p&gt;

&lt;p&gt;!The same panel after scaling to three replicas: the three go-api pods are still throttled in about 45% to 100% of periods&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqmin2wbwfdberv0f7i5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqmin2wbwfdberv0f7i5b.png" alt="The same panel after scaling to three replicas: the three go-api pods are still throttled in about 45% to 100% of periods" width="799" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The same panel after scaling to three replicas: the three go-api pods are still throttled in about 45% to 100% of periods&lt;/p&gt;

&lt;p&gt;The lab's check stayed red: &lt;code&gt;FAIL: go-api/go-api is still not sized for the load it serves.&lt;/code&gt; Replicas spread the load, but every pod keeps a ceiling below what it needs, and the cost review that set the limit now pays for three pods instead of one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Measure first, then set the limit
&lt;/h2&gt;

&lt;p&gt;You can't size a limit while the pod is capped, because &lt;code&gt;kubectl top&lt;/code&gt; reads the cap. So the fix has two steps. I scaled back to one replica and lifted the limit far above anything it had used, as a measuring step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl scale deploy/go-api &lt;span class="nt"&gt;--replicas&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;1 &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl &lt;span class="nb"&gt;set &lt;/span&gt;resources deploy/go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api &lt;span class="nt"&gt;--limits&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;cpu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;500m
deployment.apps/go-api resource requirements updated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A minute into steady load, &lt;code&gt;kubectl top&lt;/code&gt; showed the real demand:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl top pod &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      CPU&lt;span class="o"&gt;(&lt;/span&gt;cores&lt;span class="o"&gt;)&lt;/span&gt;   MEMORY&lt;span class="o"&gt;(&lt;/span&gt;bytes&lt;span class="o"&gt;)&lt;/span&gt;
go-api-6d5ddc4d8b-db7gc   24m          7Mi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;24m, and 23m a minute later. More than twice the old limit. Then I set it properly: a request near the steady use, so the scheduler is told the truth, and a limit with plenty of headroom for bursts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl &lt;span class="nb"&gt;set &lt;/span&gt;resources deploy/go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api &lt;span class="nt"&gt;--requests&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;cpu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;50m &lt;span class="nt"&gt;--limits&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;cpu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;200m
deployment.apps/go-api resource requirements updated

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl rollout status deploy/go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
Waiting &lt;span class="k"&gt;for &lt;/span&gt;deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; rollout to finish: 1 old replicas are pending termination...
deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; successfully rolled out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I left out the scale command's output and one repeated &lt;code&gt;Waiting&lt;/code&gt; line.) The request is the pod's guaranteed share of a busy node. The limit is the ceiling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proving the fix
&lt;/h2&gt;

&lt;p&gt;The fix shows on the user signal, not only on the resource signal. The server-side p99 fell from about 8 seconds back down to the median:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0rfcdbusoc2wlo3q48qa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0rfcdbusoc2wlo3q48qa.png" alt="Grafana &amp;quot;Latency percentiles (server-side)&amp;quot;: p99 drops from about 8 s to near zero after the limit is lifted, while p50 stays flat at zero the whole time" width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Grafana "Latency percentiles (server-side)": p99 drops from about 8 s to near zero after the limit is lifted, while p50 stays flat at zero the whole time&lt;/p&gt;

&lt;p&gt;On the throttled panel, the old pods' lines ended and the new pod drew no line at all. That panel only draws pods throttled in more than 5% of periods, so the new pod is under that. The lab's check then passed and closed the incident.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questions people ask next
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Should I remove CPU limits altogether?
&lt;/h3&gt;

&lt;p&gt;It's a common choice for latency-sensitive services, and a reasonable one. Without a limit the pod can use idle CPU on the node, and its request still guarantees it a share when the node is busy. Two catches: a namespace &lt;code&gt;LimitRange&lt;/code&gt; may add a default limit nobody chose (check &lt;code&gt;kubectl describe limitrange -n &amp;lt;ns&amp;gt;&lt;/code&gt;), and a pod only gets the &lt;code&gt;Guaranteed&lt;/code&gt; QoS class if its limits equal its requests. Keep a limit where you need either of those. And this is about the CPU limit only: memory can't be throttled, so keep the memory limit.&lt;/p&gt;

&lt;h3&gt;
  
  
  How much throttling is a problem?
&lt;/h3&gt;

&lt;p&gt;There's no universal threshold, so judge it against latency. In this lab, a limit of 1.5 times the measured demand still left the app throttled in about a sixth of its periods with p99 near 150 ms. At twice the demand, throttling was near zero and p99 went back to a few milliseconds. Graph the throttled ratio next to your p99 and look for the two moving together.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other causes of slow pods with no restarts
&lt;/h2&gt;

&lt;p&gt;Throttling is the cause where the pod's own CPU reads flat at a round number that equals its limit. If it doesn't, look elsewhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A busy node&lt;/strong&gt;: &lt;code&gt;kubectl top nodes&lt;/code&gt; near 100%, and a neighbour taking the CPU. The fix is placement or requests, not this pod's limit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Too few replicas for the traffic&lt;/strong&gt;: CPU per pod is high but below the limit. That's a job for scaling, or a HorizontalPodAutoscaler.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A slow dependency&lt;/strong&gt;: the app waits on a database or another service. Traces or the dependency's own latency show it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory pressure&lt;/strong&gt;: a tight memory limit causes garbage-collection pauses before it causes &lt;code&gt;OOMKilled&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it yourself
&lt;/h2&gt;

&lt;p&gt;On any test cluster with steady traffic on a Deployment, set a CPU limit far below what it uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;set &lt;/span&gt;resources deploy/&amp;lt;app&amp;gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &amp;lt;ns&amp;gt; &lt;span class="nt"&gt;--limits&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;cpu&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then work through it: p99 against the median, pods, nodes, &lt;code&gt;top&lt;/code&gt; against the limit, the throttled ratio, then measure and set.&lt;/p&gt;

&lt;p&gt;I ran this drill in SnowOps Labs, an open-source Kubernetes lab where you inject faults like this one into a real app and fix them (GitHub). Disclosure: I build it. It measures your machine before it sets the limit, runs the load for you, and checks the limit you set, not just the moment's latency, so scaling out or stopping the traffic won't pass.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ladder to remember
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Compare p99 with the median. Slow but not broken means something is waiting.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl get pods&lt;/code&gt; and &lt;code&gt;kubectl top nodes&lt;/code&gt;: no restarts, no busy node.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl top pod&lt;/code&gt; against the limit in &lt;code&gt;kubectl describe pod&lt;/code&gt;. Equal means capped.&lt;/li&gt;
&lt;li&gt;Check the throttled ratio (&lt;code&gt;container_cpu_cfs_throttled_periods_total&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Lift the limit, measure the real use under load.&lt;/li&gt;
&lt;li&gt;Set a request near that use and a limit with headroom, or remove the CPU limit.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;*This is part of a series I'm writing on debugging Kubernetes in production. I am building &lt;a href="https://www.github.com/sagar2395/snowopslabs" rel="noopener noreferrer"&gt;Snowopslabs&lt;/a&gt; which I have used to simulate this incident and resolve it. Check out this tool if you want to play around with Kubernetes incidents and scenarios and learn along the way.&lt;/p&gt;

</description>
      <category>sre</category>
      <category>kubernetes</category>
      <category>performance</category>
      <category>devops</category>
    </item>
    <item>
      <title>Pods Running, Service returns 503: the selector bug that fools everyone</title>
      <dc:creator>Sagar</dc:creator>
      <pubDate>Sun, 25 Oct 2026 06:58:32 +0000</pubDate>
      <link>https://dev.to/sagar2395/pods-running-service-returns-503-the-selector-bug-that-fools-everyone-5aln</link>
      <guid>https://dev.to/sagar2395/pods-running-service-returns-503-the-selector-bug-that-fools-everyone-5aln</guid>
      <description>&lt;p&gt;Every request to the app fails with a 503. The body says &lt;code&gt;no available server&lt;/code&gt;. And yet &lt;code&gt;kubectl get pods&lt;/code&gt; looks perfect:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; http://go-api.snowops.localhost/health
HTTP/1.1 503 Service Unavailable
Content-Type: text/plain&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;utf-8
X-Content-Type-Options: nosniff
Date: Mon, 12 Oct 2026 14:25:45 GMT
Content-Length: 20

no available server

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      READY   STATUS    RESTARTS   AGE
go-api-5d8497557b-7pfhz   1/1     Running   0          4m42s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One of one ready, zero restarts, nothing deployed. I broke a small Go service on purpose to walk through this one, because it fools people precisely by looking healthy everywhere you'd normally look. The commands below work on any cluster. The cause in my drill is one renamed label, and at the end I'll go through the other things that leave a Service with nowhere to send traffic.&lt;/p&gt;

&lt;h2&gt;
  
  
  The piece most people never check
&lt;/h2&gt;

&lt;p&gt;A request from outside reaches a pod in three hops. The ingress controller receives it and looks up the Service the route points at. The Service doesn't forward anything to "the app" in general. It forwards to a list of pod addresses, its endpoints. Then the request lands on one of those pods.&lt;/p&gt;

&lt;p&gt;That list isn't something you write by hand. A Service has a selector, a set of labels, and Kubernetes keeps the list up to date with every pod that carries all of those labels and is ready to serve. Today the list lives in EndpointSlice objects (Kubernetes docs: EndpointSlices). The older Endpoints object still exists, and &lt;code&gt;kubectl get endpoints&lt;/code&gt; still works, but newer clusters print a warning when you use it.&lt;/p&gt;

&lt;p&gt;Here is the healthy state, before I broke anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get endpoints go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
Warning: v1 Endpoints is deprecated &lt;span class="k"&gt;in &lt;/span&gt;v1.33+&lt;span class="p"&gt;;&lt;/span&gt; use discovery.k8s.io/v1 EndpointSlice
NAME     ENDPOINTS          AGE
go-api   10.42.0.136:8080   67s

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get endpointslices &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME           ADDRESSTYPE   PORTS   ENDPOINTS     AGE
go-api-kt9b6   IPv4          8080    10.42.0.136   82s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One address, the pod's IP, on port 8080. Keep that picture in mind. If the list is empty, the ingress has a route and a Service and nowhere to send the request. That is exactly what &lt;code&gt;no available server&lt;/code&gt; means. It comes from Traefik, the ingress controller in this lab, not from the app.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the outage looks like from the inside
&lt;/h2&gt;

&lt;p&gt;Before going to the terminal, I looked at the dashboard. A load generator (k6) had been sending the app steady traffic from inside the cluster, so there's a before and an after.&lt;/p&gt;

&lt;p&gt;This was the part that surprised me most:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fspgrgpbkqk685te7fshq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fspgrgpbkqk685te7fshq.png" alt="Grafana during the outage: the app's own 5xx error rate stays at zero while k6's failed request rate climbs to 100%" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Grafana during the outage: the app's own 5xx error rate stays at zero while k6's failed request rate climbs to 100%&lt;/p&gt;

&lt;p&gt;On the left, the app's own error rate. Flat at zero for the whole outage. On the right, what the client saw: every request failing. Both panels are telling the truth. No request reached the pod, so the pod had nothing to count, good or bad. Its metrics didn't go red, they went quiet.&lt;/p&gt;

&lt;p&gt;The panel that shows it best puts both sides on one chart:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgpeh7bn13dk4jd4xgmf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fgpeh7bn13dk4jd4xgmf1.png" alt="Offered vs served: k6 keeps offering about 50 requests a second (green) while the requests the app handles (yellow) fall away" width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Offered vs served: k6 keeps offering about 50 requests a second (green) while the requests the app handles (yellow) fall away&lt;/p&gt;

&lt;p&gt;Green is what k6 offered, yellow is what the app handled. Normally the two lines sit on top of each other. The gap between them is the outage.&lt;/p&gt;

&lt;p&gt;If your alerting only looks at what a service says about itself, this outage looks like a quiet afternoon. You need at least one signal from the client side: a synthetic check, a probe from outside the cluster, or the ingress controller's own metrics. An alert that watches pods won't help either, because the pods really are fine. What does work is an alert on the thing that broke. The lab ships one, and it was firing:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2603gp4bci0isht622ph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2603gp4bci0isht622ph.png" alt="Prometheus: the LabFaultServiceEndpointsEmpty rule firing, absent() over the Service's ready EndpointSlice endpoints for 1 minute" width="798" height="238"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Prometheus: the LabFaultServiceEndpointsEmpty rule firing, absent() over the Service's ready EndpointSlice endpoints for 1 minute&lt;/p&gt;

&lt;p&gt;It uses &lt;code&gt;absent()&lt;/code&gt; rather than &lt;code&gt;count(...) == 0&lt;/code&gt;, and the lab's rule file explains why: kube-state-metrics exports one series per endpoint address, so when there are no addresses there is no series at all, and a count would never fire. That's an easy rule to get wrong, and worth stealing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Find the tell: an empty endpoint list
&lt;/h2&gt;

&lt;p&gt;Back in the terminal, the order of checks follows the request. The pods are healthy, so check the link in the middle:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get endpoints go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
Warning: v1 Endpoints is deprecated &lt;span class="k"&gt;in &lt;/span&gt;v1.33+&lt;span class="p"&gt;;&lt;/span&gt; use discovery.k8s.io/v1 EndpointSlice
NAME     ENDPOINTS   AGE
go-api   &amp;lt;none&amp;gt;      7m27s

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get endpointslices &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME           ADDRESSTYPE   PORTS     ENDPOINTS   AGE
go-api-kt9b6   IPv4          &amp;lt;&lt;span class="nb"&gt;unset&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;   &amp;lt;&lt;span class="nb"&gt;unset&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;     7m41s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;none&amp;gt;&lt;/code&gt;. A few minutes ago that column held the pod's address. The EndpointSlice is still there, but it's empty. That's the tell: the Service exists, the pod exists, and the Service isn't selecting it.&lt;/p&gt;

&lt;p&gt;Nothing else would have told me. Nothing crashed, nothing restarted, and Kubernetes emits no event when a selector stops matching, because from its point of view nothing failed. The Service is doing exactly what its spec says.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare the selector with the labels
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;-o wide&lt;/code&gt; prints a Service's selector in the last column:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get svc go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api &lt;span class="nt"&gt;-o&lt;/span&gt; wide
NAME     TYPE        CLUSTER-IP      EXTERNAL-IP   PORT&lt;span class="o"&gt;(&lt;/span&gt;S&lt;span class="o"&gt;)&lt;/span&gt;    AGE   SELECTOR
go-api   ClusterIP   10.43.223.247   &amp;lt;none&amp;gt;        8080/TCP   8m    app.kubernetes.io/instance&lt;span class="o"&gt;=&lt;/span&gt;go-api,app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api-v2,app&lt;span class="o"&gt;=&lt;/span&gt;go-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(My terminal wrapped that last line, I joined it back.) Three labels. Now the labels the pod actually carries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api &lt;span class="nt"&gt;--show-labels&lt;/span&gt;
NAME                      READY   STATUS    RESTARTS   AGE     LABELS
go-api-5d8497557b-7pfhz   1/1     Running   0          8m16s   app.kubernetes.io/instance&lt;span class="o"&gt;=&lt;/span&gt;go-api,app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api,app&lt;span class="o"&gt;=&lt;/span&gt;go-api,pod-template-hash&lt;span class="o"&gt;=&lt;/span&gt;5d8497557b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Line them up and the difference is one value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Service wants:  app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api-v2
Pod carries:    app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two out of three labels match, and that counts for nothing. A selector is an AND: a pod has to carry every label in it (Kubernetes docs: labels and selectors). One key off, and not one pod matches.&lt;/p&gt;

&lt;p&gt;A small tip if you're doing this on your own cluster: I used &lt;code&gt;get -o wide&lt;/code&gt; rather than &lt;code&gt;kubectl describe svc&lt;/code&gt; here. &lt;code&gt;describe&lt;/code&gt; shows the selector too, but on this lab it also prints an annotation the drill leaves behind with the original selector in it, which gives the answer away. On your cluster &lt;code&gt;describe&lt;/code&gt; is fine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Which side is wrong?
&lt;/h2&gt;

&lt;p&gt;A mismatch has two sides, and you could make them agree from either one. The Deployment settles it. It selects its pods by labels too, and it stamps those labels onto every pod it creates:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get deploy go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api &lt;span class="nt"&gt;-o&lt;/span&gt; wide
NAME     READY   UP-TO-DATE   AVAILABLE   AGE     CONTAINERS   IMAGES          SELECTOR
go-api   1/1     1            1           8m33s   go-api       go-api:v1.2.0   &lt;span class="nv"&gt;app&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;go-api,app.kubernetes.io/instance&lt;span class="o"&gt;=&lt;/span&gt;go-api,app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;name=go-api&lt;/code&gt;. The pods are right, and the Service is the odd one out. There's a structural reason to fix it there as well: a Deployment's selector can't be changed after it's created (in &lt;code&gt;apps/v1&lt;/code&gt; it's immutable), while a Service's selector can be changed at any time, to anything, and Kubernetes accepts it without a warning. That's how this kind of drift gets in.&lt;/p&gt;

&lt;h2&gt;
  
  
  The tempting fix
&lt;/h2&gt;

&lt;p&gt;The Service wants a pod labelled &lt;code&gt;go-api-v2&lt;/code&gt;. So why not give the pod that label? It's one command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl label pod &lt;span class="nt"&gt;-n&lt;/span&gt; go-api go-api-5d8497557b-7pfhz app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api-v2 &lt;span class="nt"&gt;--overwrite&lt;/span&gt;
pod/go-api-5d8497557b-7pfhz labeled
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And it works, in the sense that requests flow again. The endpoint list fills back in and the health check returns 200. If you stopped here, you'd close the incident. But list the pods:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api &lt;span class="nt"&gt;--show-labels&lt;/span&gt;
NAME                      READY   STATUS    RESTARTS   AGE     LABELS
go-api-5d8497557b-2qwx4   1/1     Running   0          18s     app.kubernetes.io/instance&lt;span class="o"&gt;=&lt;/span&gt;go-api,app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api,app&lt;span class="o"&gt;=&lt;/span&gt;go-api,pod-template-hash&lt;span class="o"&gt;=&lt;/span&gt;5d8497557b
go-api-5d8497557b-7pfhz   1/1     Running   0          9m16s   app.kubernetes.io/instance&lt;span class="o"&gt;=&lt;/span&gt;go-api,app.kubernetes.io/name&lt;span class="o"&gt;=&lt;/span&gt;go-api-v2,app&lt;span class="o"&gt;=&lt;/span&gt;go-api,pod-template-hash&lt;span class="o"&gt;=&lt;/span&gt;5d8497557b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are two now. A ReplicaSet also finds its pods by their labels. The moment I relabelled the pod, it stopped matching the ReplicaSet's selector, so as far as the ReplicaSet was concerned it had lost a pod, and it made a replacement with the original labels. The docs describe this as isolating a pod from its ReplicaSet (Kubernetes docs: ReplicaSet), and it's normally used on purpose, to pull a misbehaving pod out of service for debugging.&lt;/p&gt;

&lt;p&gt;So the Service is now held up by one orphan pod that nothing owns. If it's evicted, or its node goes away, nothing replaces it and the 503s come back. And the next rollout creates pods from the template, which still says &lt;code&gt;go-api&lt;/code&gt;. The person doing that rollout won't connect it to today's incident.&lt;/p&gt;

&lt;p&gt;The lab's check wasn't fooled:&lt;/p&gt;

&lt;p&gt;!The SnowOps Labs check refuses the relabel: Not resolved yet, the Service wants "go-api-v2", pods are labelled "go-api"&lt;/p&gt;

&lt;p&gt;The SnowOps Labs check refuses the relabel: Not resolved yet, the Service wants "go-api-v2", pods are labelled "go-api"&lt;/p&gt;

&lt;p&gt;It compares the Service's selector with the Deployment's pod template rather than with whatever labels happen to be on a pod right now, for exactly this reason.&lt;/p&gt;

&lt;h2&gt;
  
  
  The real fix: change the Service
&lt;/h2&gt;

&lt;p&gt;First, undo the shortcut. Nothing owns the relabelled pod, so deleting it is permanent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl delete pod &lt;span class="nt"&gt;-n&lt;/span&gt; go-api go-api-5d8497557b-7pfhz
pod &lt;span class="s2"&gt;"go-api-5d8497557b-7pfhz"&lt;/span&gt; deleted from go-api namespace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then patch the Service's selector back to what the Deployment uses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl &lt;span class="nt"&gt;-n&lt;/span&gt; go-api patch svc go-api &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s1"&gt;'{"spec":{"selector":{"app.kubernetes.io/name":"go-api"}}}'&lt;/span&gt;
service/go-api patched
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;kubectl patch&lt;/code&gt; sends only the fields you give it, and for a Service the selector map is merged, so the other two labels stay as they were. Only &lt;code&gt;name&lt;/code&gt; changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prove it, in the order you found it
&lt;/h2&gt;

&lt;p&gt;I check in the same order I diagnosed, from the inside out. First the Service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get endpoints go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME     ENDPOINTS          AGE
go-api   10.42.2.168:8080   10m
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I dropped the deprecation warning from here on.) An address again, and a different one from the start. It belongs to the pod the ReplicaSet created, which is the one that should be serving. Then the same question from outside:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; http://go-api.snowops.localhost/health
HTTP/1.1 200 OK
Content-Length: 16
Content-Type: application/json
Date: Mon, 12 Oct 2026 14:32:28 GMT

&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;:&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same request as at the start, different answer. On the dashboard the app's request rate came back up to meet k6's, and the lab's check passed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it on your own cluster
&lt;/h2&gt;

&lt;p&gt;You don't need the lab for this one. Pick a Service in a test namespace, note its selector, and change one label to a value no pod carries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get svc &amp;lt;your-service&amp;gt; &lt;span class="nt"&gt;-o&lt;/span&gt; wide
kubectl patch svc &amp;lt;your-service&amp;gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s1"&gt;'{"spec":{"selector":{"&amp;lt;key&amp;gt;":"&amp;lt;value no pod has&amp;gt;"}}}'&lt;/span&gt;
kubectl get endpoints &amp;lt;your-service&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The endpoints go to &lt;code&gt;&amp;lt;none&amp;gt;&lt;/code&gt; straight away. Your pods stay Running and Ready, nothing restarts, and no event warns you. Patch the label back to undo it. Only do this on a test Service: a selector change moves traffic immediately.&lt;/p&gt;

&lt;p&gt;If you'd rather practise the whole incident, with traffic, the dashboards, the alert and a check that won't accept the relabel shortcut, it's one of the drills in SnowOps Labs, a free, open source Kubernetes lab that runs on a laptop. Disclosure: I build it. Every screenshot above is from it, and the code is on GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other ways to end up with no endpoints
&lt;/h2&gt;

&lt;p&gt;A renamed label is one cause. When &lt;code&gt;kubectl get endpoints&lt;/code&gt; comes back empty and your pods look fine, these are the others I'd check, roughly in this order. The Kubernetes guide to debugging Services walks through the same ground.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The pods aren't Ready.&lt;/strong&gt; Running isn't Ready. A pod failing its readiness probe is left out of the Service's ready endpoints, so a broken readiness probe empties the list just as well. &lt;code&gt;kubectl get pods&lt;/code&gt; shows &lt;code&gt;0/1&lt;/code&gt; in the READY column. Check that first, which is why it comes first in the recap below.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A typo in the label key, not the value.&lt;/strong&gt; &lt;code&gt;app.kubernetes.io/name&lt;/code&gt; against &lt;code&gt;app.kubernetes.io/Name&lt;/code&gt;, or &lt;code&gt;app&lt;/code&gt; against &lt;code&gt;application&lt;/code&gt;. Same result, harder to spot by eye. Compare the two outputs character by character.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The wrong namespace.&lt;/strong&gt; A Service only selects pods in its own namespace. A Service applied to &lt;code&gt;default&lt;/code&gt; while the pods live in &lt;code&gt;go-api&lt;/code&gt; has a perfect selector and no endpoints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A Service with no selector at all.&lt;/strong&gt; Then Kubernetes doesn't manage its endpoints, and they stay empty unless something creates EndpointSlices for it. That's intended for pointing a Service at something outside the cluster, and a surprise when it's a mistake.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Endpoints exist, but requests still fail.&lt;/strong&gt; Then it isn't this problem. Look at the Service's &lt;code&gt;targetPort&lt;/code&gt; against the port the container really listens on, and at what the ingress route points to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At work, the label usually changes somewhere other than the cluster: a Helm chart refactor that renames the selector labels, or a Service copied from another app with its app name left in. Whatever produced the change, fix it there as well (the chart, the Kustomize overlay, the GitOps repo), or the next sync puts the bad selector straight back.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;p&gt;When users get 503s and the pods look healthy:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;curl -i&lt;/code&gt; the URL, or open it, and confirm what users see.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl get pods&lt;/code&gt;: pods that aren't Ready also empty the endpoint list, so rule that out first.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl get endpoints &amp;lt;service&amp;gt;&lt;/code&gt; (or &lt;code&gt;get endpointslices&lt;/code&gt;): an empty list means the Service selects nothing.&lt;/li&gt;
&lt;li&gt;Compare &lt;code&gt;kubectl get svc &amp;lt;service&amp;gt; -o wide&lt;/code&gt; with &lt;code&gt;kubectl get pods --show-labels&lt;/code&gt;. One mismatched label is enough.&lt;/li&gt;
&lt;li&gt;Fix the Service (or whatever generates it), not the pods, and check that the endpoints come back before you check the URL.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;em&gt;This incident is resolved using snowops labs, which is the open source project I am building for simulating real world platform engineering scenarios. Checkout this project: &lt;a href="https://labs.snowops.net" rel="noopener noreferrer"&gt;snowopslabs&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>debugging</category>
      <category>devops</category>
      <category>sre</category>
    </item>
    <item>
      <title>CrashLoopBackOff: how to find the real cause (and why deleting the pod won't help)</title>
      <dc:creator>Sagar</dc:creator>
      <pubDate>Wed, 21 Oct 2026 11:48:23 +0000</pubDate>
      <link>https://dev.to/sagar2395/crashloopbackoff-how-to-find-the-real-cause-and-why-deleting-the-pod-wont-help-130g</link>
      <guid>https://dev.to/sagar2395/crashloopbackoff-how-to-find-the-real-cause-and-why-deleting-the-pod-wont-help-130g</guid>
      <description>&lt;p&gt;A config change goes out. A couple of minutes later every request to the app fails, and &lt;code&gt;kubectl get pods&lt;/code&gt; shows the status nobody wants to see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;NAME                      READY   STATUS             RESTARTS      AGE
go-api-7b45497dfd-qxqx2   0/1     CrashLoopBackOff   4 &lt;span class="o"&gt;(&lt;/span&gt;15s ago&lt;span class="o"&gt;)&lt;/span&gt;   115s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I broke a small Go service on purpose to walk through this one properly, from the first symptom to a fix you can prove. The commands work on any cluster. The specific bug is just one example, and I'll come back at the end to the other things that cause the same status.&lt;/p&gt;

&lt;h2&gt;
  
  
  What CrashLoopBackOff actually tells you
&lt;/h2&gt;

&lt;p&gt;It is easy to read CrashLoopBackOff as an error. It isn't one. It is Kubernetes describing what it is doing about an error.&lt;/p&gt;

&lt;p&gt;The container starts and then exits. The kubelet on the node restarts it, because the pod's &lt;code&gt;restartPolicy&lt;/code&gt; says so. If it exits again, the kubelet waits before the next try, and the wait grows each time: 10 seconds, 20, 40, and so on, capped at five minutes (Kubernetes docs: container restarts). While it is waiting, the pod shows &lt;code&gt;CrashLoopBackOff&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So the status answers "what is happening?" (the container keeps dying) and says nothing about why. That second question is the whole job, and the pod has already written the answer down somewhere. You just have to know where to read it.&lt;/p&gt;

&lt;h2&gt;
  
  
  First, check whether anyone is still being served
&lt;/h2&gt;

&lt;p&gt;Before digging into the crash, it's worth thirty seconds to find out how bad things are. A crash loop during a rollout is often harmless: with a rolling update and a readiness probe, the old pods keep serving until a new one becomes Ready. If the new pod never gets there, the rollout just stalls.&lt;/p&gt;

&lt;p&gt;A Deployment keeps one ReplicaSet per version of its pod template, so listing them tells you whether an older version is still up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get rs &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                DESIRED   CURRENT   READY   AGE
go-api-5d8497557b   0         0         0       5m46s
go-api-7b45497dfd   1         1         0       2m9s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Not good. The old ReplicaSet is at zero, and the new one wants a pod and has none ready. Nothing is serving. In my drill I set it up that way on purpose, but you get the same picture in real life with a &lt;code&gt;Recreate&lt;/code&gt; strategy, or when the crash only starts after the pod has already passed its readiness check. Either way, this isn't a stuck rollout any more. It's an outage.&lt;/p&gt;

&lt;p&gt;The browser agreed:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff0c9ipaaj5ewl6o4wqef.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff0c9ipaaj5ewl6o4wqef.png" alt="Snowopslabs - Kubernetes logs previous" width="800" height="132"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That message comes from the ingress. It had a route for the app and no ready pod to send the request to.&lt;/p&gt;

&lt;h3&gt;
  
  
  A detour worth taking: the dashboard that says everything is fine
&lt;/h3&gt;

&lt;p&gt;This was the part of the drill that surprised me most. Here is the Grafana dashboard during the outage. On the left is the app's own error rate (HTTP 5xx). On the right is the failure rate seen by k6, the load generator sending traffic from outside.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3bhy8leq2avmyxcqvobl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3bhy8leq2avmyxcqvobl.png" alt="Grafana dashboard" width="800" height="325"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The app reports zero errors. The client sees 100% of requests fail. Both are telling the truth: a process that never finishes starting can't count the requests it never received, so its own metrics go quiet rather than red. If your alerting only looks at what the service says about itself, a total outage can look like a calm afternoon. Watch at least one signal from the client side too, whether that's an ingress or load balancer metric, a synthetic check, or a probe from outside the cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the crash's last words: &lt;code&gt;kubectl logs --previous&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Plain &lt;code&gt;kubectl logs&lt;/code&gt; shows the current container. In a crash loop the current container has often just started, or hasn't started yet, so you get nothing useful. The container that just died is still on the node, and &lt;code&gt;--previous&lt;/code&gt; (or &lt;code&gt;-p&lt;/code&gt;) asks for its logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl logs &lt;span class="nt"&gt;-n&lt;/span&gt; go-api go-api-7b45497dfd-qxqx2 &lt;span class="nt"&gt;--previous&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"level"&lt;/span&gt;:&lt;span class="s2"&gt;"INFO"&lt;/span&gt;,&lt;span class="s2"&gt;"msg"&lt;/span&gt;:&lt;span class="s2"&gt;"server starting"&lt;/span&gt;,&lt;span class="s2"&gt;"port"&lt;/span&gt;:&lt;span class="s2"&gt;"80800"&lt;/span&gt;,&lt;span class="s2"&gt;"service"&lt;/span&gt;:&lt;span class="s2"&gt;"go-api"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"level"&lt;/span&gt;:&lt;span class="s2"&gt;"ERROR"&lt;/span&gt;,&lt;span class="s2"&gt;"msg"&lt;/span&gt;:&lt;span class="s2"&gt;"server error"&lt;/span&gt;,&lt;span class="s2"&gt;"error"&lt;/span&gt;:&lt;span class="s2"&gt;"listen tcp: address 80800: invalid port"&lt;/span&gt;&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(I trimmed the timestamps.) Two lines, and the second one is the answer. The server tried to listen on port 80800. Port numbers stop at 65535, so the bind fails and the process exits.&lt;/p&gt;

&lt;p&gt;Most of the time the logs get you this far. When they don't, the next command usually does.&lt;/p&gt;

&lt;h2&gt;
  
  
  Confirm it from Kubernetes' side: &lt;code&gt;kubectl describe pod&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;describe&lt;/code&gt; is long, so I pipe it into &lt;code&gt;less&lt;/code&gt; and search for &lt;code&gt;Last State&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl describe pod &lt;span class="nt"&gt;-n&lt;/span&gt; go-api go-api-7b45497dfd-qxqx2 | less
...
    Last State:     Terminated
      Reason:       Error
      Exit Code:    1
    Ready:          False
    Restart Count:  4
    ...
    Environment:
      PORT:                 80800
      READINESS_FAILURE:    &lt;span class="nb"&gt;false
      &lt;/span&gt;SHUTDOWN_TIMEOUT:     10s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three things to take from this block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The exit code.&lt;/strong&gt; &lt;code&gt;1&lt;/code&gt; means the app chose to exit with an error. Nothing killed it. If you see &lt;code&gt;137&lt;/code&gt; instead, the process got a SIGKILL (128 + 9), and a &lt;code&gt;Reason&lt;/code&gt; of &lt;code&gt;OOMKilled&lt;/code&gt; tells you it ran out of memory. Those two numbers send you down completely different paths, so it's worth reading this line before anything else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The environment.&lt;/strong&gt; The same 80800 again, now in the spec. So the bad value isn't something the app made up at runtime. Kubernetes handed it over.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The events at the bottom.&lt;/strong&gt; In this case they only confirm the loop: &lt;code&gt;Back-off restarting failed container&lt;/code&gt;. For other causes they carry the real clue, such as &lt;code&gt;Liveness probe failed&lt;/code&gt;, a missing ConfigMap or Secret, or an image that can't be pulled.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix everyone tries first
&lt;/h2&gt;

&lt;p&gt;With the pod clearly broken, deleting it is tempting. I tried:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl delete pod &lt;span class="nt"&gt;-n&lt;/span&gt; go-api go-api-7b45497dfd-qxqx2
pod &lt;span class="s2"&gt;"go-api-7b45497dfd-qxqx2"&lt;/span&gt; deleted

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      READY   STATUS             RESTARTS      AGE
go-api-7b45497dfd-4c995   0/1     CrashLoopBackOff   1 &lt;span class="o"&gt;(&lt;/span&gt;21s ago&lt;span class="o"&gt;)&lt;/span&gt;   22s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A new name, the same crash, within seconds. The pod was never the problem. A pod owned by a Deployment is a copy of the Deployment's pod template, and the ReplicaSet will keep making fresh copies of the same mistake for as long as you delete them. The only thing deleting achieved was resetting the restart counter, which made the situation look less serious than it was.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix it where it lives: the pod template
&lt;/h2&gt;

&lt;p&gt;So the question becomes where the template gets &lt;code&gt;PORT=80800&lt;/code&gt; from. &lt;code&gt;describe deploy&lt;/code&gt; shows the template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl describe deploy go-api &lt;span class="nt"&gt;-n&lt;/span&gt; go-api | less
...
  Containers:
   go-api:
    Image:      go-api:v1.2.0
    Port:       8080/TCP &lt;span class="o"&gt;(&lt;/span&gt;http&lt;span class="o"&gt;)&lt;/span&gt;
    Liveness:   http-get http://:http/health &lt;span class="nv"&gt;delay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;15s &lt;span class="nb"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;5s &lt;span class="nv"&gt;period&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10s
    Readiness:  http-get http://:http/ready &lt;span class="nv"&gt;delay&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10s &lt;span class="nb"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3s &lt;span class="nv"&gt;period&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;5s
    Environment:
      PORT:                 80800
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The container declares port 8080, both probes use that named port, and the environment variable says 80800. One zero too many. The fix goes on the Deployment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl &lt;span class="nt"&gt;-n&lt;/span&gt; go-api &lt;span class="nb"&gt;set env &lt;/span&gt;deploy/go-api &lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;8080
deployment.apps/go-api &lt;span class="nb"&gt;env &lt;/span&gt;updated
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Changing the template starts a new rollout. In a real team you'd make the same change in whatever produced the manifest (the Helm values, the Kustomize overlay, the GitOps repo) or the next sync will put the typo straight back. &lt;code&gt;kubectl set env&lt;/code&gt; is fine for stopping the bleeding, as long as the real fix follows it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;kubectl rollout undo deploy/go-api -n go-api&lt;/code&gt; would have worked too. It returns the template to the previous revision, environment included. When you're paged and you know the last change caused it, rolling back first and investigating second is often the right call.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prove the fix instead of assuming it
&lt;/h2&gt;

&lt;p&gt;Don't eyeball &lt;code&gt;get pods&lt;/code&gt; a few seconds after the change. &lt;code&gt;rollout status&lt;/code&gt; waits until the new pods are actually Ready:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl &lt;span class="nt"&gt;-n&lt;/span&gt; go-api rollout status deploy/go-api
Waiting &lt;span class="k"&gt;for &lt;/span&gt;deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; rollout to finish: 1 old replicas are pending termination...
deployment &lt;span class="s2"&gt;"go-api"&lt;/span&gt; successfully rolled out

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                      READY   STATUS    RESTARTS   AGE
go-api-5d8497557b-r47rn   1/1     Running   0          26s

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get rs &lt;span class="nt"&gt;-n&lt;/span&gt; go-api
NAME                DESIRED   CURRENT   READY   AGE
go-api-5d8497557b   1         1         1       9m8s
go-api-7b45497dfd   0         0         0       5m31s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look at the ReplicaSet names. Kubernetes didn't create a third one. The fixed template is identical to the one from before the bad change, so the Deployment scaled the old ReplicaSet back up. It's a small detail, but it's a nice confirmation that the template now matches the last version that worked.&lt;/p&gt;

&lt;p&gt;Then check from outside, the way users see it. The health URL answered again, and the request rate on the dashboard came back.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it on your own cluster
&lt;/h2&gt;

&lt;p&gt;You don't need anything special to reproduce this. On a test cluster, take any Deployment whose app reads its port from an environment variable and give it an impossible one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl &lt;span class="nb"&gt;set env &lt;/span&gt;deploy/&amp;lt;your-test-app&amp;gt; &lt;span class="nv"&gt;PORT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;80800
kubectl get pods &lt;span class="nt"&gt;-w&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With the default rolling update you'll likely see the stalled-rollout version: the old pod stays Running while the new one crash-loops. That's a useful thing to see for yourself, because it's exactly why the ReplicaSet check at the start matters. Put it back with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl rollout undo deploy/&amp;lt;your-test-app&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you'd rather practise the full outage version, with traffic, dashboards, alerts and a check that tells you when you've actually fixed it, this drill is one of the incidents in SnowOps Labs, a free, open-source Kubernetes lab that runs on a laptop. Disclosure: I build it. Every screenshot above is from it, and the code is on &lt;a href="https://www.github.com/sagar2395/snowopslabs" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5afyzizxlz8i9552x71.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd5afyzizxlz8i9552x71.png" alt="Snowopslabs UI" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Other causes of the same status
&lt;/h2&gt;

&lt;p&gt;The port typo is one cause among many. The Kubernetes docs group the usual suspects into application errors, configuration errors, resource limits, and failing health checks. In practice that looks like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A bug or a missing dependency in the app.&lt;/strong&gt; Logs with &lt;code&gt;--previous&lt;/code&gt; usually say so, often as a stack trace or a "connection refused" to a database that isn't there.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Missing or wrong configuration.&lt;/strong&gt; A typo like this one, a variable renamed in one place and not the other, a config file mounted at the wrong path, or a value that's fine in staging and wrong in production.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not enough memory.&lt;/strong&gt; Exit code 137 with &lt;code&gt;Reason: OOMKilled&lt;/code&gt; in &lt;code&gt;describe&lt;/code&gt;. Raise the limit or fix the leak, but find out which one first.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A liveness probe that kills a healthy app.&lt;/strong&gt; The app starts, the probe fails (too strict, wrong path, too short a delay for a slow start), and the kubelet restarts the container. The events say &lt;code&gt;Liveness probe failed&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The container never really starts.&lt;/strong&gt; A wrong &lt;code&gt;command&lt;/code&gt; or &lt;code&gt;args&lt;/code&gt;, an image built for another CPU architecture, a missing binary. Here the logs are often empty, because nothing ran long enough to write any. &lt;code&gt;describe&lt;/code&gt; and its events carry the message instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One extra tip from the docs on finding why a pod failed: set &lt;code&gt;terminationMessagePolicy: FallbackToLogsOnError&lt;/code&gt; on your containers. When a container fails without writing a termination message, Kubernetes then copies the last lines of its log into the pod status, so &lt;code&gt;describe&lt;/code&gt; shows the error even after the logs are gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;p&gt;When a pod is in CrashLoopBackOff, this order gets you to the cause quickly, whatever the cause turns out to be:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;kubectl get pods&lt;/code&gt; shows the symptom and the restart count.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl get rs&lt;/code&gt; tells you whether anything is still serving, which decides how urgent this is.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl logs &amp;lt;pod&amp;gt; --previous&lt;/code&gt; gives you the dead container's last words.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;kubectl describe pod &amp;lt;pod&amp;gt;&lt;/code&gt; gives the exit code, the reason and the events.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then fix the thing the pod was copied from, not the pod, and let &lt;code&gt;rollout status&lt;/code&gt; tell you when it's really done.&lt;/p&gt;

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