Issue#

A new deployment, or a scale-up, leaves pods stuck in Pending. kubectl top nodes shows the nodes are mostly idle, but the scheduler still refuses to place the pods.

kubectl describe pod myapp-7d9c5b6f4-xk2lp
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 12s default-scheduler 0/3 nodes are available: 3 Insufficient cpu. preemption: 0/3 nodes are available: 3 No preemption victims found for incoming pod.

Cause#

The scheduler does not look at real CPU usage. It compares the pod's requests with each node's allocatable capacity minus the requests of pods already on that node. If the total requested CPU is already close to allocatable, a new pod cannot fit, even when the node is idle. The same applies to memory (Insufficient memory).

Common reasons:

  • Requests are set much higher than the app needs (for example cpu: 2 for a small web app).
  • A LimitRange in the namespace injects large default requests.
  • Replicas were scaled up beyond what the cluster can hold.

Solution#

  1. Check how much CPU is already requested on each node:
kubectl describe nodes | grep -A 8 "Allocated resources"

If the cpu line under Requests shows a value near 100%, the node is full from the scheduler's point of view.

  1. Find the pods that request the most CPU:
kubectl get pods -A -o custom-columns=NS:.metadata.namespace,NAME:.metadata.name,CPU_REQ:.spec.containers[*].resources.requests.cpu,NODE:.spec.nodeName
  1. Check what the pending pod requests, and whether a LimitRange sets defaults:
kubectl get pod myapp-7d9c5b6f4-xk2lp -o jsonpath='{.spec.containers[*].resources}'; echo kubectl get limitrange -n default -o yaml
  1. Lower the requests to realistic values. Base them on actual usage from kubectl top pods:
kubectl top pods -n default kubectl set resources deployment myapp -n default --requests=cpu=250m,memory=256Mi

Or set them in the manifest:

resources: requests: cpu: 250m memory: 256Mi limits: memory: 512Mi
  1. If the requests are already correct, reduce replicas or add capacity:
kubectl scale deployment myapp -n default --replicas=2

Otherwise, add a node, or let the cluster autoscaler add one if it is installed.

Tip: kubectl top needs metrics-server. Without it, use kubectl describe nodes only, because that output comes from requests and not from live metrics.

Verify#

kubectl get pods -n default -l app=myapp -w

The pods should move from Pending to Running. Confirm there are no new scheduling failures:

kubectl get events -n default --field-selector reason=FailedScheduling