Microk8s
Kubernetes
Ubuntu
Troubleshooting
Pods Pending

Microk8s pods are stuck on pending on Ubuntu

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Exploring Pending MicroK8s Pods on Ubuntu: Troubleshooting and Resolutions

When using MicroK8s on Ubuntu, a common issue that users encounter is pods being stuck in the "Pending" state. This situation arises due to various factors that interfere with the successful scheduling and running of pods. Understanding why this happens and how to troubleshoot can significantly aid in managing a healthy Kubernetes environment.

Understanding What MicroK8s is

MicroK8s is a lightweight, fast, and convenient Kubernetes distribution by Canonical, tailored primarily for IoT devices and edge computing applications. It's often chosen for its ease of installation and minimal system resource requirements, making it a popular choice for development environments on Ubuntu.

Reasons for Pods Being Stuck in Pending

There are multiple reasons why a pod might be stuck in the Pending state. This typically occurs because the pod cannot be scheduled onto any node within the cluster. Here are the main causes:

  1. Resource Constraints:
    • Nodes may lack sufficient CPU or memory resources to schedule the pod.
    • By default, Kubernetes scheduling priorities aim to bind pods that fit resource availability on nodes.
  2. Node Unschedulability:
    • Nodes might be marked as unschedulable if they are under maintenance or unavailable.
  3. Taints and Affinities:
    • Pods that don't tolerate certain node taints or don't meet defined affinity rules might remain unschedulable.
  4. Network Plugin Issues:
    • CNI plugin misconfigurations can prevent pod networking from being established.
  5. Persistent Volume Claims (PVC) Issues:
    • Pending PVCs that pods depend on block pods from starting.

Troubleshooting Steps

Here are practical steps to resolve nodes stuck in Pending when using MicroK8s on Ubuntu:

1. Check Available Resources

Ensure that your nodes have enough resources.

  • Look for indications that nodes lack sufficient CPU or memory.
  • Use `microk8s kubectl cordon ``<node-name>``` and `microk8s kubectl uncordon ``<node-name>``` to adjust node schedulability.
  • Look for Events suggesting resource limits, node readiness, or scheduling issues.
  • Ensure that your pod spec includes necessary tolerations.
  • Use `microk8s enable dns` and `microk8s enable ``<networking-plugin>``` as needed.
  • Investigate pending PVCs and their associated storage classes.

Course illustration
Course illustration

All Rights Reserved.