k8s node节点加入到集群时卡住 “[preflight] Running pre-flight checks”

  1. 搭建集群之后想把node加入到集群中,如下图一直卡住
[root@k8s-node1 log]# kubeadm join 10.0.0.200:6443 --token dmsehb.dvofkx1z5dpc0r58 --discovery-token-ca-cert-hash sha256:f8d6e3c1562adcd5e35d6246679c23759124229bf36e100cbf03398849263911
[preflight] Running pre-flight checks
  1. 查看master节点,发现时间不同步
[root@k8s-master1 kubeadm]# date
Sun Mar 20 04:05:57 CST 2022
[root@k8s-node1 log]# date
Mon Mar 21 17:35:48 CST 2022
#同步时间
[root@k8s-master1 kubeadm]# yum install ntpdate
[root@k8s-master1 kubeadm]# ntpdate ntp1.aliyun.com;hwclock --systohc
date;hwclock
  1. 再次执行命令,还是不行
[root@k8s-node1 log]# kubeadm join 10.0.0.200:6443 --token dmsehb.dvofkx1z5dpc0r58 --discovery-token-ca-cert-hash sha256:f8d6e3c1562adcd5e35d6246679c23759124229bf36e100cbf03398849263911
[preflight] Running pre-flight checks
  1. 去mater节点重新生成token
[root@k8s-master1 kubeadm]# kubeadm token create --ttl 0 --print-join-command
kubeadm join 10.0.0.200:6443 --token dmsehb.dvofkx1z5dpc0r58 --discovery-token-ca-cert-hash sha256:f8d6e3c1562adcd5e35d6246679c23759124229bf36e100cbf03398849263911
  1. 再次加入集群
[root@k8s-node2 ~]# kubeadm join 10.0.0.200:6443 --token dmsehb.dvofkx1z5dpc0r58 --discovery-token-ca-cert-hash sha256:f8d6e3c1562adcd5e35d6246679c23759124229bf36e100cbf03398849263911
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Starting the kubelet
[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...

This node has joined the cluster:
* Certificate signing request was sent to apiserver and a response was received.
* The Kubelet was informed of the new secure connection details.

Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

[root@k8s-node2 ~]#

成功!!!!!!

总结:
当node节点加入集群时卡在[preflight] Running pre-flight checks,有两种原因
1. 集群节点之前时间不同步
2. token过期,重新生成一下

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐