CodeBlanks Logo Icon CodeBlanks

Pending Pod

Learn to inspect Pending Pods.

A pending pod

A pod stuck in Pending shows that the scheduler couldn't place it on any node (or that the image is being pulled). The FailedScheduling message in the event tells the reason:

0/3 nodes are available:
  3 Insufficient cpu.                                  # requests too big
  1 node(s) had untolerated taint {node-role...}       # taint
  2 node(s) didn't match Pod's node affinity/selector  # nodeSelector
  pod has unbound immediate PersistentVolumeClaims     # no storage

Inspecting node capacity

kubectl describe node shows the allocatable resources and the total requests of the pods on the node as percentages. If the resources the pod requests exceed the free capacity, either the request is reduced or a node is added:

$ kubectl describe node worker-1 | grep -A6 "Allocated resources"
Allocated resources:
  Resource           Requests      Limits
  cpu                1850m (92%)   3 (150%)
  memory             3200Mi (81%)  4Gi (104%)
$ kubectl get pod api-xyz -o jsonpath='{.spec.containers[0].resources.requests}'
{"cpu":"500m","memory":"1Gi"}

Practice Why isn't it placed?

Write three commands: list the pods in the Pending phase; print the requests of the api-xyz pod with jsonpath='{.spec.containers[0].resources.requests}'; show the worker-1 node in detail.

Starter code

terminal
# buraya yaz

Sample solution

terminal
kubectl get pods --field-selector status.phase=Pending
kubectl get pod api-xyz -o jsonpath='{.spec.containers[0].resources.requests}'
kubectl describe node worker-1

Expected output

NAME      READY   STATUS    RESTARTS   AGE
api-xyz   0/1     Pending   0          4m
{"cpu":"500m","memory":"1Gi"}
Name:               worker-1
Allocated resources:
  memory             3200Mi (81%)  4Gi (104%)

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the right first step for the "3 Insufficient memory" message?

  • Changing the namespace
  • Comparing the pod's requests.memory with the nodes' allocatable memory Correct answer
  • Deleting and recreating the pod
  • Shrinking the image

Explanation: The scheduler looks at requests, not usage.

2 List only the Pending pods.

Question
kubectl get pods --field-selector status.phase=____
Answer
kubectl get pods --field-selector status.phase=Pending

Explanation: status.phase is the pod phase.

3 Match the messages.

Term Meaning
Insufficient cpu Request exceeds capacity
untolerated taint The node repels it
node affinity/selector No node with the right label
unbound PersistentVolumeClaims Storage not bound

All lessons in Intermediate