How to Troubleshoot Kubernetes Pod in Pending State

FoxuTech
3 min readJul 17, 2023

--

Part of our Kubernetes troubleshooting series, in this article will see how to troubleshoot, pod on pending state and reasons.

Pod in Pending Status

In K8s, the “Pending” status for a Pod means that the Pod has been accepted by the K8s system, but it hasn’t been scheduled for running on a node yet, or it has been scheduled but the necessary preparations are not complete.

For example:

# kubectl get pods --field-selector=status.phase=Pending
NAME                         READY   STATUS    RESTARTS   AGE
testing-pod 0/1 Pending 0 5m11s

Common Reasons

  • Insufficient resources: If your cluster doesn’t have enough resources (CPU, memory, etc.) to meet the Pod’s requirements, the Pod will remain in the Pending state.
  • Taints and Tolerations: If a node is “tainted”, it’s marked to repel certain Pods. A Pod with a matching “toleration” can be scheduled on such a node. If no node with a suitable toleration for the Pod’s taints exists, the Pod will stay in Pending status.
  • Node Selector/Affinity rules: If you’ve set node selector or node/pod affinity/anti-affinity rules that the scheduler can’t satisfy, the Pod will remain in Pending status.
  • Persistent Volume Claims (PVCs): If a Pod is dependent on a PVC and that PVC is not ready or cannot be allocated, the Pod will stay in Pending state.
  • Image Pull Issues: If there are errors pulling the Docker image (for example, due to a typo in the image name, problems with the image registry, or ImagePullBackOff errors), the Pod will remain in Pending status.
  • Init Containers: If the Pod has Init Containers and they haven’t completed successfully, the Pod will remain in Pending status.
  • Dependency: The kubelet tries to verify all dependencies with other Kubernetes components before the pod starts. The pod will remain in a pending state until the dependencies are met.

How to Troubleshoot

Here are some steps you can take to troubleshoot Pods stuck in the Pending state:

  • Describe the Pod: The first step in troubleshooting a Pod stuck in Pending state is to get more information about the Pod. Run following commend to check it.
# kubectl describe pod <pod-name>

This command will provide a lot of useful information, such as the current state of the Pod, recent events, and so on.

Check for Events: At the bottom of the kubectl describe pod <pod-name> output, you’ll see an “Events” section. This section can often provide clues about why the Pod is not starting. Look for events like “FailedScheduling”, which can indicate issues like insufficient resources on your nodes or or some PaaS cluster, wont in-cooperate events with describe command, you may need to run,

# kubectl get events | grep <pod-name>

  • Check the Scheduler: The K8s scheduler is responsible for assigning Pods to nodes. If there’s a problem with the scheduler, it could prevent Pods from being scheduled. You can check the scheduler’s logs with the
# kubectl logs <scheduler-pod-name> -n kube-system
# kubectl -n kube-system logs $(kubectl -n kube-system get pods|grep scheduler|awk '{print $1}')

Continue Reading on https://foxutech.com/how-to-troubleshoot-kubernetes-pod-in-pending-state/

Please subscribe us on https://www.youtube.com/@FoxuTech.

--

--

FoxuTech

Discuss about #Linux, #DevOps, #Docker, #kubernetes, #HowTo’s, #cloud & IT technologies like #argocd #crossplane #azure https://foxutech.com/