Pods are stuck in the Pending state
Once pods are created but not run yet, they remain in the Pending state before switching to the Running state. To start running on a node, pods wait for certain conditions to be met, and if they are not, the pods get stuck in the Pending state.
There might be several possible reasons for this behavior. Follow the instructions below one by one until the issue is resolved.
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:0/3 nodes are available: 1 Insufficient cpu, 2 Insufficient memoryIf it does, there are not enough resources (CPU and RAM) available on the node to run the pod.
-
View detailed information about the node resources using the command:
kubectl describe node <POD_NAME>In the command output:
Capacity— the maximum number of resources available on the nodeallocatable— the amount of resources available for the pod, given the system requirementsAllocated resources— the amount of already allocated resourcespods— the maximum number of pods that can run on the node at the same time
-
Solve the issue using one of the following approaches:
-
Enable automatic scaling of node groups or manually increase the number of nodes in the group if there are not enough existing nodes to accommodate the pods.
-
Adjust the resource requests in the pod manifest in the
resources.requestsblock if more resources are requested than are available on the node.For more details on resources, refer to the Resource limiting section and the official Kubernetes documentation.
-
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:0/3 nodes are available: 3 Insufficient podsIf it does, the node has reached the limit on the maximum number of pods that can be run at the same time.
-
View how many pods can run on a node and how many are already running using the command:
kubectl describe node <POD_NAME> podsOutput example:
pods: 110/110 -
Solve the issue using one of the following approaches:
-
Delete the pods you no longer need using the command:
kubectl delete pod <POD_NAME> -n <NAMESPACE> -
Increase the node's pod limit in the
maxPodsparameter of the configuration file for Kubelet. For more details, refer to the official Kubernetes documentation. -
Reallocate pods to other nodes. For more details, refer to the official Kubernetes documentation.
-
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:Forbidden: exceeded quotaForbidden: container memory limit exceeds limit rangeIf it does, the resource limit set by the
ResourceQuotaandLimitRangeobjects has been reached in the namespace. -
View information about quotas and resource limits for pods:
For the ResourceQuota objectFor the LimitRange objectRun the command:
kubectl get resourcequota -n <NAMESPACE>In the command output, the following displays:
- the name of the
ResourceQuotaobject - the
hardlimit for each resource type - the amount of resources that has already been consumed and is still available for use
Run the command:
kubectl get limitrange -n <NAMESPACE>In the command output, the following displays:
- the name of the
LimitRangeobject - the minimum, maximum, and default values for each resource type, if specified
- the object's age
- the name of the
-
Solve the issue using one of the following approaches:
-
In the pod manifest, adjust the values in the
resources.requestsandresources.limitsblocks to match the set quotas and limits.For more details on resources and limits, refer to the Resource limiting section and the official Kubernetes documentation.
-
In the
ResourceQuotaobject manifest, increase quotas in thespec.hardsection.For more details, refer to the official Kubernetes documentation.
-
Delete unnecessary
LimitRangeobjects, or in theLimitRangeobject manifest, adjust the values in thespec.limitssection.For more details, refer to the official Kubernetes documentation.
-
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:0/3 nodes are available: 3 node(s) didn't match node selector.0/3 nodes are available: 3 node(s) didn't match pod affinity/anti-affinity rules.0/3 nodes are available: 3 node(s) had taint {key=value:NoSchedule}; that no tolerations are applied.If it does, nodes do not meet the scheduling policies set by
nodeSelector,affinity, ortolerations. -
Solve the issue using one of the following approaches:
- Coordinate the pod settings with the specified policies.
- Add a new node group that matches the specified policies.
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:0/3 nodes are available: 1 pod has unbound immediate PersistentVolumeClaims0/3 nodes are available: no persistent volumes available for this claimIf it does, the pod has run into issues with PVs or PVCs. Examples of such issues:
- The PVC is not bound to the PV because the PV does not exist or meet the requirements.
- There are no appropriate PVs, or the
Provisionercomponent cannot create an appropriate PV. - A storage class is not configured, or it does not meet the requirements of the PVC.
-
Solve the issue using one of the following approaches:
- Create a PV manually or adjust parameters for its dynamic provisioning. For more details on working with PVs, refer to the respective how-to guide and the official Kubernetes documentation.
- Make sure that the storage class for the PVC exists and is specified, and its parameters meet the requirements of the PVC (disk type, availability zone, size, and so on).
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:Failed to create pod sandbox: networkPlugin cni failedFailed to allocate host port: address already in useIf it does, it is caused by issues with using the
hostPortsetting. Examples of such issues:- Two pods on the same node are trying to use the same
hostPortwhich causes their conflict. - The port specified in
hostPortis already used by the system process on the node. - There are no available ports on the node (for example, too many pods use
hostPort).
- Two pods on the same node are trying to use the same
-
Solve the issue using one of the following approaches:
-
Do not use
hostPortin the pod configuration, as this significantly limits its operation (there is no automatic scaling, it is impossible to redirect traffic, use load balancing, and so on). Instead, use services of theLoadBalancerorNodePorttypes. -
If you cannot avoid using
hostPort:- Limit the number of replicas to 1. This ensures that there will only be one pod on one node, so there will be no port conflicts. For more details, refer to the official Kubernetes documentation.
- If you need to run multiple replicas with
hostPort, place each replica on a separate node using affinity and anti-affinity rules.
-
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:0/3 nodes are available: 3 node(s) didn't satisfy existing topology spread constraintsIf it does, the Kubernetes scheduler cannot place a pod on any node because the topology spread constraints are violated — that is, the policy of distributing pods by topology (for example, by nodes, regions, availability zones, and so on).
-
View the policy settings in the pod manifest in the
spec.topologySpreadConstraintsblock. -
Solve the issue using one of the following approaches:
-
Adjust the
maxSkewvalue. This parameter specifies the maximum allowable difference in the number of pods among nodes. This way none of the topologies will have significantly more pods than the other ones.For example, if you need to place four pods into two availability zones, with the value
maxSkew:1, two pods will be placed in each of the zones, as opposed to three pods being placed in the first availability zone, and the remaining one — in the second. -
If you want the pods to run even with imperfect topology distribution, add the
whenUnsatisfiable: ScheduleAnywayparameter. This way, the pod will be scheduled on any available node, even in violation of the topology constraints (for example, in a topology where there are already too many pods, and themaxSkewparameter does not allow adding another one). -
Increase the number of nodes (add them to an existing group or create a new one).
-
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:Preemption is not possible because the priority of the pod is the lowestIf it does, low-priority pods cannot be run if there are no available resources on the nodes.
The priority of a pod is defined by its
PriorityClassparameter which tells the Kubernetes scheduler which pod must be run first and which ones can be preempted if there are insufficient resources. For more details, refer to the official Kubernetes documentation. -
View the priority levels configured for the cluster using the command:
kubectl get priorityclassOutput example:
NAME VALUE GLOBAL-DEFAULT... ... ...high-priority 20000000 falsemedium-priority 1000000 truelow-priority 100000 falseHere:
NAME— Priority name.VALUE— The numerical value of the priority. The higher it is, the higher the priority.GLOBAL-DEFAULT— A parameter that, when set totrue, indicates that this priority will be set for all pods whose priority is not explicitly set otherwise.
-
View the priority of the pod using the command:
kubectl describe pod <POD_NAME> | sed -n '/Priority/,+3p'The priority of the pod is set in the manifest in the
PriorityClassNamefield. If a low priority is set for the pod or none at all, and the pod is critical for operation, do the following:- Set a higher priority for this pod.
- (Optional) For pods that perform background tasks, set a lower priority and decrease resource requests.
-
Connect to the cluster via
kubectl. -
Display the events of the affected pod using the command:
kubectl describe pod <POD_NAME> -n <NAMESPACE> | sed -n '/Events/,$p' -
Check whether the
Eventssection contains similar records:Failed to pull image "myrepo/myimage:latest": rpc error: code = Unknown desc = Error response from daemon: manifest for myrepo/myimage:latest not found: manifest unknown: manifest unknownFailed to pull image "myrepo/myimage:latest": rpc error: code = Unknown desc = Error response from daemon: unauthorized: authentication requiredError: ErrImagePullBack-off pulling image "myrepo/myimage:latest"If it does, Kubernetes cannot download the required Docker image for the pod. There might be several reasons for this. Examples of such reasons:
- This image does not exist.
- The pod has no access to the public Docker registry.
- The secret for downloading images from private Docker registries is incorrectly configured, missing, or outdated.
-
Solve the issue using one of the following approaches:
Public Docker registriesPrivate Docker registriesMake sure that the tag and image name specified in the manifest are correct. To do this, check if the specified tag exists in the corresponding Docker registry, or use the command:
docker pull <IMAGE_NAME>:<TAG>If the image is successfully downloaded, the tag exists.
If possible, use a digest instead of a tag. A digest is a unique identifier (hash) of a particular image build in the following format:
<HASH_FUNCTION>:<IDENTIFIER>. Using it ensures that this particular image build will always be downloaded, even if the image is updated or its tag changes.For more details, refer to the official Kubernetes documentation.
In the manifest, change or specify the secret for accessing the registry.
-
Connect to the cluster via
kubectl. -
View information about the system pods of the cluster located in the
kube-systemnamespace using the command:kubectl get pods -n kube-systemIf any of these pods are stuck in the
Pendingstate, this might be caused by issues in integration with the container network interface (CNI) or the container storage interface (CSI). -
View information about the nodes whose pods are stuck the
Pendingstate using the command:kubectl describe node <POD_NAME> -
View the errors in the
Conditionssection and fix them:Error
Description
How to fix
NetworkUnavailableThe network is unavailable as the CNI has failed
- Make sure that the Calico CNI plugin is configured and running correctly.
- Restore or restart pods that run Calico
DiskPressureThere is not enough disk space on the node, so Kubernetes cannot run new pods on it
Increase the disk size, clean up the disk space (for example, delete old logs and unused images)
PIDPressureThere are too many processes running on the node, so Kubernetes cannot run new pods on it
Increase process limits, reduce the number of concurrent processes. For more details, refer to the official Kubernetes documentation
If the issue persists, contact technical support.