1. shell脚本
cat >join.sh<<EOF
#!/bin/bash
set -e
ip=\$1
token=`kubeadm token create`
sha256=`openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'`
echo kubeadm join \${ip}:6443 --token \${token} --discovery-token-ca-cert-hash sha256:\${sha256}
EOF
2. 填写master IP地址
sh join.sh 192.168.1.127
3. 获取打印的结果,粘贴到新节点运行
kubeadm join 192.168.1.127:6443 --token 0tvq0j.vjo91vhj4ek4xagc --discovery-token-ca-cert-hash sha256:878a6903082fcd1c5dd6a5f762932372dc08785a27dd511e737ae8b79a638f47