Ubuntu20.04无法启动kubelet的问题

查看状态

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo systemctl status kubelet
sudo systemctl status kubelet
sudo systemctl status kubelet

会发现是exit 异常退出,查看日志

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
journalctl -u kubelet
journalctl -u kubelet
journalctl -u kubelet

发现如下报错

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Failed to run kubelet" err="failed to run Kubelet: misconfiguration: kubelet cgroup driver: \"systemd\" is different from docker
cgroup driver: \"cgroupfs\"
Failed to run kubelet" err="failed to run Kubelet: misconfiguration: kubelet cgroup driver: \"systemd\" is different from docker cgroup driver: \"cgroupfs\"
Failed to run kubelet" err="failed to run Kubelet: misconfiguration: kubelet cgroup driver: \"systemd\" is different from docker 
cgroup driver: \"cgroupfs\"

这是cgroup的驱动不必配导致的,本地docker使用的是cgroupfs,然而kubelet使用的是systemd

确认当前使用的驱动版本:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
docker info |grep -i cgroup
WARNING: No swap limit support
Cgroup Driver: cgroupfs
Cgroup Version: 1
docker info |grep -i cgroup WARNING: No swap limit support Cgroup Driver: cgroupfs Cgroup Version: 1
docker info |grep -i cgroup
WARNING: No swap limit support
 Cgroup Driver: cgroupfs
 Cgroup Version: 1

修改:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo vim /etc/docker/daemon.json
sudo vim /etc/docker/daemon.json
sudo vim /etc/docker/daemon.json

添加

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{"exec-opts": ["native.cgroupdriver=systemd"]}
{"exec-opts": ["native.cgroupdriver=systemd"]}
{"exec-opts": ["native.cgroupdriver=systemd"]}

重启,搞定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo systemctl restart docker
sudo systemctl restart docker
sudo systemctl restart docker

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *