https://drive.google.com/file/d/1aCCxjiwfzxO8R3911myUQtRO7HMZNr2B/view?usp=sharing

πŸ” YAML Breakdown

apiVersion: v1
kind: Pod
metadata: 
  name: nnappone
  namespace: learning
  labels:
    app: nnappone
spec:
  containers:
    - name: crackone-app
      image: nginx
      resources:
        requests:
          cpu: "4"    # ← Wants 4 full CPU cores
        limits:
          cpu: "4"    # ← Also limits to 4 cores

⚠️ Key Issue:

The Pod requests 4 CPU cores β€” but most dev clusters (Minikube, Kind, Docker Desktop) have only 2–4 CPUs TOTAL, and system pods (kube-system) already use some.

🚫 Result: No node has 4 free CPUs β†’ Pod can’t be scheduled.


πŸ“Œ What Happens During Scheduling?

  1. You run: kubectl apply -f pod-with-cpu-exceed.yml
  2. Scheduler checks all nodes: β†’ "Does any node have β‰₯4 CPU cores available?"
  3. Answer: ❌ No β†’ Pod stays in Pending state forever.
  4. Event logged: 0/1 nodes are available: 1 Insufficient cpu.

πŸ’‘ Important:

This is a scheduling failure β€” not a runtime crash.

The container never starts.


πŸ§ͺ Lab: Reproduce & Diagnose CPU Scheduling Failure

πŸ”§ Steps

# 1. Create namespace
kubectl create namespace learning

# 2. Apply the Pod
kubectl apply -f pod-with-cpu-exceed.yml

# 3. Check Pod status
kubectl get pods -n learning

# βœ… Expected output:
# NAME       READY   STATUS    RESTARTS   AGE
# nnappone   0/1     Pending   0          10s

# 4. Describe Pod β†’ look for scheduling events
kubectl describe pod nnappone -n learning

# πŸ” Look for this critical line in "Events":
#   Type     Reason            Age   From               Message
#   ----     ------            ----  ----               -------
#   Warning  FailedScheduling  5s    default-scheduler  0/1 nodes are available: 1 Insufficient cpu.

πŸ” Check Your Node’s Capacity

# See total & allocatable CPU on nodes
kubectl describe nodes | grep -A 5 -B 5 "Capacity\\\\|Allocatable"

# Example output (Minikube with 2 CPUs):
# Capacity:
#  cpu:                2
# Allocatable:
#  cpu:                2

πŸ“Š Allocatable CPU = Total CPU – reserved for system/kubelet

β†’ If allocatable = 2, you can’t schedule a 4-CPU Pod.