[root@k8s-master01 ~]# kubelet --version
Kubernetes v1.20.0
问题:
[root@k8s-master01 ~]# kubctl get node
No resources found
[root@k8s-master01 ~]# systemctl status kubelet
● kubelet.service - Kubernetes Kubelet
Loaded: loaded (/usr/lib/systemd/system/kubelet.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/kubelet.service.d
└─10-kubelet.conf
Active: activating (auto-restart) (Result: exit-code) since Sat 2021-01-30 10:14:16 CST; 2s ago
Docs: https://github.com/kubernetes/kubernetes
Process: 27712 ExecStart=/usr/local/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_CONFIG_ARGS $KUBELET_SYSTEM_ARGS $KUBELET_EXTRA_ARGS (code=exited, status=255)
Main PID: 27712 (code=exited, status=255)
Jan 30 10:14:16 k8s-master01 kubelet[27712]: net/http.(*persistConn).readLoop(0xc00040c000)
Jan 30 10:14:16 k8s-master01 kubelet[27712]: /usr/local/go/src/net/http/transport.go:2040 +0x1a8
Jan 30 10:14:16 k8s-master01 kubelet[27712]: created by net/http.(*Transport).dialConn
Jan 30 10:14:16 k8s-master01 kubelet[27712]: /usr/local/go/src/net/http/transport.go:1708 +0xcb7
Jan 30 10:14:16 k8s-master01 kubelet[27712]: goroutine 120 [select]:
Jan 30 10:14:16 k8s-master01 kubelet[27712]: net/http.(*persistConn).writeLoop(0xc00040c000)
Jan 30 10:14:16 k8s-master01 kubelet[27712]: /usr/local/go/src/net/http/transport.go:2340 +0x11c
Jan 30 10:14:16 k8s-master01 kubelet[27712]: created by net/http.(*Transport).dialConn
Jan 30 10:14:16 k8s-master01 kubelet[27712]: /usr/local/go/src/net/http/transport.go:1709 +0xcdc
Jan 30 10:14:16 k8s-master01 systemd[1]: kubelet.service failed.
# 原因:kubelet设置的cgroups和docker的不一致导致,修改一样的即可
我这边修改的是docker
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
EOF
# 修改完需要重启
[root@k8s-master01 docker]# systemctl restart docker
[root@k8s-master01 docker]# systemctl restart kubelet