It seems like the kubelet isn‘t running or healthy

背景

通过 kubeadm 安装k8s集群报错
操作系统环境信息

root@controlplane:~# cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

kubeadm init 安装报错信息

[kubelet-check] It seems like the kubelet isn't running or healthy.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.
[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get "http://localhost:10248/healthz": dial tcp 127.0.0.1:10248: connect: connection refused.

        Unfortunately, an error has occurred:
                timed out waiting for the condition

        This error is likely caused by:
                - The kubelet is not running
                - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)

        If you are on a systemd-powered system, you can try to troubleshoot the error with the following commands:
                - 'systemctl status kubelet'
                - 'journalctl -xeu kubelet'

        Additionally, a control plane component may have crashed or exited when started by the container runtime.
        To troubleshoot, list all containers using your preferred container runtimes CLI.

        Here is one example how you may list all Kubernetes containers running in docker:
                - 'docker ps -a | grep kube | grep -v pause'
                Once you have found the failing container, you can inspect its logs with:
                - 'docker logs CONTAINERID'

排查思路

查看官网介绍为 docker 和 kubelet 服务中的 cgroup 驱动不一致,有两种方法
方式一:驱动向 docker 看齐
方式二:驱动为向 kubelet 看齐
如果docker 不方便重启则统一向 kubelet看齐,并重启对应的服务即可

解决方式

docker 配置文件

这里采取的是方式二,docker 默认驱动为 cgroupfs ,只需要添加

 "exec-opts": [
    "native.cgroupdriver=systemd"
  ],

修改后配置文件

root@controlplane:~# cat /etc/docker/daemon.json 
{
  "exec-opts": [
    "native.cgroupdriver=systemd"
  ],
  "bip":"172.12.0.1/24",
  "registry-mirrors": [
    "http://docker-registry-mirror.kodekloud.com"
  ]
}

重启docker
systemctl restart docker

kublete 配置文件

grep 截取一下,可以看得出来kubelet默认 cgoup 驱动为systemd

root@controlplane:~# cat /var/lib/kubelet/config.yaml |grep group
cgroupDriver: systemd

重启kubelet (optional)
systemctl restart kubelet

参考

配置cgroup驱动
Docker中的Cgroup Driver:Cgroupfs 与 Systemd
为什么要修改docker的cgroup driver

根据您提供的信息,kubeadm正在创建kube-scheduler的静态Pod清单,并在"/etc/kubernetes/manifests"目录下创建本地etcd的静态Pod清单。 然后,kubeadm等待kubelet以静态Pod的形式从"/etc/kubernetes/manifests"目录启动控制平面。这个过程可能需要最多4分钟。 但是,在等待过程中,出现了一些问题。警告信息"W0225 17:09:39.827262 43878 manifests.go:214] the default kube-apiserver authorization-mode is "Node,RBAC"; using "Node,RBAC""和"W0225 17:09:39.827977 43878 manifests.go:214] the default kube-apiserver authorization-mode is "Node,RBAC"; using "Node,RBAC""表示默认的kube-apiserver授权模式为"Node,RBAC",并且将使用此模式。 警告信息"[kubelet-check] Initial timeout of 40s passed."和"[kubelet-check] It seems like the kubelet isn't running or healthy."表示在初始超时时间内无法连接到kubelet,可能是kubelet未运行或出现了健康问题。 警告信息"[kubelet-check] The HTTP call equal to 'curl -sSL http://localhost:10248/healthz' failed with error: Get http://localhost:10248/healthz: dial tcp 127.0.0.1:10248: connect: connection refused."表示尝试通过HTTP请求检查kubelet的健康状态失败,连接被拒绝。 这些警告表明kubelet可能在启动过程中遇到了问题。您可以检查kubelet的日志以获取更多详细信息,可能需要查看kubelet的日志文件以确定具体的问题所在。 如果您需要进一步的帮助,请提供更多信息或具体的错误日志,以便我们能够更好地帮助您解决问题。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

独步秋风

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值