一、查看是否过期
root@ali005:~# kubeadm token list
TOKEN TTL EXPIRES USAGES DESCRIPTION
abcdef.0123456789abcdef 9h 2020-05-28T18:38:18+08:00 authentication,signing <none>
二、如果没有过期,则利用证书获取sha256的校验值
root@ali005:~# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
f2d8ddf7e2470d9e3290519e61dc3fdbc6b60497f4497c023a78abcd6c3ee913
三、node节点的加入:
kubeadm join 172.26.195.120:6443 --token abcdef.0123456789abcdef \
--discovery-token-ca-cert-hash sha256:f2d8ddf7e2470d9e3290519e61dc3fdbc6b60497f4497c023a78abcd6c3ee913
以上的--token和--discovery-token-ca-cert-hash,是第一,二的获取物。
四、如果已过期,则重新生成token
root@ali005:~# kubeadm token create --print-join-command --ttl 24h0m0s
W0528 09:01:09.991940 15431 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]
kubeadm join 172.26.195.120:6443 --token ologft.wx9rex5tjjd6bqoi --discovery-token-ca-cert-hash sha256:f2d8ddf7e2470d9e3290519e61dc3fdbc6b60497f4497c023a78abcd6c3ee913
以上的--ttl 为token的生存期,--print-join-command 输出节点的添加命令
网友评论