Run Virtual Machines on Kubernetes with Kubevirt!

Bharat
3 min readJul 26, 2019

Kubevirt is an opensource project that allows users to run Virtual Machines on Kubernetes. Lately, I’ve contributed to this project on Github and have been working on running Virtual Machines on Kubernetes! Trust me, it’s fun. This post is a starting point for you to explore this cool project. I might write more about something that is a little more advanced that leverages these Kubevirt VMs on a cluster in future posts.

Clone the Official Repo — that’s the starting point!

Start by cloning the official GitHub Repo. The project is in a highly developmental phase, but it has some really good documentation on how to get started with the project and set it up.

The Makefile for the Kubevirt project pretty much consists of all the commands that are needed to test, develop and deploy a virtual machine on a cluster.

Choose a Kubernetes Cluster Backend for VMIs

The project provides a dev Kubernetes cluster environment that is bootstrapped together with a number of docker containers. While testing, I found this setup to be most accurate if one were to develop/contribute to the project (only for testing and development parity sake). Otherwise, I would not necessarily recommend this setup as it was really slow to iterate.

Instead, I would recommend one to use minikube or the Rancher Kubernetes Engine. For more details please refer to the official documentation for these projects. Regardless the one you choose, this blog post just assumes that there is a Kubernetes Cluster that is up and running. Verify you can list your resources using the kubectl tool {Eg: kubectl get ns}.

Lets deploy Kubevirt on to the K8S Cluster

Kubevirt allows us to make use of the APIs by deploying them as Custom Resource Definitions (CRDs) in the Cluster.

Also, Kubevirt works closely with KVM, so if you are using a OS that does not allow that level of interaction, we should be using emulation. One can do that by doing the following.

Let’s deploy the CRDs so that we can launch our very first VMI (Virtual Machine Instance).

Lets deploy a Virtual Machine Instance next

Deploy the testvm using the following command:

Next, lets look at the state of our VMI that we deployed.

We can see that our testvm is now deployed !

I would like to stop right there! Now you all should try this out and see if you can get into the VM. If you can leave me response or a clap so that I would know! Tip: Follow the project instructions on Github!

--

--