安装 minikube 后使用 kubeadm init 报错 http://localhost:10248/healthz‘ failed with error connection refu问题

一、背景

首先安装的是 minikube,然后 minikube 还没卸载清理干净就使用 kubeadm init 来想要安装正式一点集群环境,结果前面各种步骤都没有问题,就是在启动 kubectl 的时候一直报如下错误

[kubelet-check] The HTTP call equal to ‘curl -sSL http://localhost:10248/healthz’ failed with error: 
Get “http://localhost:10248/healthz”: dial tcp [::1]:10248: connect: connection refused.

二、处理过程

执行 journalctl -xeu kubelet 后有如下日志

Aug 12 23:15:55 host-192.168.56.66 systemd[1]: kubelet.service failed.
Aug 12 23:16:05 host-192.168.56.66 systemd[1]: kubelet.service holdoff time over, scheduling restart.
Aug 12 23:16:05 host-192.168.56.66 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.
Aug 12 23:16:05 host-192.168.56.66 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.
Aug 12 23:16:05 host-192.168.56.66 systemd[13235]: Failed at step EXEC spawning /var/lib/minikube/binaries/v1.27.4/kubelet: No such file or directory
-- Subject: Process /var/lib/minikube/binaries/v1.27.4/kubelet could not be executed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- The process /var/lib/minikube/binaries/v1.27.4/kubelet could not be executed and failed.
-- 
-- The error number returned by this process is 2.
Aug 12 23:16:05 host-192.168.56.66 systemd[1]: kubelet.service: main process exited, code=exited, status=203/EXEC
Aug 12 23:16:05 host-192.168.56.66 systemd[1]: Unit kubelet.service entered failed state.
Aug 12 23:16:05 host-192.168.56.66 systemd[1]: kubelet.service failed.
Aug 12 23:16:16 host-192.168.56.66 systemd[1]: kubelet.service holdoff time over, scheduling restart.
Aug 12 23:16:16 host-192.168.56.66 systemd[1]: Started kubelet: The Kubernetes Node Agent.

其中 Failed at step EXEC spawning /var/lib/minikube/binaries/v1.27.4/kubelet: No such file or directory 这行着实亮眼,我明明使用 kubeadm 来安装的,结果却使用了之前 minikube 安装的 kubelet,但是这个到底是怎么来的呢?


三、解决

由于在网上找了好一会没有找到相关的问题,所以这里做个记录,问题出现在如下的配置文件,删除该文件或者修改 kubelet 的目录即可;

[root@host_192 ~]# cat /etc/systemd/system/kubelet.service.d/10-kubeadm.conf 
[Unit]
Wants=docker.socket

[Service]
ExecStart=
ExecStart=/var/lib/minikube/binaries/v1.27.4/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --config=/var/lib/kubelet/config.ya-container-runtime-endpoint=unix:///var/run/cri-dockerd.sock --hostname-override=control-plane.minikube.internal --kubeconfig=/etc/kubernetes/kubelet. --node-ip=10.0.2.15

[Install]

你可能感兴趣的:(kubernetes)