Kubernetes
kubeadm
kubelet
troubleshooting
devops

kubeadm init shows kubelet isn't running or healthy

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Running Kubernetes can sometimes present challenges, especially during the initialization phases using kubeadm. One common issue users may encounter is the message indicating “kubelet isn’t running or healthy” during the execution of kubeadm init. This document aims to dissect the causes of this problem and provide comprehensive guidance on how to troubleshoot and resolve it.

Understanding Kubeadm and Kubelet

kubeadm is a tool used for initializing a Kubernetes cluster. It automates many of the complex steps required to bootstrap a cluster and provides simple commands for setting up a single-node or multi-node cluster. On the other hand, kubelet is the node agent that runs on every cluster node. It is responsible for managing the containers running on the node, ensuring that the pods are running and are in a healthy state.

When using kubeadm init, kubelet should be active and healthy to ensure the pods are managed successfully. The message “kubelet isn’t running or healthy” signifies that there may be an issue with kubelet, preventing successful initialization.

Common Causes and Troubleshooting

The problem can be attributed to various factors which are essential to check and troubleshoot in a systematic manner:

System Configuration Issues

  • Incorrect Swap Settings: Kubernetes requires the swap memory to be disabled for nodes. If swap is enabled, it can cause kubelet to fail.
bash
1  # To temporarily disable swap
2  sudo swapoff -a
3
4  # To permanently disable swap, comment out the swap line in /etc/fstab
  • Incorrect Firewall Rules: Ports used by Kubernetes components must be open.
    • Ensure that ports like 6443, 2379-2380, 10250, etc., are open.

Inadequate Resources

  • Insufficient System Resources: Make sure that your system meets the minimum requirements needed to run Kubernetes components.
  • Nodes Running Out of Memory or CPU: This can also cause kubelet to fail.

Kubelet Configuration File Issues

  • Invalid Configurations: Verify that kubelet configuration files are correct and not corrupted. Configuration files are often located under /etc/systemd/system/kubelet.service.d/.

Logs and Error Messages

  • Reviewing logs can provide insights. Access kubelet logs using:
bash
  journalctl -xeu kubelet

Look for any error messages that may direct you toward the root cause.

Missing CNI Plugins

  • Pod Network Plugin: Make sure a network plugin is properly installed, e.g., Flannel or Calico.
bash
  kubectl apply -f [network-plugin.yaml]

Incompatible Kubernetes and OS Versions

  • Ensure that both Kubernetes version and OS are compatible.
    • Check the Kubernetes version skew policy to make sure they align.

Comprehensive Checklist

Let's look at a summary checklist presented in table form to aid in troubleshooting:

Potential CauseExplanationSolution
Swap EnabledKubernetes requires swap to be disabled.Disable swap using swapoff -a and edit /etc/fstab.
Firewall Blocking PortsCertain ports need to be open.Check and open requisite ports like 6443, 2379-2380, and 10250.
CPU/Memory ConstraintsResource limitation can cause kubelet to fail.Ensure system resources are adequate.
Invalid Kubelet ConfigurationMisconfigured settings or parameters.Check and correct configuration files under /etc/systemd/system/kubelet.service.d/.
CNI Plugin Not InstalledNetwork plugins are needed for pod communication.Make sure a CNI plugin is applied, e.g., Flannel or Calico.
Incompatible VersionsIncompatibility between Kubernetes and OS versions.Verify version compatibility and conformance to the Kubernetes version skew policy.

Additional Considerations

Understanding Systemd's Role

Kubelet runs as a systemd service; understanding how to interact with systemd can be valuable:

bash
1# Start kubelet service
2sudo systemctl start kubelet
3
4# Enable kubelet service at boot
5sudo systemctl enable kubelet
6
7# Restart kubelet service
8sudo systemctl restart kubelet

Practical Example

Consider running a debug process if you suspect a deeper issue. Using tools like top or htop to monitor resources, netstat to check open ports, and further using strace and lsof for tracing and listing open files or network connections can be beneficial.

Leveraging Community and Documentation

When going through complex issues, don't hesitate to scrutinize the Kubernetes official documentation, seek community help, or engage in forums such as Kubernetes Slack.

By following these recommendations and closely analyzing both the logs and the existing system configurations, you can often navigate through the "kubeadm init shows kubelet isn't running or healthy" error and successfully bootstrap a Kubernetes cluster.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.