6.6 kubeadm添加新的节点到集群

很多时候由于高可用的需要或者业务增加导致资源不足增加更多的节点。下面介绍一下node节点和master的增加方式

6.6.1 添加node节点

6.6.1.1 在master上生成新的token

kubeadm token create --print-join-command
kubeadm join 127.0.0.1:8443 --token izskvs.zusj16444vhnc725 --discovery-token-ca-cert-hash sha256:263be26e9eeb814bfb33eeb75595a199624860913c8285270395fa9a938d2948

6.6.1.2 在node节点执行join命令

将master输出结果拷贝到node节点执行

kubeadm join 127.0.0.1:8443 --token izskvs.zusj16444vhnc725 \
  --discovery-token-ca-cert-hash sha256:263be26e9eeb814bfb33eeb75595a199624860913c8285270395fa9a938d2948

6.6.2 添加master节点

6.6.2.1 在master上生成新的token

这一步跟node节点加入相同

kubeadm token create --print-join-command
kubeadm join 127.0.0.1:8443 --token izskvs.zusj16444vhnc725 --discovery-token-ca-cert-hash sha256:263be26e9eeb814bfb33eeb75595a199624860913c8285270395fa9a938d2948

6.6.2.2 在master节点上传证书

执行完会在kube-system名称空间下创建名为kubeadm-certsSecret,里面包含master节点需要用到的证书公钥和私钥。

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:
d82a6f600fe57cb4f7dc703e674e3f6458b67f5b7480a7fb8a4f83daab96182f

6.6.2.3 在新的master节点上执行加入命令

跟node节点相比就多了--control-plane为控制平台,需要带上certificate key

kubeadm join 127.0.0.1:8443 --token izskvs.zusj16444vhnc725 \
  --discovery-token-ca-cert-hash sha256:263be26e9eeb814bfb33eeb75595a199624860913c8285270395fa9a938d2948 \
  --control-plane --certificate-key d82a6f600fe57cb4f7dc703e674e3f6458b67f5b7480a7fb8a4f83daab96182f
Copyright © huangzhongde.cn 2021 all right reserved,powered by Gitbook该文件修订时间: 2022-01-28 00:02:24

results matching ""

    No results matching ""