报错信息
报错截图:
主要报错原因:
error execution phase preflight: couldn't validate the identity of the API Server: invalid discovery token CA certificate hash: expected a 32 byte SHA-256 hash, found 27 bytes
出现该问题的原因有很多,但主要有两个:
- token过期
- 节点之间防火墙未关闭,从而导致
k8s api server
不可达
解决方式
重新生成token
在master节点上重新生成token
#在master上重新生成token
kubeadm token generate #生成toke
#会打印出新生成的token
977vdv.sxp3fn4g2fzxfeal
kubeadm token create 977vdv.sxp3fn4g2fzxfeal --print-join-command --ttl=0 #利用上面的token输出添加命令
#会打印出新的join命令
kubeadm join 192.168.238.131:6443 --token 977vdv.sxp3fn4g2fzxfeal --discovery-token-ca-cert-hash sha256:85ec1421ec0628f9e71c49f0530260dbe17bc7afe0af2765edfc12e20f9626f6
再将新的kubeadm join
命令放到想要添加的节点中执行,成功添加的结果如下:
在master节点上kubectl get nodes
关闭防火墙
此时需要检查和关闭所有服务器的firewalld
和selinux
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
systemctl disable firewalld --now