How to Fix Pending Pod in Kubernetes: Quick Debug Guide
Pending state when Kubernetes cannot schedule it on any node, often due to resource shortages or missing node selectors. To fix this, check node availability, resource requests, and scheduling constraints, then adjust your pod spec or cluster resources accordingly.Why This Happens
A pod remains in Pending state when Kubernetes cannot find a suitable node to run it. This usually happens because the pod requests more CPU or memory than any node can provide, or because node selectors or taints prevent scheduling.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: busybox
image: busybox
command: ['sleep', '3600']
nodeSelector:
disktype: ssd
resources:
requests:
memory: "10Gi"
cpu: "5"The Fix
To fix a pending pod, first check node resources and labels with kubectl get nodes -o wide. Adjust resource requests to fit available capacity or remove restrictive node selectors. Alternatively, add more nodes or update taints and tolerations.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: busybox
image: busybox
command: ['sleep', '3600']
resources:
requests:
memory: "100Mi"
cpu: "0.1"Prevention
To avoid pods staying pending, always request realistic resources matching your cluster capacity. Use kubectl describe pod to check scheduling issues early. Keep node labels and taints updated and monitor cluster resource usage regularly.
Related Errors
Other common scheduling errors include ImagePullBackOff when the container image is missing, and CrashLoopBackOff when the container repeatedly fails. Use kubectl describe pod to diagnose these quickly.