Kubevirt on K3S


Userlevel 7
Badge +22

Hi Folks,

Recently Veeam Vanguard @k00laidIT aka Jim Jones asked about which Linux distribution to use for kubernetes/minikube. Turns out he is going to explore kubevirt. Now if he is looking into this you know it is serious. 

Feeling pangs of IT conscience I decided to take a look myself. I have known about kubevirt for a while but for some strange reason never wandered into those woods.

So this week I decided it was high time to discover potentially yet another Kubernetes rabbit hole to fall blissfully into!

To my surprise everything was much simpler that I was prepared for. 

Here is my step by step set of instructions for getting kubevirt up and running on a 3 node k3s cluster. I might also try this on a Laptop Rancher Desktop install a bit later as well.

First we need to get the current stable version.

export VERSION=$(curl -s https://storage.googleapis.com/kubevirt-prow/release/kubevirt/kubevirt/stable.txt)

echo $VERSION

Now we will deploy the operator.

kubectl create -f https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/kubevirt-operator.yaml

You can check how the deployment is going with this command.

kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.phase}"

Once the deployment is complete the status should change to Deployed.

Deployed

You can also check the state of the pods in the kubevirt namespace.

kubectl get po -n kubevirt
pods

 

In order to control your virtual machines you will need to install the virtctl command.

VERSION=$(kubectl get kubevirt.kubevirt.io/kubevirt -n kubevirt -o=jsonpath="{.status.observedKubeVirtVersion}")
ARCH=$(uname -s | tr A-Z a-z)-$(uname -m | sed 's/x86_64/amd64/') || windows-amd64.exe
echo ${ARCH}
curl -L -o virtctl https://github.com/kubevirt/kubevirt/releases/download/${VERSION}/virtctl-${VERSION}-${ARCH}
chmod +x virtctl
sudo install virtctl /usr/local/bin
virtctl

That is it! ready to go, almost!

Before we run a vm from the kubevirt Labs we need to make one change and enable software virtualization emulation.

kubectl edit -n kubevirt kubevirt kubevirt

Under spec add useEmulation: true then save and exit your editor.

useEmulation: true

 

Now we are ready to run a vm. Kubevirt provides us with some labs and the first one allows us to get a vm running and then login to its console.

Download the vm manifest.

wget https://kubevirt.io/labs/manifests/vm.yaml

Apply the manifest.

kubectl apply -f https://kubevirt.io/labs/manifests/vm.yaml

Start the vm.

virtctl start testvm

We can check the vm’s status.

kubectl get vms
testvm is running

 

Now as it states in the instructions we should be able to login to the console.

virtctl console testvm
The Test VM console

Conveniently the username and password are provided.

Inside our vm

Here are the links to the documentation that I followed:

I used the Kind instructions only because they were the closest to k8s/k3s versions:

https://kubevirt.io/quickstart_kind/

https://kubevirt.io/labs/kubernetes/lab1.html

That’s it. Pretty straightforward and fun. Now to see if we can get windows working in Kubevirt 😃 on a Rancher Desktop laptop installation. I know what my fun thrilled weekend will now be like!!!


5 comments

Userlevel 7
Badge +20

Great post and follow up to the other thread. Great to see all this learning. 👍

Userlevel 7
Badge +17

Cool info on kubevirt. Thanks for sharing Geoff!

Userlevel 7
Badge +6

Thanks Geoff, another great exploring post. 
 

You mentioned “enable software virtualisation emulation” this is because you are running your K3s cluster on a hypervisor? 
 

Think you moved to Proxmox, so we have some physical hardware with Proxmox on and then you have your K3s VMs and cluster on there and then we have a testvm running on KubeVirt? 

Userlevel 7
Badge +22

Thanks Geoff, another great exploring post. 
 

You mentioned “enable software virtualisation emulation” this is because you are running your K3s cluster on a hypervisor? 
 

Think you moved to Proxmox, so we have some physical hardware with Proxmox on and then you have your K3s VMs and cluster on there and then we have a testvm running on KubeVirt? 

Yes that is it! So my “super cheap and barely visible” lab is running one Proxmox on an old desktop that I bought downtown with beefed up memory. For storage I also have a Synology. In that Synology (which I beefed up memory for as well) I am trying to run a second Proxmox but that is a work in progress due to processor. 

This lab for Kubernetes stuff and one VBR (with a VHR repo) works well. However, I just installed NutanixCE in there as well and that does stretch things a bit. 

The good thing about trying to run stuff on empty beer cans and chewing gum is you really learn the inner guts of the systems since you have to kick and squeeze stuff to get it working. 

 

Userlevel 7
Badge +22

Brings me back to why I love Kubernetes, there is so much you can do on so little!!!

Comment