What methods do you use to diagnose and find the causes of applications hanging in Pending state in Kubernetes?
sobes.tech AI
Answer from AI
To diagnose a pod hanging in the Pending state in Kubernetes, you can use the following methods:
- Check pod events:
kubectl describe pod <pod-name>
In the Events section, you can see the reasons why the pod is not starting (e.g., insufficient resources, PVC issues).
- Check node status:
kubectl get nodes
If nodes are not ready or overloaded, pods may remain in Pending.
-
Check resource availability: If the pod requires more CPU or memory than available, it will not be scheduled.
-
Check PersistentVolumeClaims settings: If the pod is waiting for volume binding and the PV is not available, it will be in Pending.
-
Check quorum restrictions and security policies: For example, PodSecurityPolicies or NetworkPolicies may block the scheduling.
-
Check the Scheduler: Ensure that the scheduler is running and can assign the pod to a node.
-
Controller logs: Check the logs of kube-scheduler and kube-controller-manager for errors.
Thus, diagnosis begins with describing the pod and analyzing events, then infrastructure and cluster settings are checked.