![Kubernetes-执行阶段预检:无法验证 API 服务器的身份](https://linux22.com/image/794098/Kubernetes-%E6%89%A7%E8%A1%8C%E9%98%B6%E6%AE%B5%E9%A2%84%E6%A3%80%EF%BC%9A%E6%97%A0%E6%B3%95%E9%AA%8C%E8%AF%81%20API%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E8%BA%AB%E4%BB%BD.png)
我正在尝试创建一个由一个主节点和三个工作节点组成的裸机 Kubernetes 集群。这些节点是在 VMWare Workstation 实验室环境中运行的 Ubuntu VM。主节点已成功启动并处于“就绪”状态,但我无法加入任何工作节点。我收到的错误消息是:
执行阶段预检:无法验证 API 服务器的身份
。
掌握:
root@master:~# kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready control-plane 38h v1.29.3
root@master:~# netstat -ntlp | grep LISTEN
tcp 0 0 127.0.0.1:10248 0.0.0.0:* LISTEN 36683/kubelet
tcp 0 0 127.0.0.1:10249 0.0.0.0:* LISTEN 39403/kube-proxy
tcp 0 0 192.168.13.1:2379 0.0.0.0:* LISTEN 35077/etcd
tcp 0 0 127.0.0.1:2379 0.0.0.0:* LISTEN 35077/etcd
tcp 0 0 192.168.13.1:2380 0.0.0.0:* LISTEN 35077/etcd
tcp 0 0 127.0.0.1:2381 0.0.0.0:* LISTEN 35077/etcd
tcp 0 0 127.0.0.1:10257 0.0.0.0:* LISTEN 79799/kube-controll
tcp 0 0 127.0.0.1:10259 0.0.0.0:* LISTEN 35132/kube-schedule
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 63271/systemd-resol
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1355/sshd
tcp 0 0 127.0.0.1:34487 0.0.0.0:* LISTEN 1137/containerd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 2748/sshd: master@p
tcp6 0 0 :::10250 :::* LISTEN 36683/kubelet
tcp6 0 0 :::6443 :::* LISTEN 35116/kube-apiserve
tcp6 0 0 :::10256 :::* LISTEN 39403/kube-proxy
tcp6 0 0 :::22 :::* LISTEN 1355/sshd
tcp6 0 0 ::1:6010 :::* LISTEN 2748/sshd: master@p
root@master:~# sudo ufw status
Status: inactive`
工作节点
master@new-worker2:~$ sudo no_proxy=192.168.13.1 kubeadm join 192.168.13.1:6443 --token 8htazp.lf07zanopt299271 --discovery-token-ca-cert-hash sha256:cdf446379eee25fffa7b5fff5409c05884330d3663e62ae3a8352c3d13040614
[preflight] Running pre-flight checks
^[[Berror execution phase preflight: couldn't validate the identity of the API Server: Get "https://192.168.13.1:6443/api/v1/namespaces/kube-public/configmaps/cluster-info?timeout=10s": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
To see the stack trace of this error execute with --v=5 or higher
root@new-worker2:~# netstat -ntlp | grep LISTEN
tcp 0 0 127.0.0.1:37605 0.0.0.0:* LISTEN 1120/containerd
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 865/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1148/sshd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 2053/sshd: master@p
tcp6 0 0 :::22 :::* LISTEN 1148/sshd
tcp6 0 0 ::1:6010 :::* LISTEN 2053/sshd: master@p
root@new-worker2:~# sudo ufw status
Status: inactive
I am able to ping thw master nodes IP address 192.168.13.1
root@new-worker2:~# ping 192.168.13.1
PING 192.168.13.1 (192.168.13.1) 56(84) bytes of data.
64 bytes from 192.168.13.1: icmp_seq=1 ttl=59 time=26.0 ms
64 bytes from 192.168.13.1: icmp_seq=2 ttl=59 time=24.3 ms
64 bytes from 192.168.13.1: icmp_seq=3 ttl=59 time=26.6 ms
64 bytes from 192.168.13.1: icmp_seq=4 ttl=59 time=22.8 ms
64 bytes from 192.168.13.1: icmp_seq=5 ttl=59 time=27.1 ms
我尝试了 StackOverflow 帖子建议的所有解决方案,例如生成新 Token、检查连接性、检查端口,以及重新安装了所有 Kubernetes 组件等。