Bird
Raised Fist0
Kubernetesdevops~10 mins

Pod stuck in Pending state in Kubernetes - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Process Flow - Pod stuck in Pending state
Pod Created
Scheduler Checks Resources
Resources Available?
NoPod Stays Pending
Yes
Pod Scheduled to Node
Pod Starts Running
This flow shows how a pod moves from creation to running, or stays pending if resources are insufficient.
Execution Sample
Kubernetes
kubectl get pods
kubectl describe pod mypod
kubectl get nodes
kubectl describe node nodename
Commands to check pod status, details, and node resources to diagnose Pending state.
Process Table
StepActionCondition/CheckResultNext Step
1Pod created by userN/APod enters Pending stateScheduler checks resources
2Scheduler checks nodes for resourcesAre nodes free with enough CPU/memory?No nodes availablePod remains Pending
3User runs 'kubectl describe pod mypod'Check events for reasonsShows 'Insufficient cpu' eventUser checks nodes
4User runs 'kubectl get nodes'Check node status and capacityNodes Ready but CPU fully usedUser considers scaling or freeing resources
5User runs 'kubectl describe node nodename'Check detailed resource usageConfirms no free CPUPod stays Pending until resources free
6User frees resources or adds nodesResources become availableScheduler assigns pod to nodePod moves to Running state
7Pod starts runningPod status changesPod ReadyEnd
💡 Pod stays Pending if no nodes have enough free resources; moves to Running once scheduled.
Status Tracker
VariableStartAfter Step 2After Step 4After Step 6Final
Pod StatusPendingPendingPendingRunningRunning
Node CPU AvailabilityUnknownInsufficientInsufficientSufficientSufficient
Key Moments - 3 Insights
Why does the pod stay in Pending even though nodes are Ready?
Nodes can be Ready but still have no free CPU or memory. Execution table step 4 shows nodes are Ready but CPU is fully used, so pod cannot be scheduled.
What does the 'Insufficient cpu' event mean in pod description?
It means the scheduler tried to find a node with enough CPU but failed. See execution table step 3 where this event is found, indicating resource shortage.
How can the pod move from Pending to Running?
By freeing resources or adding nodes to increase available CPU/memory. Step 6 shows that once resources are sufficient, scheduler assigns the pod and it starts running.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the pod status change from Pending to Running?
AStep 2
BStep 6
CStep 4
DStep 3
💡 Hint
Check the 'Pod Status' variable in variable_tracker after Step 6.
According to the execution table, what is the main reason the pod stays Pending at Step 2?
ANo nodes have enough CPU resources
BNode is Not Ready
CPod configuration error
DNetwork issue
💡 Hint
See Step 2 'Result' column and variable_tracker 'Node CPU Availability' after Step 2.
If the user adds more nodes with free CPU, how will the pod status change in the variable_tracker?
APod Status remains Pending
BNode CPU Availability becomes Insufficient
CPod Status changes to Running
DPod Status changes to Failed
💡 Hint
Refer to Step 6 and final values in variable_tracker.
Concept Snapshot
Pod Pending State:
- Pod created but not scheduled yet
- Scheduler checks node resources
- Pending if no node has enough CPU/memory
- Check 'kubectl describe pod' for events
- Free resources or add nodes to schedule pod
- Pod moves to Running once assigned
Full Transcript
When you create a pod in Kubernetes, it starts in Pending state until the scheduler finds a node with enough resources. The scheduler checks all nodes for available CPU and memory. If no node has enough free resources, the pod stays Pending. You can use 'kubectl describe pod' to see events like 'Insufficient cpu' that explain why scheduling failed. Checking nodes with 'kubectl get nodes' and 'kubectl describe node' helps confirm resource availability. To fix Pending pods, free resources or add nodes. Once resources are sufficient, the scheduler assigns the pod to a node and it starts running.

Practice

(1/5)
1. What does it usually mean when a Kubernetes Pod is stuck in the Pending state?
easy
A. Kubernetes cannot find a suitable node to run the Pod.
B. The Pod has completed its task and is terminating.
C. The Pod is running but not responding to requests.
D. The Pod has been deleted from the cluster.

Solution

  1. Step 1: Understand Pod lifecycle states

    The Pending state means the Pod is created but not yet scheduled to a node.
  2. Step 2: Identify reason for Pending

    Pending usually happens when no node meets the Pod's resource or scheduling requirements.
  3. Final Answer:

    Kubernetes cannot find a suitable node to run the Pod. -> Option A
  4. Quick Check:

    Pending = No suitable node found [OK]
Hint: Pending means no node fits Pod's needs [OK]
Common Mistakes:
  • Confusing Pending with Running state
  • Thinking Pending means Pod is deleted
  • Assuming Pending means Pod is ready
2. Which kubectl command helps you see detailed reasons why a Pod is stuck in Pending state?
easy
A. kubectl get pods
B. kubectl describe pod
C. kubectl logs
D. kubectl delete pod

Solution

  1. Step 1: Identify command to get detailed Pod info

    kubectl describe pod shows events and status details for the Pod.
  2. Step 2: Confirm command usage

    This command reveals scheduling failures or resource issues causing Pending.
  3. Final Answer:

    kubectl describe pod <pod-name> -> Option B
  4. Quick Check:

    Describe Pod = Detailed status [OK]
Hint: Use describe to see Pod events and reasons [OK]
Common Mistakes:
  • Using get pods only shows summary, not reasons
  • Using logs shows container logs, not scheduling info
  • Deleting Pod does not show status
3. Given this kubectl describe pod mypod output snippet:
Events:
  Type     Reason            Age   From               Message
  ----     ------            ----  ----               -------
  Warning  FailedScheduling  2m    default-scheduler  0/3 nodes are available: 3 Insufficient cpu.

What is the main reason the Pod is stuck in Pending?
medium
A. There is no node with enough CPU available.
B. The Pod image is not found.
C. The Pod has a syntax error in its YAML.
D. The Pod is already running on another node.

Solution

  1. Step 1: Analyze the event message

    The message says "0/3 nodes are available: 3 Insufficient cpu." meaning no node has enough CPU resources.
  2. Step 2: Understand impact on scheduling

    Without enough CPU, the scheduler cannot place the Pod, so it stays Pending.
  3. Final Answer:

    There is no node with enough CPU available. -> Option A
  4. Quick Check:

    Insufficient CPU = Pod Pending [OK]
Hint: Look for 'Insufficient cpu' in describe events [OK]
Common Mistakes:
  • Confusing image errors with scheduling errors
  • Assuming YAML syntax causes Pending
  • Thinking Pod runs on multiple nodes
4. You see a Pod stuck in Pending state. You check kubectl describe pod and find the message: 0/2 nodes are available: 2 node(s) didn't match Pod's node selector.
What should you do to fix this?
medium
A. Delete the Pod and recreate it without changes.
B. Increase the Pod's CPU requests to match node capacity.
C. Remove or correct the Pod's nodeSelector labels to match available nodes.
D. Restart the Kubernetes cluster.

Solution

  1. Step 1: Understand nodeSelector impact

    The Pod's nodeSelector restricts scheduling to nodes with matching labels.
  2. Step 2: Fix nodeSelector to match nodes

    Adjust or remove nodeSelector so nodes in cluster match Pod requirements.
  3. Final Answer:

    Remove or correct the Pod's nodeSelector labels to match available nodes. -> Option C
  4. Quick Check:

    nodeSelector mismatch = fix labels [OK]
Hint: Check and fix nodeSelector labels to match nodes [OK]
Common Mistakes:
  • Increasing CPU requests worsens scheduling
  • Deleting Pod without fixing selector won't help
  • Restarting cluster is unnecessary
5. A Pod requests 4 CPUs but all nodes in your cluster have only 2 CPUs each. The Pod stays Pending. Which is the best way to fix this?
hard
A. Change the Pod's image to a smaller size.
B. Reduce the Pod's CPU request to 2 or less.
C. Remove resource requests from the Pod spec.
D. Add a node with at least 4 CPUs to the cluster.

Solution

  1. Step 1: Understand resource requests vs node capacity

    The Pod requests 4 CPUs but nodes have only 2 CPUs, so no node can run it.
  2. Step 2: Choose solution to meet resource needs

    Adding a node with enough CPUs allows the Pod to be scheduled properly.
  3. Final Answer:

    Add a node with at least 4 CPUs to the cluster. -> Option D
  4. Quick Check:

    Pod CPU request > node CPU = add bigger node [OK]
Hint: Match Pod CPU request with node CPU capacity [OK]
Common Mistakes:
  • Reducing CPU request may not be possible or desired
  • Removing requests can cause unstable scheduling
  • Changing image size does not affect CPU requests