Bird
Raised Fist0
Kubernetesdevops~20 mins

Pod stuck in Pending state in Kubernetes - Practice Problems & Coding Challenges

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
Challenge - 5 Problems
🎖️
Pod Pending State Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is a Kubernetes Pod stuck in Pending state?

A Pod in Kubernetes is stuck in the Pending state. What is the most common reason for this?

AThere are not enough resources available on any node to schedule the Pod.
BThe Pod's container image is missing from the registry.
CThe Pod's network policy is blocking all traffic.
DThe Pod has completed its task and is terminating.
Attempts:
2 left
💡 Hint

Think about what the scheduler needs to place a Pod on a node.

💻 Command Output
intermediate
2:00remaining
Identify the cause from Pod describe output

Given the following snippet from kubectl describe pod mypod, what is the cause of the Pod being Pending?

Events:
  Type     Reason            Age                From               Message
  ----     ------            ----               ----               -------
  Warning  FailedScheduling  2m (x3 over 5m)    default-scheduler  0/3 nodes are available: 3 Insufficient memory.
AThe Pod's container image is not found.
BThe Pod is waiting for a volume to be attached.
CThe Pod requests more memory than any node has available.
DThe Pod's service account is missing.
Attempts:
2 left
💡 Hint

Look at the 'FailedScheduling' message carefully.

Troubleshoot
advanced
2:00remaining
Fixing a Pod stuck in Pending due to node selector mismatch

You deployed a Pod with a nodeSelector that does not match any node labels. Which command will help you verify node labels to fix this issue?

Akubectl logs mypod
Bkubectl describe pod mypod
Ckubectl get pods --all-namespaces
Dkubectl get nodes --show-labels
Attempts:
2 left
💡 Hint

You need to check node labels to match the nodeSelector.

🔀 Workflow
advanced
3:00remaining
Order the steps to diagnose a Pending Pod due to resource constraints

Put the following steps in the correct order to diagnose why a Pod is stuck in Pending due to resource constraints.

A1,3,2,4
B3,1,2,4
C1,3,4,2
D3,2,1,4
Attempts:
2 left
💡 Hint

Start by checking Pod events, then resource requests, then node details, then compare.

Best Practice
expert
2:00remaining
Preventing Pods from getting stuck in Pending state

Which practice helps prevent Pods from getting stuck in Pending state due to resource shortages?

AUse hostPath volumes to store Pod data on the node.
BAlways set resource requests and limits for Pods to help the scheduler make decisions.
CDisable the Kubernetes scheduler and assign Pods manually.
DSet Pod restartPolicy to Never.
Attempts:
2 left
💡 Hint

Think about how the scheduler decides where to place Pods.

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