kubelet启动失败:/usr/bin/kubelet文件不存在的问题求助
Hey there! I totally get how frustrating it is when kubelet refuses to run even after a full reinstall—let's work through this step by step to get it sorted out.
First, let's look at the systemctl status you shared, which shows kubelet is stuck in an auto-restart loop with exit code 1:
ismail@Ismail:~/cloud_monitoringapp$ sudo systemctl status kubelet ● kubelet.service - kubelet: The Kubernetes Node Agent Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled) Drop-In: /usr/lib/systemd/system/kubelet.service.d └─10-kubeadm.conf Active: activating (auto-restart) (Result: exit-code) since Mon 2024-05-20 02:11:16 CEST; 4s ago Docs: https://kubernetes.io/docs/ Process: 25239 ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_KUBEADM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=1/FAILURE) Main PID: 25239 (code=exited, status=1/FAILURE) CPU: 55ms
Since you've already tried reinstalling, let's dig into the most likely culprits:
1. Verify the kubelet binary exists and is executable
Exit code 1 can sometimes mean the binary itself is missing or corrupted. Run this command to check:
ls -l /usr/bin/kubelet
- If the file isn't listed, your reinstall didn't complete successfully. We'll need to do a thorough cleanup and reinstall again (see step 3 below).
- If it exists, double-check its executable permissions with
sudo chmod +x /usr/bin/kubeletjust in case it lost access rights during reinstall.
2. Check for detailed error messages in journalctl
The snippet you shared from journalctl -u kubelet cuts off, but the full log will have the exact reason kubelet is failing. Run this to stream real-time logs as kubelet tries to start:
sudo journalctl -u kubelet -f
Look for lines marked with ERROR or Failed—these will point you to specific issues like missing config files, invalid kubeconfig entries, port conflicts, or dependency problems.
3. Perform a complete Kubernetes cleanup and reinstall
If the binary is missing or logs point to corrupted files, let's wipe everything clean before reinstalling:
# Purge all Kubernetes packages sudo apt-get purge -y kubeadm kubectl kubelet kubernetes-cni kube* # Remove leftover dependencies sudo apt-get autoremove -y # Delete config and data directories sudo rm -rf ~/.kube sudo rm -rf /etc/kubernetes sudo rm -rf /var/lib/kubelet sudo rm -rf /var/lib/etcd # Reload systemd to clear old service definitions sudo systemctl daemon-reload
Then reinstall using the official Kubernetes repo (adjust the version if you need a specific one):
# Install prerequisites sudo apt-get update && sudo apt-get install -y apt-transport-https ca-certificates curl # Add Kubernetes GPG key curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg # Add Kubernetes repo echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list # Update and install packages sudo apt-get update sudo apt-get install -y kubelet kubeadm kubectl # Hold packages to prevent automatic updates sudo apt-mark hold kubelet kubeadm kubectl
4. Check system environment issues
Sometimes system settings can block kubelet:
- AppArmor (Ubuntu): Make sure it's not interfering. You can temporarily disable it with
sudo systemctl stop apparmorand try starting kubelet again. - Firewall rules: Ensure ports used by kubelet (like 10250) are open. You can temporarily disable the firewall to test:
sudo ufw disable(remember to re-enable it later if this fixes the issue). - Kernel compatibility: Verify your system kernel meets Kubernetes requirements (Ubuntu 22.04 recommends kernel 5.4+). Run
uname -rto check.
Once you've tried these steps, share the detailed error logs from journalctl if you're still stuck—I can help you parse them further!
备注:内容来源于stack exchange,提问作者Nazim Razac

