报错如下:k8s从节点加入主节点信息

[root@k8s-node1 ~]# kubeadm join 192.168.10.110:6443 --token tmoo8b.kg32mkv6pv0y772n         --discovery-token-ca-cert-hash sha256:4dddf3238cd0a4a594e9eb4bed71a0d62696562e64643a9cec248230eb61afd7 --cri-socket unix:///var/run/cri-dockerd.sock
[preflight] Running pre-flight checks
        [WARNING Swap]: swap is enabled; production deployments should disable swap unless testing the NodeSwap feature gate of the kubelet
error execution phase preflight: [preflight] Some fatal errors occurred:
        [ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
        [ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists
[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`
To see the stack trace of this error execute with --v=5 or higher

解决:
1. 禁用交换分区

[root@k8s-node1 ~]# sed -ri 's/.*swap.*/#&/' /etc/fstab

2. 清除残留文件

#删除k8s配置文件和证书文件

[root@k8s-node1 ~]# rm -rf /etc/kubernetes/kubelet.conf /etc/kubernetes/pki/ca.crt

3.  重置环境

[root@k8s-node1 ~]# kubeadm reset --cri-socket unix:///var/run/cri-dockerd.sock

4.主节点重新执行token命令,避免token 过期报错

        ##注意该节点为master节点

[root@k8s-master ~]# kubeadm token create --print-join-command

 5. 重新加入

[root@k8s-node1 ~]# kubeadm join 192.168.10.110:6443 --token jx7hwk.hg6yuuplrvyf1pr4 --discovery-token-ca-cert-hash sha256:4dddf3238cd0a4a594e9eb4bed71a0d62696562e64643a9cec248230eb61afd7 --cri-socket unix:///var/run/cri-dockerd.sock

## 求助 ##

#关于kubeadm join报错信息如下:
[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.
[kubelet-check] It seems like the kubelet isn't running or healthy.
 

#关于Kubelet 似乎没有运行或处于不健康状态,报错信息如下:

Nov 26 09:33:47 k8s-node1 kubelet: Flag --pod-infra-container-image has been deprecated, will be removed in a future release. Image garbage collector will get sandbox image information from CRI.
Nov 26 09:33:47 k8s-node1 kubelet: I1126 09:33:47.959883   35616 server.go:203] "--pod-infra-container-image will not be pruned by the image garbage collector in kubelet and should also be set in the remote runtime"
Nov 26 09:33:47 k8s-node1 kubelet: I1126 09:33:47.962971   35616 server.go:467] "Kubelet version" kubeletVersion="v1.28.2"
Nov 26 09:33:47 k8s-node1 kubelet: I1126 09:33:47.962991   35616 server.go:469] "Golang settings" GOGC="" GOMAXPROCS="" GOTRACEBACK=""
Nov 26 09:33:47 k8s-node1 kubelet: I1126 09:33:47.963146   35616 server.go:895] "Client rotation is on, will bootstrap in background"
Nov 26 09:33:47 k8s-node1 kubelet: E1126 09:33:47.963676   35616 bootstrap.go:241] unable to read existing bootstrap client config from /etc/kubernetes/kubelet.conf: invalid configuration: [unable to read client-cert /var/lib/kubelet/pki/kubelet-client-current.pem for default-auth due to open /var/lib/kubelet/pki/kubelet-client-current.pem: no such file or directory, unable to read client-key /var/lib/kubelet/pki/kubelet-client-current.pem for default-auth due to open /var/lib/kubelet/pki/kubelet-client-current.pem: no such file or directory]
Nov 26 09:33:47 k8s-node1 kubelet: E1126 09:33:47.963700   35616 run.go:74] "command failed" err="failed to run Kubelet: unable to load bootstrap kubeconfig: stat /etc/kubernetes/bootstrap-kubelet.conf: no such file or directory"
Nov 26 09:33:47 k8s-node1 systemd: kubelet.service: main process exited, code=exited, status=1/FAILURE
Nov 26 09:33:47 k8s-node1 systemd: Unit kubelet.service entered failed state.
Nov 26 09:33:47 k8s-node1 systemd: kubelet.service failed.

已尝试方法:

1. 

2.

 

Logo

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

更多推荐