what is the best way to add a second master in kubernetes cluster?

5/23/2018

I have a 5 worker node and a master node in a kubernetes cluster. I want to add a new master in that cluster so that the cluster will be highly available. what could be the best approach to add a new master in a cluster?

-- user2370590
kubernetes

1 Answer

5/24/2018

This article helped me a lot with understanding how HA cluster looks like in real life, so I recommend to check it out first.

Here is a quote from Kubernetes documentation that describes creating HA cluster:

Starting an HA-compatible cluster To create a new HA-compatible cluster, you must set the following flags in your kube-up script:

  • MULTIZONE=true - to prevent removal of master replicas kubelets from zones different than the server's default zone. Required if you want to run master replicas in different zones, which is recommended.

  • ENABLE_ETCD_QUORUM_READS=true - to ensure that reads from all API servers will return the most up-to-date data. If true, reads will be directed to leader etcd replica. Setting this value to true is optional: reads will be more reliable but will also be slower.

Optionally, you can specify a GCE zone where the first master replica is to be created. Set the following flag:

  • KUBE_GCE_ZONE=zone - zone where the first master replica will run. The following sample command sets up a HA-compatible cluster in the GCE zone europe-west1-b:

    $ MULTIZONE=true KUBE_GCE_ZONE=europe-west1-b ENABLE_ETCD_QUORUM_READS=true ./cluster/kube-up.sh

Note that the commands above create a cluster with one master; however, you can add new master replicas to the cluster with subsequent commands.

Adding a new master replica After you have created an HA-compatible cluster, you can add master replicas to it. You add master replicas by

using a kube-up script with the following flags:

  • KUBE_REPLICATE_EXISTING_MASTER=true - to create a replica of an existing master.

  • KUBE_GCE_ZONE=zone - zone where the master replica will run. Must be in the same region as other replicas’ zones.

You don’t need to set the MULTIZONE or ENABLE_ETCD_QUORUM_READS flags, as those are inherited from when you started your HA-compatible cluster.

The following sample command replicates the master on an existing HA-compatible cluster:

$ KUBE_GCE_ZONE=europe-west1-c KUBE_REPLICATE_EXISTING_MASTER=true ./cluster/kube-up.sh

You can also find these resources useful:

-- VAS
Source: StackOverflow