Running and Managing VMs on Kubernetes

The cloud native ecosystem has been primarily shaped by containers. As a result, Kubernetes has become the go-to platform for managing large-scale, containerized workloads. But what if you still need virtual machines (VMs)? That’s where KubeVirt comes into play.

Evolution

In the dark ages, mainframes were huge and costly. IBM led the way in virtualization with its CP-40 and CP-67 systems, enabling a single mainframe to be divided into multiple “virtual” machines. Each machine could run its own operating system, acting like a separate computer. This was a game-changer because it enabled organizations to maximize the value of their hardware investment.

As personal computers became more common, the idea of running multiple operating systems on a single machine gained popularity. Companies like VMware popularized this in the late 1990s by introducing virtualization for x86 hardware. Suddenly, a single physical server could host multiple virtual servers, reducing costs and enhancing flexibility. Virtual machines were beneficial, but they had overhead because each VM ran a full OS. System administrators began seeking something lighter. That’s when containers emerged, building on earlier concepts like chroot, introduced in 1979, and Solaris Zones introduced in 2004. Docker, introduced in 2013, made containers accessible to everyone. It allowed applications to run in isolated environments without the bulk of full VMs and enabled our application deployment method to evolve.

So what is KubeVirt?

KubeVirt is an open-source extension for Kubernetes that lets you run and manage VMs alongside containers. It extends Kubernetes' APIs to treat VMs as first-class resources, just like regular Pods or Deployments. This means you can manage both workloads with the same tools, processes, and automation. In short, KubeVirt bridges the gap between containerized applications and traditional VM-based workloads.

KubeVirt began as a project at Red Hat in 2016 to help organizations modernize without abandoning their existing VM workloads. Many enterprises had significant investments in VM-based applications, and rewriting them into containers was often unrealistic. It was open-sourced in 2017 and has been part of the CNCF landscape since 2019. Version 1.0, officially released in July 2020, is supported by a growing ecosystem surrounding it. KubeVirt recently gained even more traction as a result of Broadcom’s acquisition of VMware.

How does KubeVirt work?

The architecture of KubeVirt is built on solid design principles that leverage the strengths of Kubernetes by using the operator pattern. KubeVirt is a Kubernetes operator that adds extra functionality. It provides new Custom Resource Definitions (CRDs) that allow virtual machines to be described as Custom Resources (CR).

You can think of KubeVirt as a pod that contains a KVM-based virtual machine. In Kubernetes, a pod is a set of containers that share resources and run together. KVM (Kernel-based Virtual Machine) is an open-source extension of the Linux kernel that lets it act as a hypervisor. Virtualizations with KVM often use other technologies, such as QEMU and Libvirt, that simplify the management of virtual machines. As a result, KubeVirt-powered virtual machines behave much like pods, allowing their lifecycle to be managed within Kubernetes, including handling states such as stopped, paused, and running, as well as operations like provisioning, scheduling, and migrating virtual machines.

In addition to the new Kubernetes CRDs, KubeVirt includes various runtime components.

virt-controller

The virt-controller monitors created and existing virtual machine definitions. These include the custom resources (CRs) VirtualMachine and VirtualMachineInstance. When a new virtual machine definition is created, the virt-controller creates a pod for the instance and assigns it to a node.

virt-api

The virt-api provides a RESTful API for all aspects of creating, validating, and managing virtual machines.

virt-handler

The virt-handler runs as a daemon set on each Kubernetes node. It configures the pod according to the VM definition and ensures the VM's state matches the definition. If a change is detected, it directs the virt-handler container to perform the necessary actions.

virt-launcher

The virt-launcher is a container that runs inside the VM pod. It starts and monitors the VM using a local libvirtd instance.

libvirtd

Libvirt supplies a low-level virtualization architecture and interface to the kernel. This is used to manage the lifecycle of the VM process.

What can KubeVirt be used for?

Using virtual machines has become an essential part of running today’s complex systems. KubeVirt can handle various VM use cases, such as: 

  • Standardizing technical infrastructure 
  • Streamlining workflows with consistent pipelines and tools during development 
  • Running VM and container workloads in parallel for legacy applications or when migrating applications to containers 
  • Using and directly accessing dedicated hardware like graphics cards or network interfaces 
  • Offering Kubernetes as a Service (KaaS), for instance, by using Cluster API provider KubeVirt 
  • Avoiding vendor lock-in and license costs (still up for debate) 

However, there are challenges with KubeVirt: 

  • Not suitable for all workloads: While KubeVirt offers many benefits, it may not be the best option for every workload, especially those needing specialised virtualization features.
  • Challenges in migrating legacy VMs: Moving existing legacy VMs to KubeVirt can create challenges, including compatibility issues and the need for careful planning.
  • Need for organisational change: Successfully adopting KubeVirt may require cultural and operational shifts within organisations to benefit from its capabilities fully.

KubeVirt as an Alternative

KubeVirt is a compelling alternative to traditional virtualization platforms. Its goal is to facilitate the migration of virtual machine workloads into a contemporary, cloud-native environment, not to replace current hypervisors completely.

Organizations can standardise infrastructure and streamline operational procedures by using the same tools and workflows for managing virtual machines as they do for containers. The result of this unification is a more uniform product landscape, lower operating costs, and a reduction in system complexity.

Its open-source nature is an additional benefit. Free project access and the backing of a sizable and vibrant community help mitigate the risk of vendor lock-in, which many businesses encounter when using proprietary virtualization solutions.

In short, KubeVirt isn’t just another virtualization platform. It’s a bridge to a container-native future, where legacy and modern workloads can coexist seamlessly.

---

https://kubevirt.io/

Verpassen Sie nie wieder ein Update.

Abonnieren Sie Updates und Artikel ohne Spam.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.