The cloud-native ecosystem is dominated by containerized applications, but many organizations still rely heavily on virtual machines (VMs) for their legacy applications. Enter KubeVirt – a powerful open-source project that bridges the gap between containers and virtual machines, enabling you to run and manage VMs alongside your Kubernetes workloads.
In this blog post, I will guide you through the basics of KubeVirt, explaining its core concepts, its advantages, and a quick guide on how to get started.
What is KubeVirt?
KubeVirt is an extension for Kubernetes that adds the capability of running VMs alongside containers. It does this by treating VMs as first-class citizens in Kubernetes, integrating them seamlessly into the Kubernetes control plane. Essentially, it allows Kubernetes to manage both containerized and virtualized workloads in a unified platform.
With KubeVirt, you can:
Run your traditional VM workloads on Kubernetes clusters.
Leverage Kubernetes' robust scheduling, scaling, and networking features for VMs.
Simplify your infrastructure by consolidating both containerized and VM workloads on a single Kubernetes platform.
Key Features of KubeVirt
Unified Control Plane: KubeVirt integrates with Kubernetes, allowing you to use standard Kubernetes tools like
kubectl
to manage VMs.VM Lifecycle Management: You can create, delete, and modify VMs using Kubernetes YAML manifests, similar to how you manage Pods.
Networking and Storage: KubeVirt leverages Kubernetes' networking and storage capabilities, ensuring that your VMs can utilize the same resources as your containerized workloads.
VM Migration: Live migration of VMs between nodes is supported, ensuring high availability and easy scaling of workloads.
Architecture of the KubeVirt
The architecture diagram shows the internal workings of KubeVirt on a Kubernetes cluster, showing the interaction between Kubernetes components and KubeVirt components for managing virtual machines (VMs). Below is a breakdown of the architecture:
Kubernetes Components (Left Side)
kubectl (user commands):
kubectl
is the command-line interface used to interact with the Kubernetes API server. In this case,kubectl
is also used to manage VirtualMachine Instances (VMIs) within KubeVirt.API Server:
The API server is a core Kubernetes component that handles RESTful requests from
kubectl
. It is the central control point for all API interactions in the cluster, including those from KubeVirt. The API server processes VM-related requests and passes them to the appropriate KubeVirt components.virt-controller:
This KubeVirt component is responsible for reconciling the desired state of VirtualMachines (VMs). It communicates with the API server to ensure that VMs are created, deleted, and maintained according to the specifications defined in the cluster.
virt-api:
virt-api
provides the API endpoints specific to KubeVirt and integrates them into the Kubernetes API server, enabling Kubernetes to recognize and handle KubeVirt resources like VMs and VirtualMachineInstances (VMIs).
Node Components (Right Side)
Each Kubernetes node contains multiple Pods, which include both containerized applications and virtual machines (VMs).
kubelet:
The
kubelet
is the primary node agent in Kubernetes. It manages containers and now, with KubeVirt, it also manages the lifecycle of VMs. It interacts with the API server and the node's runtime (e.g., Docker, containerd) to execute the workloads (containers or VMs).Pod (DaemonSet): virt-handler:
The
virt-handler
is deployed as a DaemonSet across all nodes in the Kubernetes cluster. This KubeVirt component runs on every node and is responsible for managing the lifecycle of VMIs on that node, including starting and stopping VMs.It communicates with
virt-launcher
to manage the virtual machines and ensures that VMs adhere to their desired state.Pod (per VMI): virt-launcher:
A
virt-launcher
pod is created for each VirtualMachineInstance (VMI). This pod is responsible for launching and managing the lifecycle of a specific VM. Each VM runs inside its own pod.The
virt-launcher
useslibvirtd
andqemu
to manage and run the VMs.libvirtd:
libvirtd
is a daemon that provides APIs for managing VMs. It communicates with the virtualization software (QEMU in this case) to start, stop, and manage VMs on the node.qemu:
QEMU is the open-source hypervisor used to run VMs within KubeVirt. It provides hardware emulation and virtualizes the VM inside the Kubernetes pod.
Containerized Workloads:
Standard containerized applications (e.g., Pods running Docker containers) coexist alongside KubeVirt VM workloads. Kubernetes manages both types of workloads using the same infrastructure, making KubeVirt a hybrid solution.
Workflow Summary
A user issues a command using
kubectl
to create or manage a VM.The API server processes the request and forwards it to the
virt-controller
.The
virt-controller
ensures that the VM is scheduled and created by interacting with the nodes.On the node, the
virt-handler
communicates with thevirt-launcher
pod to start the VM usinglibvirtd
andqemu
.The VM is treated like a Kubernetes workload, and Kubernetes manages its lifecycle just like any containerized application.
Kubevirt in Action
Please follow the below resource to do some hand's on. They have really good step wise documentation. So, better to follow it .
Try out kubevirt on kubernetes
Conclusion
KubeVirt provides an excellent solution for organizations looking to modernize their infrastructure without abandoning their legacy virtualized workloads. It combines the best of Kubernetes and virtualization, offering a unified platform that can help streamline operations and improve efficiency.
Whether you’re managing VMs, containers, or both, KubeVirt is a robust, flexible solution that’s well worth considering in your hybrid cloud journey. Start exploring KubeVirt today, and take your infrastructure management to the next level!
Get Involved
If you found this guide helpful, feel free to share it and spread the word about KubeVirt!