<p>I am trying to achieve the k8s high availability using kubeadm. I am following the document <a href="https://v1-10.docs.kubernetes.io/docs/setup/independent/high-availability/" rel="nofollow noreferrer">k8s HA using kubeadm</a></p>

<p>In the official document, it is recommended to have the failover mechanism/load balancer for the kube-apiserver. I tried keepalived but, in case of setup on aws/gcp instaces, it lands in split brain situation as multicast is not supported and so I am not allowed to use it. Is there any way out for this?</p>

Yudi
<p><a href="https://kubernetes.io" rel="nofollow noreferrer">Kubernetes</a> is a container-orchestration system for automating deployment, scaling, and management of containerized applications.
Kubernetes play best in High Available and Load Balancing environments.</p>

<p>As <a href="https://stackoverflow.com/users/645002/jaxxstorm">@jaxxstorm</a> mentioned, cloud providers give you a possibility to use native load balancers, and I also suggest it is
a good pole position with High Availability attempt. You may be interested in <a href="https://cloud.google.com/kubernetes-engine/docs/" rel="nofollow noreferrer">GCP</a> documentation.</p>

<p>Kubeadm on Kubernetes homebrewed environment requires some additional work, and from my point of view, it is good
to set up <a href="https://github.com/kelseyhightower/kubernetes-the-hard-way" rel="nofollow noreferrer">Kubernetes The Hardway</a> then starts to play with <a href="https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/" rel="nofollow noreferrer">Kubeadm</a>. </p>

<p>OK, I assume servers for the installation are ready. To create a not complex installation of multi-master cluster, <strong>you need 3 masters node (10.0.0.50-52) and Load Balancer (10.0.0.200)</strong>.</p>

<p>Generate token and save the output to file:</p>

<p><code>kubeadm token generate</code></p>

<p>Create a kubeadm config file:</p>

<pre><code>apiVersion: kubeadm.k8s.io/v1alpha1
kind: MasterConfiguration
etcd:
  endpoints:
  - "http://10.0.0.50:2379"
  - "http://10.0.0.51:2379"
  - "http://10.0.0.52:2379"
apiServerExtraArgs:
  apiserver-count: "3"
apiServerCertSANs:
- "10.0.0.50"
- "10.0.0.51"
- "10.0.0.52"
- "10.0.0.200"
- "127.0.0.1"
token: "YOUR KUBEADM TOKEN"
tokenTTL: "0"
</code></pre>

<p>Copy the config file to all nodes.</p>

<p>Do initialization on the first master instance:</p>

<pre><code>kubeadm init --config /path/to/config.yaml
</code></pre>

<p>The new master instance, will have all the certificates and keys necessary for our master cluster.</p>

<p>Copy directory structure <code>/etc/kubernetes/pki</code> to other masters to the same location.</p>

<p>On other master servers:</p>

<pre><code>kubeadm init --config /path/to/config.yaml
</code></pre>

<p>Now let’s start to set up load balancer:</p>

<p>Copy <code>/etc/kubernetes/admin.conf</code> into <code>$HOME/.kube/config</code></p>

<p>next, edit <code>$HOME/.config</code> and  replace </p>

<blockquote>
  <p>server:10.0.0.50</p>
</blockquote>

<p>with </p>

<blockquote>
  <p>server:10.0.0.200</p>
</blockquote>

<p>Check if nodes are working fine:</p>

<p><code>kubectl get nodes</code></p>

<p>On all workers execute:</p>

<p><code>kubeadm join --token YOUR_CLUSTER_TOKEN 10.0.0.200:6443 --discovery-token-ca-cert-hash sha256:89870e4215b92262c5093b3f4f6d57be8580c3442ed6c8b00b0b30822c41e5b3</code></p>

<p>And that’s it! If everything was setup cleanly, you should now have a highly available cluster. </p>

<p>I found <a href="https://medium.com/@bambash/ha-kubernetes-cluster-via-kubeadm-b2133360b198" rel="nofollow noreferrer">"HA Kubernetes cluster via Kubeadm"</a> tutorial useful, thank you <a href="https://medium.com/@bambash" rel="nofollow noreferrer">@Nate Baker</a> for inspiration.</p>
