Bird
Raised Fist0
Kubernetesdevops~30 mins

Pod stuck in Pending state in Kubernetes - Mini Project: Build & Apply

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
Troubleshooting a Pod Stuck in Pending State
📖 Scenario: You are managing a Kubernetes cluster for a small web application. One of your pods is stuck in the Pending state, which means it is not starting properly. You want to find out why and fix the issue so your application runs smoothly.
🎯 Goal: Learn how to check the pod status, understand why a pod might be stuck in Pending, and fix the problem by adjusting resource requests or node selectors.
📋 What You'll Learn
Use kubectl commands to check pod status
Inspect pod events to find the cause of Pending state
Modify pod configuration to fix resource or scheduling issues
Apply the fixed configuration and verify pod starts running
💡 Why This Matters
🌍 Real World
Pods stuck in Pending state are common when cluster resources are limited or pod specs are too demanding. Fixing these issues quickly keeps applications available.
💼 Career
DevOps engineers and Kubernetes administrators often troubleshoot pod scheduling problems to maintain healthy application deployments.
Progress0 / 4 steps
1
Check Pod Status
Use the command kubectl get pod myapp-pod to check the status of the pod named myapp-pod.
Kubernetes
Hint

Use kubectl get pod followed by the pod name to see its current status.

2
Inspect Pod Events
Use the command kubectl describe pod myapp-pod to see detailed information and events for the pod myapp-pod. Look for messages explaining why it is Pending.
Kubernetes
Hint

The kubectl describe pod command shows events like scheduling failures or resource shortages.

3
Fix Pod Resource Requests
Edit the pod configuration YAML to reduce the resources.requests.cpu value to 100m and resources.requests.memory to 128Mi. This helps if the pod is Pending due to insufficient resources.
Kubernetes
Hint

Open the pod YAML and find the resources.requests section. Change the CPU and memory values as instructed.

4
Apply Changes and Verify Pod Runs
Apply the updated pod configuration using kubectl apply -f pod.yaml. Then check the pod status again with kubectl get pod myapp-pod to confirm it is now Running.
Kubernetes
Hint

Use kubectl apply -f pod.yaml to update the pod, then kubectl get pod myapp-pod to see if it is 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