cookeem / kubeadm-ha

通过kubeadm安装kubernetes高可用集群,使用docker/containerd容器运行时,适用v1.24.x以上版本
MIT License
679 stars 275 forks source link

How to add new control plane (master) node to existing cluster? #61

Closed dipiash closed 5 years ago

dipiash commented 5 years ago

Hi!

I have an existing cluster with 3 master and 5 worker nodes (Kubernetes v 1.14.x). I'm installed cluster from this guide - https://github.com/cookeem/kubeadm-ha/blob/master/README.md.

How can I add new control plane (master) node to existing configured claster?

On this new 2 control plane nodes I have a configured keepalived - it works with existing other 3 keepalived instances. And I have installed: kubeadm, kubectl, kubelet, docker and docker-compose on 2 control plane.

Please help

dipiash commented 5 years ago

I'm answer my self :)

  1. Use this part of kubernetes documentation
  2. You should copy only next certs to you new control plane node
    USER=ubuntu # customizable
    CONTROL_PLANE_IPS="10.0.0.7 10.0.0.8" # customizable
    for host in ${CONTROL_PLANE_IPS}; do
    scp -rp /etc/kubernetes/pki/ca.crt "${USER}"@$host:/etc/kubernetes/pki/ca.crt
    scp -rp /etc/kubernetes/pki/ca.key "${USER}"@$host:/etc/kubernetes/pki/ca.key
    scp -rp /etc/kubernetes/pki/sa.key "${USER}"@$host:/etc/kubernetes/pki/sa.key
    scp -rp /etc/kubernetes/pki/sa.pub "${USER}"@$host:/etc/kubernetes/pki/sa.pub
    scp -rp /etc/kubernetes/pki/front-proxy-ca.crt "${USER}"@$host:/etc/kubernetes/pki/front-proxy-ca.crt
    scp -rp /etc/kubernetes/pki/front-proxy-ca.key "${USER}"@$host:/etc/kubernetes/pki/front-proxy-ca.key
    scp -rp /etc/kubernetes/pki/etcd/ca.crt "${USER}"@$host:/etc/kubernetes/pki/etcd/ca.crt
    scp -rp /etc/kubernetes/pki/etcd/ca.key "${USER}"@$host:/etc/kubernetes/pki/etcd/ca.key
    done
  3. Get command for generate new token and get command to join
    sudo kubeadm token create --print-join-command

    You get command like this

    kubeadm join 123.60.44.32:16443 --token XXXXXXXXXXX  --discovery-token-ca-cert-hash sha256:dv3c44v17b4e98d764tcde98453156d7d9048fb921edd93d0e1ab7bfd09rtec3
  4. Add flag to this command for control plane node
    kubeadm join 123.60.44.32:16443 --token XXXXXXXXXXX  --discovery-token-ca-cert-hash sha256:dv3c44v17b4e98d764tcde98453156d7d9048fb921edd93d0e1ab7bfd09rtec3 --experimental-control-plane
  5. Execute this command on you new control plane node