02 November, 2017

Setup production ready Kubernetes cluster using Kubespray and Vagrant running on the libvirt KVMs

If you are creating some Docker containers - sooner or later you will work with Kubernetes to automate deploying, scaling, and operating application containers. If you need simply run Kuberenetes only there is is project called Minikube which can help you to setup single VM with Kubernetes. This is probably the best way how you can start with it.

Sometimes it's handy to have "production ready" Kubernetes cluster running on your laptop contains multiple VMs (like in real production environment) - that's where you need to look around and search for another solution.

After trying few tools I decided to use Kubespray. It's a tool for deploying a production ready Kubernetes cluster on AWS, GCE, Azure, OpenStack or Baremetal.

I'm fine to create few virtual machines (using Vagrant) on my laptop and install Kubernetes there.


I'll use 3 VMs, all 3 have etcd installed, all 3 are nodes (running pods), 2 of them run master components:


(you can use more VMs with more advanced setup: https://github.com/kubespray/kubespray-cli)

Let's see how you can do it in Fedora 26 using Vagrant + libvirt + Kubespray + Kubespray-cli.

  • Install Vagrant VMs + libvirt and the Vagrantfile template for building the VMs
  • Create Python's Virtualenv for kubespray ans start the Kubernetes cluster provisioning

After the deployment is over you should be able to login to one of the master node and run + see something like:


Then you can work with the Kubernetes Cluster like usual...

You can see the whole installation here:

Some parts mentioned above are specific to Fedora 26, but most of it can be achievable on the other distros.

Enjoy ;-)

No comments:

Post a Comment

Note: only a member of this blog may post a comment.