Running Kubernetes on Fedora with Vagrant

Kubernetes is a Container Cluster Manager from Google which basically means that Kubernetes is an orchestration of many services running on plenty of Docker containers. Google actually supports a several ways how to run Kubernetes and luckily Vagrant is one of them.

Note: The following is actually a short and fixed version of official getting started guide specifically written for Fedora host and libvirt provider.

You can run the installation scripts directly on your computer or inside a virtual machine which I highly recommend. I already wrote about setting up nested virtualization with Vagrant and KVM before.

First you need to install Vagrant with libvirt support and other dependencies on Fedora. You can also use the new Vagrant assistant to do install vagrant-libvirt and set up the polkit rules. I am including which and wget as they might not be available in some boxes and the Google installation script needs them.

On Fedora 22 run:

On Fedora 21 run:

Once you have that ready, we can just start the Google installation script:

First we set up the Vagrant provider for the installation script and libvirt provider for Vagrant. Then we run the script provided by Google. Unfortunately that failed me with something like Can’t find the necessary components for the libvirt vagrant provider, please fix and retry. Amusingly enough it does not tell you what’s actually wrong so I looked on the downloaded sources and found the issue:

No libvirt there. So I went and tried to add a line for it which seemed to fix the issue:

So let’s continue. But in order not to run the installation script again, we only run from the Kubernetes sources that got downloaded by the above installation script: is a script that replaces vagrant up call for us and should spin and configure two virtual machines for us, one for Kubernetes master and one for our first minion. Once it finishes we can list the VMs with familiar Vagrant command:

Now we can vagrant ssh master and explore our master server by running various kubectl calls to list pods, nodes, services and other stuff. We can also use docker ps command to see what containers are running. We can even find out what’s running on our minion-1 server without explicitly logging there with:

Nice, everything seems to work and we can start playing with Kubernetes.

Leave a comment

Your email address will not be published. Required fields are marked *