[转帖]使用kubeadm 新加入节点(原始token过期后)

使用kubeadm 新加入节点(原始token过期后)---转发

 
kubeadm token create --print-join-command

https://www.cnblogs.com/xiaoyaojinzhazhadehangcheng/p/11605934.html

最简单的方法

 

kubeadm join

kubeadm init 安装完成后你会得到以下的输出,使用join指令可以新增节点到集群,此token 有效期为24小时

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

  kubeadm join 18.16.202.35:6443 --token zr8n5j.yfkanjio0lfsupc0 --discovery-token-ca-cert-hash sha256:380b775b7f9ea362d45e4400be92adc4f71d86793ba6aae091ddb53c489d218c

kubeadm token

在新节点没有拿到证书以前,新节点和api server的通信是通过token和ca的签名完成的,具体的步骤如下

# 生成token
[root@node1 flannel]# kubeadm  token create
kiyfhw.xiacqbch8o8fa8qj
[root@node1 flannel]# kubeadm  token list
TOKEN                     TTL         EXPIRES                     USAGES                   DESCRIPTION   EXTRA GROUPS
gvvqwk.hn56nlsgsv11mik6   <invalid>   2018-10-25T14:16:06+08:00   authentication,signing   <none>        system:bootstrappers:kubeadm:default-node-token
kiyfhw.xiacqbch8o8fa8qj   23h         2018-10-27T06:39:24+08:00   authentication,signing   <none>        system:bootstrappers:kubeadm:default-node-token
# 生成ca的sha256 hash值
[root@node1 flannel]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
5417eb1b68bd4e7a4c82aded83abc55ec91bd601e45734d6aba85de8b1ebb057
# 组装join命令
kubeadm join 18.16.202.35:6443 --token kiyfhw.xiacqbch8o8fa8qj --discovery-token-ca-cert-hash sha256:5417eb1b68bd4e7a4c82aded83abc55ec91bd601e45734d6aba85de8b1ebb057
# 一步完成以上步骤
kubeadm token create --print-join-command
# 手动生成token,完成命令打印
token=$(kubeadm token generate)
kubeadm token create $token --print-join-command --ttl=0
上一篇:Android apk签名详解——AS签名、获取签名信息、系统签名、命令行签名


下一篇:docker 学习操作记录 3