添加master和node节点(使用多master的时候添加)
1、按照上述内容部署kubectl组建
2、首先在master上生成新的token
2.1 为了加入node
[root@k8s-00001 ~]# kubeadm token create --print-join-command
kubeadm join 172.28.149.6:6443 --token km6vem.3zapw7cwe1km7e98 --discovery-token-ca-cert-hash sha256:f5c9d504a850a6de70637270572b0ff6752b0d247b016241b37eefb530aea435
3、在master上生成用于新master加入的证书
[root@k8s-00001 ~]# kubeadm init phase upload-certs --experimental-upload-certs
unknown flag: --experimental-upload-certs
To see the stack trace of this error execute with --v=5 or higher
解决:之前版本为v1.4.0时该命令正常执行
解决办法: 将–experimental-upload-certs 替换为 --upload-certs
[root@k8s-00001 ~]# kubeadm init phase upload-certs --upload-certs
[upload-certs] Storing the certificates in Secret "kubeadm-certs" in the "kube-system" Namespace
[upload-certs] Using certificate key:
b7721beec3d4926941a5c243e1c1c4c9124e2b61719e591aa3560d9514fa2de4
4、添加新master,把红色部分加到–experimental-control-plane --certificate-key后。
[root@k8s-00004 ~]#kubeadm join 172.28.149.6:6443 --token km6vem.3zapw7cwe1km7e98 --discovery-token-ca-cert-hash sha256:f5c9d504a850a6de70637270572b0ff6752b0d247b016241b37eefb530aea435 --control-plane --certificate-key b7721beec3d4926941a5c243e1c1c4c9124e2b61719e591aa3560d9514fa2de4
问题:
[preflight] Running pre-flight checks
[preflight] Reading configuration from the cluster...
[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
error execution phase preflight:
One or more conditions for hosting a new control plane instance is not satisfied.
unable to add a new control plane instance a cluster that doesn't have a stable controlPlaneEndpoint address
Please ensure that:
* The cluster has a stable controlPlaneEndpoint address.
* The certificates that must be shared among control plane instances are provided.
To see the stack trace of this error execute with --v=5 or higher
5、添加新node
[root@k8s-00005 ~]#kubeadm join 172.28.149.6:6443 --token km6vem.3zapw7cwe1km7e98 --discovery-token-ca-cert-hash sha256:f5c9d504a850a6de70637270572b0ff6752b0d247b016241b37eefb530aea435
微信公众号,需要的话就关注下我~