Prerequisites
For KubeVirt and Talos to work you have to enable certain configurations in the BIOS and configure Talos properly for it to work.Enable virtualization in your BIOS
On many new PCs and servers, virtualization is enabled by default. Please consult your manufacturer on how to enable this in the BIOS. You can also run KubeVirt from within a virtual machine. For that to work you have to enable Nested Virtualization. This can also be done in the BIOS.Configure your network interface in bridge mode (optional)
When you want to leverage Multus to give your virtual machines direct access to your node network, your bridge needs to be configured properly. This can be done by setting your network interface in bridge mode. You can look up the network interface name by using the following command:eth0
.
Now you can configure your bridge properly.
This can be done in the machine config of your node:
Install the local-path-provisioner
When we are using KubeVirt, we are also installing the CDI (containerized data importer) operator.
For this to work properly, we have to install the local-path-provisioner
.
This CNI can be used to write scratch space when importing images with the CDI.
You can install the local-path-provisioner
by following this guide.
Configure storage
If you would like to use features such asLiveMigration
shared storage is neccesary.
You can either choose to install a CSI that connects to NFS or you can install Longhorn, for example.
For more information on how to install Longhorn on Talos you can follow this link.
To install the NFS-CSI driver, you can follow This guide.
After the installation of the NFS-CSI driver is done, you can create a storage class for the NFS CSI driver to work:
nolock
option.
If not, the nfs-csi storageclass won’t work, because talos doesn’t have a rpc.statd
daemon running.
Install virtctl
virtctl
is needed for communication between the CLI and the KubeVirt api server.
You can install the virtctl
client directly by running:
kubectl
:
Installing KubeVirt
After the neccesary preperations are done, you can now install KubeVirt. This can either be done through the Operator Lifecycle Manager or by just simply applying a YAML file. We will keep this simple and do the following:KubeVirt configuration options
In this yaml file we specified certain configurations:featureGates
KubeVirt has a set of features that are not mature enough to be enabled by default.
As such, they are protected by a Kubernetes concept called feature gates.
More information about the feature gates can be found in the KubeVirt documentation.
In this example we enable:
LiveMigration
— For live migration of virtual machines to other nodesNetworkBindingPlugins
— This is needed for Multus to work.
smbios
Here we configure a specific smbios configuration.
This can be useful when you want to give your virtual machines a own sku, manufacturer name etc.
workloadUpdateStrategy
If this is configured, virtual machines will be live migrated to other nodes when KubeVirt is updated.
Installing CDI
The CDI (containerized data importer) is needed to import virtual disk images in your KubeVirt cluster. The CDI can do the following:- Import images of type:
- qcow2
- raw
- iso
- Import disks from either:
- http/https
- uploaded through virtctl
- Container registry
- Another PVC
VirtualMachine
CR.
When applying either the DataVolume
CR or the VirtualMachine
CR with a dataVolumeTemplates
, the CDI kicks in and will do the following:
- creates a PVC with the requirements from either the
DataVolume
or thedataVolumeTemplates
- starts a pod
- writes temporary scratch space to local disk
- downloads the image
- extracts it to the temporary scratch space
- copies the image to the PVC
scratchSpaceStorageClass
This is the storage class that we installed earlier with the local-path-provisioner
.
This is needed for the CDI to write scratch space to local disk before importing the image
podResourceRequirements
In many cases the default resource requests and limits are not sufficient for the importer pod to import the image.
This will result in a crash of the importer pod.
After applying this yaml file, the CDI operator is ready.
Creating your first virtual machine
Now it is time to create your first virtual machine in KubeVirt. Below we will describe two examples:- A virtual machine with the default CNI
- A virtual machine with Multus
Basic virtual machine example with default CNI
Datavolume
.
You can monitor this process by running:
DataVolume
is created, you can start the virtual machine:
VirtualMachine
called VirtualMachineInstance
:
console
command it will open a terminal to the virtual machine.
With the vnc
command, it will open vncviewer
.
Note that a vncviewer
needs to installed for it to work.
Now you can create a Service
object to expose the virtual machine to the outside.
In this example we will use MetalLB as a LoadBalancer.
Basic virtual machine example with Multus
kubectl virt start fedora-vm
.
After that you can look up the ip address of the virtual machine with