k8s加入集群之获取token和sha256
1 获取或生成token1.1 查看token命令:kubeadm token list[root@k8s-master /]# kubeadm token listTOKENTTLEXPIRESUSAGESDESCRIPTIONEXTRA GROUPSjg2shz.spsj
·
1 获取或生成token
1.1 查看token
- 命令:
kubeadm token list
[root@k8s-master /]# kubeadm token list TOKEN TTL EXPIRES USAGES DESCRIPTION EXTRA GROUPS jg2shz.spsji7ux1diwxalf 22h 2021-12-15T01:59:42Z authentication,signing The default bootstrap token generated by 'kubeadm init'. system:bootstrappers:kubeadm:default-node-token
1.2 生成新的token
- 命令:
kubeadm token create
[root@k8s-master ~]# kubeadm token create om0i6m.rxpj28441rvulblw
2 获取ca证书sha256编码的hash值
- 命令:
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
[root@k8s-master ~]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //' bb6baac715a3fb46c8061b7390330ef6f9d15dc7aea8561502762fbc553aafb1
3 加入集群
kubeadm join master节点IP:6443 \
--token om0i6m.rxpj28441rvulblw \
--discovery-token-ca-cert-hash sha256:bb6baac715a3fb46c8061b7390330ef6f9d15dc7aea8561502762fbc553aafb1
参考文章:
K8S Node如何加入集群:https://www.jianshu.com/p/eea7059cc199
更多推荐
已为社区贡献1条内容
所有评论(0)