通过system status kubelet 查看报错,基本没有什么有效信息,所以使用

journalctl -xefu kubelet

就可以看到以下报错:Jan 16 20:49:17 master kubelet[3824]: I0116 20:49:17.402577    3824 server.go:425] Version: v1.15.0
Jan 16 20:49:17 master kubelet[3824]: I0116 20:49:17.402770    3824 plugins.go:103] No cloud provider specified.
Jan 16 20:49:17 master kubelet[3824]: I0116 20:49:17.402781    3824 server.go:791] Client rotation is on, will bootstrap in background
Jan 16 20:49:17 master kubelet[3824]: E0116 20:49:17.404041    3824 bootstrap.go:263] Part of the existing bootstrap client certificate is expired: 2023-01-29 16:57:44 +0000 UTC
Jan 16 20:49:17 master kubelet[3824]: F0116 20:49:17.404130    3824 server.go:273] failed to run Kubelet: unable to load bootstrap kubeconfig: stat /etc/kubernetes/bootstrap-kubelet.conf: no such file or directory
Jan 16 20:49:17 master systemd[1]: kubelet.service: main process exited, code=exited, status=255/n/a
Jan 16 20:49:17 master systemd[1]: Unit kubelet.service entered failed state.
Jan 16 20:49:17 master systemd[1]: kubelet.service failed.
Jan 16 20:49:27 master systemd[1]: kubelet.service holdoff time over, scheduling restart.
Jan 16 20:49:27 master systemd[1]: Started kubelet: The Kubernetes Node Agent.
Jan 16 20:49:27 master systemd[1]: Starting kubelet: The Kubernetes Node Agent...
Jan 16 20:49:27 master kubelet[3837]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Jan 16 20:49:27 master kubelet[3837]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Jan 16 20:49:27 master kubelet[3837]: I0116 20:49:27.652013    3837 server.go:425] Version: v1.15.0
Jan 16 20:49:27 master kubelet[3837]: I0116 20:49:27.652255    3837 plugins.go:103] No cloud provider specified.
Jan 16 20:49:27 master kubelet[3837]: I0116 20:49:27.652267    3837 server.go:791] Client rotation is on, will bootstrap in background
Jan 16 20:49:27 master kubelet[3837]: E0116 20:49:27.653673    3837 bootstrap.go:263] Part of the existing bootstrap client certificate is expired: 2023-01-29 16:57:44 +0000 UTC
Jan 16 20:49:27 master kubelet[3837]: F0116 20:49:27.653727    3837 server.go:273] failed to run Kubelet: unable to load bootstrap kubeconfig: stat /etc/kubernetes/bootstrap-kubelet.conf: no such file or directory
Jan 16 20:49:27 master systemd[1]: kubelet.service: main process exited, code=exited, status=255/n/a
Jan 16 20:49:27 master systemd[1]: Unit kubelet.service entered failed state.
Jan 16 20:49:27 master systemd[1]: kubelet.service failed.
 

最开始看,关键是/etc/kubernetes/bootstrap-kubelet.conf: no such file or directory 以为是配置文档丢失了。所以重新生成:

kubectl config set-cluster <cluster-name> --server=<api-server-url> --kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf

 其中,<cluster-name>是集群的名称,<api-server-url>是Kubernetes API服务器的URL。这条命令将创建一个新的kubeconfig文件,并将其保存到/etc/kubernetes/bootstrap-kubelet.conf路径下。

创建了kubeconfig文件后,我们需要将其复制到正确的位置。可以使用以下命令将kubeconfig文件复制到正确的位置:

sudo cp /etc/kubernetes/bootstrap-kubelet.conf /var/lib/kubelet/kubeconfig

重启kubelet 后,发现依旧启动失败,报错如下:

 

Unit kubelet.service has finished starting up.
-- 
-- The start-up result is done.
Jan 16 21:42:37 master systemd[1]: Starting kubelet: The Kubernetes Node Agent...
-- Subject: Unit kubelet.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit kubelet.service has begun starting up.
Jan 16 21:42:37 master kubelet[1795]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Jan 16 21:42:37 master kubelet[1795]: Flag --cgroup-driver has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
Jan 16 21:42:37 master kubelet[1795]: I0116 21:42:37.126156    1795 server.go:425] Version: v1.15.0
Jan 16 21:42:37 master kubelet[1795]: I0116 21:42:37.126316    1795 plugins.go:103] No cloud provider specified.
Jan 16 21:42:37 master kubelet[1795]: I0116 21:42:37.126326    1795 server.go:791] Client rotation is on, will bootstrap in background
Jan 16 21:42:37 master kubelet[1795]: E0116 21:42:37.127732    1795 bootstrap.go:263] Part of the existing bootstrap client certificate is expired: 2023-01-29 16:57:44 +0000 UTC
Jan 16 21:42:37 master kubelet[1795]: F0116 21:42:37.127950    1795 server.go:273] failed to run Kubelet: unable to load bootstrap kubeconfig: invalid configuration: no configuration has been provided
Jan 16 21:42:37 master systemd[1]: kubelet.service: main process exited, code=exited, status=255/n/a
Jan 16 21:42:37 master systemd[1]: Unit kubelet.service entered failed state.
Jan 16 21:42:37 master systemd[1]: kubelet.service failed.
Jan 16 21:42:47 master systemd[1]: kubelet.service holdoff time over, scheduling restart.
Jan 16 21:42:47 master systemd[1]: Started kubelet: The Kubernetes Node Agent.
-- Subject: Unit kubelet.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit kubelet.service has finished starting up.
-- 
-- The start-up result is done.
Jan 16 21:42:47 master systemd[1]: Starting kubelet: The Kubernetes Node Agent...
-- Subject: Unit kubelet.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
 

找了很多资源看,发现有可能是kubelet.conf的证书权限有问题,

然后就删除了新创建的bootstrap-kubelet.conf。拷贝 admin.conf 到 kubelet.conf ,再重新启动kubelet服务 

cp -a /etc/kubernetes/admin.conf /etc/kubernetes/kubelet.conf

systemctl daemon-reload  && systemctl restart kubelet

启动成功。

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐