Kubernetes High Availability Setup Using Ansible

1736

I have created an Ansible module to create a highly available (HA) Kubernetes cluster with latest release 1.4.x on CentOS 7.X.

You can use this module to install Kubernetes HA cluster with just one click, and your cluster will be ready in few minutes. 

There are 8 roles defined in this Ansible module.

  • addon – Use this role to create Kubernetes addon service like, kube-proxy, kube-dns, kube-dashboard, weavnet, weavescope-ui and grafana/infuxdb. This role should be called after the cluster is fully operational.
  • docker – Use this role to install later Docker version. It will install Docker on all cluster nodes, as Docker is required for all Kubernetes cluster members.
  • etcd – This role installs etcd cluster. Both secure and unsecure clusters are supported in it; choose whatever you want to install.
  • haproxy – This is Haproxy LB setup for Kubernetes api service, use it if you don’t have any other LB not available. For single node cluster it is not required.
  • master – Use this role to set up Kubernetes master services — kube-apiserver, kube-controller and kube-scheduler. All these services will run as pods on all master nodes. Both controller and scheduler are configured in HA mode.
  • node – This role installs kubelet on all cluster nodes and also creates required SSL certificate to communicate to master components.
  • sslcert – Creates all SSL certificates required to run secure K8S cluster. It creates certificate for api service, etcd, and admin account.
  • yum-repo – This role installs eple and kubernetes-1.4 package repo on all Kubernetes servers.

Follow the below steps to create Kubernetes HA setup on CentOS-7.

Prerequisites:

  • Ansible
  • All Kubernetes master/node should have password-less access from Ansible host

Download the Kubernetes-Ansible module from the following git-hub location:

https://github.com/pawankkamboj/HA-kubernetes-ansible

Set up variable according to requirement in group variable file all.yml and add host in inventory file.

Run cluster.yml playbook to create Kubernetes HA cluster.

For example — if we have two master servers, then it will deploy api, controller, scheduler service on all these in HA mode. Controller and Scheduler can be run in HA mode using the –leader-elect option, but to run API in HA, we need Load balancer and so that api traffic forwards to api servers.

Note – Addon roles should be run after cluster is fully operational.