Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 5 of 6 · Worked example · 25 min · revision 2

Why it will not run: scheduling, quotas, images, crashes and evictions

Diagnose five broken workloads on your kind cluster, one per failure mode, using get, describe, events, logs, exec and debug; then learn how node-pressure evictions differ from all of them.

Contentsand lesson path

What you will learn

  • Debug Pending, CrashLoopBackOff and ImagePullBackOff workloads using describe, logs, events and exec.

Prerequisites: Containerization

01. The problem

Five Deployments will not run, each for a different reason. Your job is to name the state, find the evidence that proves the cause, and state the fix, without restarting anything at random. You need the kind cluster from lesson 2, with its web Deployment still running in default.

Save the manifest below as broken.yaml; case 5 adds two small files of its own. Cluster outputs in this lesson are illustrative and long lines are cut with an ellipsis; the one log line in case 3 is what Python prints for that error.

YAML · broken.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: triage
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: bad-tag, namespace: triage}
spec:
  selector: {matchLabels: {app: bad-tag}}
  template:
    metadata: {labels: {app: bad-tag}}
    spec:
      containers:
        - name: app
          image: docker.io/library/python:3.31-alpine
          command: ["sleep", "3600"]
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: no-node, namespace: triage}
spec:
  selector: {matchLabels: {app: no-node}}
  template:
    metadata: {labels: {app: no-node}}
    spec:
      nodeSelector: {disktype: ssd}
      containers:
        - name: app
          image: docker.io/library/python:3.13-alpine
          command: ["sleep", "3600"]
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: oom, namespace: triage}
spec:
  selector: {matchLabels: {app: oom}}
  template:
    metadata: {labels: {app: oom}}
    spec:
      containers:
        - name: app
          image: docker.io/library/python:3.13-alpine
          command: ["python", "-c", "import time; b = b'x' * 2**28; time.sleep(3600)"]
          resources:
            requests: {memory: 64Mi}
            limits: {memory: 64Mi}
---
apiVersion: apps/v1
kind: Deployment
metadata: {name: no-env, namespace: triage}
spec:
  selector: {matchLabels: {app: no-env}}
  template:
    metadata: {labels: {app: no-env}}
    spec:
      containers:
        - name: app
          image: docker.io/library/python:3.13-alpine
          command: ["python", "-c", "import os; print(os.environ['DATABASE_URL'])"]

02. Step 1: Read the STATUS column, but know what it is

Terminal
kubectl apply -f broken.yaml
sleep 60
kubectl get pods -n triage
kubectl get pods -n triage -o custom-columns=NAME:.metadata.name,PHASE:.status.phase
Illustrative output
NAME                       READY   STATUS             RESTARTS      AGE
bad-tag-6c8f9d7b4-k2x9p    0/1     ImagePullBackOff   0             61s
no-env-5d7b8c9f6-m4q7z     0/1     CrashLoopBackOff   3 (24s ago)   61s
no-node-7f9c6d5b8-r8t2v    0/1     Pending            0             61s
oom-84d6c7b9f5-w3n6j       0/1     CrashLoopBackOff   3 (19s ago)   61s
NAME                       PHASE
bad-tag-6c8f9d7b4-k2x9p    Pending
no-env-5d7b8c9f6-m4q7z     Running
no-node-7f9c6d5b8-r8t2v    Pending
oom-84d6c7b9f5-w3n6j       Running

The STATUS column is a summary that kubectl builds from container states; it is not the Pod phase. A Pod phase is only ever Pending, Running, Succeeded, Failed or Unknown. Pending covers both "not scheduled yet" and "scheduled, but images not pulled or containers not started". A crash-looping Pod is Running: its container has run and keeps being restarted. Alerts and field selectors work on phases, so status.phase=Running happily includes crash loops.

The order of work that follows is the same every time: get to see which state, describe to read the events and container states, logs --previous once a container has run, exec or debug to look inside, and for anything that never became a Pod, the events of the owner.

03. Step 2: Pending and ImagePullBackOff

Terminal
kubectl describe pod -n triage -l app=no-node | sed -n '/^Events:/,$p'
kubectl describe pod -n triage -l app=bad-tag | sed -n '/^Events:/,$p'
Illustrative output
Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  75s   default-scheduler  0/1 nodes are available: 1 node(…
Events:
  Type     Reason   Age   From     Message
  ----     ------   ----  ----     -------
  Normal   Pulling  74s   kubelet  Pulling image "docker.io/library/python:3.31-alpine"
  Warning  Failed   72s   kubelet  Failed to pull image "docker.io/library/python:3.3…
  Warning  Failed   72s   kubelet  Error: ErrImagePull
  Normal   BackOff  20s   kubelet  Back-off pulling image "docker.io/library/python:3…
  Warning  Failed   20s   kubelet  Error: ImagePullBackOff

Case 1, no-node. The full event reads 0/1 nodes are available: 1 node(s) didn't match Pod's node affinity/selector. A FailedScheduling event means the scheduler found no node that satisfies everything the Pod demands: resource requests, node selector or affinity, untolerated taints, or volume constraints such as a claim that cannot bind. The message counts nodes per reason, so read it to the end. There are no logs, because no container ever started. Fix: correct the selector, or label a node that really has the property (kubectl label node k8s-lab-control-plane disktype=ssd).

Case 2, bad-tag. The kubelet tried to pull and the registry answered not found. The Pod stays Pending and the kubelet retries with a growing back-off, shown as ImagePullBackOff. not found points to a wrong name or tag; pull access denied or unauthorized points to a private registry without credentials, fixed with imagePullSecrets on the Pod or its service account; a timeout points to node networking or DNS. Fix: use a tag that exists, ideally one you have pulled yourself.

04. Step 3: Two kinds of CrashLoopBackOff

Terminal
kubectl logs -n triage deploy/no-env --previous | tail -n 1
kubectl describe pod -n triage -l app=oom | grep -A6 '^    State:'
Expected output of the first command
KeyError: 'DATABASE_URL'
Illustrative output of the second command
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       OOMKilled
      Exit Code:    137
      Started:      Fri, 30 Oct 2026 10:02:11 +0000
      Finished:     Fri, 30 Oct 2026 10:02:12 +0000

Case 3, no-env. CrashLoopBackOff means the image is fine and the process started, then exited, and the kubelet is waiting longer before each restart (10 s, 20 s, 40 s and so on, up to five minutes). The current container may have only just started, so read the one that died with --previous. Its last line names a missing variable, and describe shows Last State: Terminated, Reason: Error, Exit Code: 1. Fix: supply DATABASE_URL, usually from a Secret with secretKeyRef.

Case 4, oom. Same STATUS, different cause. Reason: OOMKilled with exit code 137 means the kernel killed the container for using more memory than its limit; the program tried to hold 256 MiB under a 64 MiB limit. Exit code 137 alone only means SIGKILL (128 + 9), which also happens when a container ignores SIGTERM until the grace period ends, so confirm the reason before you touch limits. Fix: measure real usage (kubectl top pod) and set the limit above it, or fix the leak.

05. Step 4: A Pod that never existed

Case 5, capped. A ResourceQuota is checked by the API server when an object is created. A Pod that would exceed it is refused with 403 Forbidden, so it never exists: there is no Pending Pod to describe. The ReplicaSet controller keeps trying and records FailedCreate events on the ReplicaSet. The quota lives in its own namespace here, because a CPU quota also refuses Pods that set no CPU request.

YAML · quota.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: quota-demo
---
apiVersion: v1
kind: ResourceQuota
metadata: {name: cpu-cap, namespace: quota-demo}
spec:
  hard:
    requests.cpu: 200m
YAML · capped.yaml
apiVersion: apps/v1
kind: Deployment
metadata: {name: capped, namespace: quota-demo}
spec:
  replicas: 3
  selector: {matchLabels: {app: capped}}
  template:
    metadata: {labels: {app: capped}}
    spec:
      containers:
        - name: app
          image: docker.io/library/python:3.13-alpine
          command: ["sleep", "3600"]
          resources:
            requests: {cpu: 100m, memory: 32Mi}
            limits: {memory: 32Mi}
Terminal
kubectl apply -f quota.yaml
sleep 5
kubectl apply -f capped.yaml
sleep 20
kubectl get deployment capped -n quota-demo
kubectl get events -n quota-demo --field-selector reason=FailedCreate \
  -o custom-columns=OBJECT:.involvedObject.name,MESSAGE:.message
kubectl describe resourcequota cpu-cap -n quota-demo
Illustrative output
NAME     READY   UP-TO-DATE   AVAILABLE   AGE
capped   2/3     2            2           20s
OBJECT              MESSAGE
capped-5c9d8f7b6    Error creating: pods "capped-5c9d8f7b6-x2p9l" is forbidden: exceed…
Name:         cpu-cap
Namespace:    quota-demo
Resource      Used  Hard
--------      ----  ----
requests.cpu  200m  200m

The full message ends with exceeded quota: cpu-cap, requested: requests.cpu=100m, used: requests.cpu=200m, limited: requests.cpu=200m. A Deployment that shows fewer ready replicas than desired, with no Pending Pods, is the signature of this case; kubectl describe rs or the namespace events show it. Fix: lower the requests, remove unused workloads from the namespace, or ask for a larger quota.

06. Step 5: Look inside with exec and debug

When a Pod runs but behaves wrongly, check what the process actually sees. kubectl exec runs a command in a running container; it needs a shell or tool inside the image. The first four lines below are typed one after another: the second and third run inside the web container. Many production images have no shell at all (distroless images, for example). kubectl debug then adds an ephemeral container with your tools to the running Pod; --target shares the process namespace of the named container, so ps shows its processes.

Terminal
kubectl exec -it deploy/web -- sh
env | grep -E 'GREETING|APP_VERSION'
wget -qO- localhost:8080/ready
exit
POD=$(kubectl get pods -l app=web -o jsonpath='{.items[0].metadata.name}')
kubectl debug -it "$POD" --image=busybox:1.37 --target=app -- ps
Illustrative output
GREETING=hello
APP_VERSION=v1
ok
PID   USER     TIME  COMMAND
    1 root      0:00 python /app/app.py
   14 root      0:00 ps

You cannot exec into a container that exits within a second. For case 3, make a copy of the Pod with the command replaced by a shell, inspect it, then delete the copy:

Terminal
NOENV=$(kubectl get pods -n triage -l app=no-env \
  -o jsonpath='{.items[0].metadata.name}')
kubectl debug -n triage "$NOENV" -it --copy-to=no-env-debug --container=app -- sh
env | grep DATABASE_URL || echo "DATABASE_URL is not set"
exit
kubectl delete pod -n triage no-env-debug

07. Evictions and node pressure

An Evicted Pod was running fine until its node ran short of a resource. The kubelet watches eviction signals; the default hard thresholds on Linux are memory.available<100Mi, nodefs.available<10%, imagefs.available<15%, nodefs.inodesFree<5% and imagefs.inodesFree<5%. When one is crossed, the node reports MemoryPressure or DiskPressure, the kubelet first tries to reclaim node-level resources (for disk, it deletes unused images and dead containers), and then evicts Pods. It picks first the Pods whose usage of that resource exceeds their requests, ordered by priority and then by how far over they are. BestEffort Pods have no requests, so they are usually first; Guaranteed Pods are rarely chosen but are not exempt.

Do not confuse this with image garbage collection. imageGCHighThresholdPercent (85% by default) makes the kubelet delete unused images when image disk usage goes above it; it does not evict Pods. To avoid disk evictions, set ephemeral-storage requests and limits, keep logs on stdout so the kubelet rotates them, and do not write large files into the container filesystem.

When many Pods fail at once, check what they share before blaming a node. If they share a node (kubectl get pods -A -o wide), run kubectl describe node and read its conditions. If they are spread across nodes, suspect a shared dependency: cluster DNS, a database, a recently changed Secret or ConfigMap, a NetworkPolicy, or expired registry credentials.

08. Check your understanding

Practice check · 3 questions

Finding the evidence

Three questions about where the evidence lives.

Q1. A Deployment wants 5 replicas. `kubectl get pods` shows only 2, both Running, and no Pending Pods at all. Where do you look next?
Q2. A Pod shows STATUS `CrashLoopBackOff` with 6 restarts. What does `kubectl get pod -o jsonpath='{.status.phase}'` print?
Q3. A running Pod uses a distroless image with no shell, and you need to see which processes it runs. Which command helps?
Practice only: not graded, not saved, not evidence.

09. Apply it

Fix all five workloads and confirm each one reaches 1/1 Running (or 3/3 for capped, after raising the quota). Then prepare for the skill project, where a setup script breaks three workloads for you: write a one-page runbook with the order of commands from step 1, the event or field that proves each cause, and the fix. Clean up with kubectl delete namespace triage quota-demo.

10. Review prompt

Without looking back, explain: the five Pod phases and why STATUS is not one of them; which events prove a scheduling failure, a bad image reference and a missing credential; why --previous matters for crash loops; how to tell an OOM kill from another SIGKILL; where to look when a quota refuses Pods; when to use exec, an ephemeral debug container and a debug copy; and what triggers a node-pressure eviction compared with image garbage collection.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check