Why KubeVirt Is the Future of Kubernetes‑Based Virtual Machine Management
This article explores how KubeVirt extends Kubernetes to manage virtual machines, compares it with OpenStack, details technical selection, core components, CRDs, storage and networking options, and shares practical SDK usage and migration experiences for cloud‑native virtualization.
Background
KubeVirt is a Kubernetes plugin that can schedule traditional virtual machines (VMs) alongside containers by using Custom Resource Definitions (CRDs) and other Kubernetes features, providing a virtualization API that integrates seamlessly with existing clusters.
OpenStack to Kubernetes Transition
In the author's company, two scheduling platforms existed: OpenStack for bare metal and VMs, and Kubernetes for containers, leading to duplicated effort and resource waste. As workloads move to the cloud, containers become the primary deployment model, but VMs will still be needed, prompting a shift toward a unified Kubernetes‑based scheduler.
Technical Selection
After researching projects like kubevirt, virtlet, and rancher/vm, kubevirt was chosen for its active community and design quality. It offers a Kubernetes‑native way to manage VMs, reducing the complexity of maintaining separate OpenStack and Kubernetes stacks.
KubeVirt Overview
KubeVirt, an open‑source project from Red Hat, runs VMs as first‑class citizens in Kubernetes, leveraging the platform’s extensibility to manage VM lifecycle, networking, and storage.
KubeVirt CRDs
KubeVirt defines several CRDs that extend the Kubernetes API, allowing users to create and manage virtual machines through standard Kubernetes resources.
KubeVirt Components
The main components are virt‑api , virt‑controller , virt‑handler , and virt‑launcher . They handle API serving, VM orchestration, node‑level VM management, and VM pod launching respectively.
Common Operations
<span>type DomainManager interface {</span>
<span>// SyncVMI creates a virtual machine</span>
<span>SyncVMI(*v1.VirtualMachineInstance, bool, *cmdv1.VirtualMachineOptions) (*api.DomainSpec, error)</span>
<span>// Pause VMI</span>
<span>PauseVMI(*v1.VirtualMachineInstance) error</span>
<span>// Unpause VMI</span>
<span>UnpauseVMI(*v1.VirtualMachineInstance) error</span>
<span>// Delete VMI</span>
<span>DeleteVMI(*v1.VirtualMachineInstance) error</span>
<span>// Migrate VMI</span>
<span>MigrateVMI(*v1.VirtualMachineInstance, *cmdclient.MigrationOptions) error</span>
<span>// Get Guest Info (requires QEMU guest agent)</span>
<span>GetGuestInfo() (v1.VirtualMachineInstanceGuestAgentInfo, error)</span>
<span>}</span>Virtual Machine Instance (VMI) Management
VMIs are listed and managed like pods. Example commands show how to retrieve VMI status, IP, and associated pods.
kubectl get vmi -o wide kubectl -n kubevirt get podStorage Options
cloudInitNoCloud / cloudInitConfigDrive : Uses a ConfigMap to provide cloud‑init data, adding a small secondary disk.
DataVolume : Automatically imports VM images into a PVC from HTTP or another PVC.
PersistentVolumeClaim : Directly attaches block or filesystem PVCs for persistent storage.
ephemeral / containerDisk : Non‑persistent disks, typically backed by Ceph CSI.
Network Implementation
KubeVirt leverages Kubernetes networking; VMI traffic passes through a virt‑launcher pod that bridges the VM’s virtual NIC to the physical network. The deployment uses Kube‑OVN (based on OVS/OVN) to provide advanced L2/L3 features and VLAN underlay for fixed‑IP scenarios.
KubeVirt SDK
KubeVirt provides Python and Go SDKs. The Python SDK is used to create, delete, list, start, stop, and rename VMs. The article shows how to configure the API client, handle optimistic concurrency with resourceVersion, and extend the SDK to support missing parameters such as VM rename.
import kubevirt
def get_api_client(host):
return kubevirt.ApiClient(host=host, header_name="Content-Type", header_value="application/json")
api_client = get_api_client(host="http://127.0.0.1:8001")
api_instance = kubevirt.DefaultApi(api_client)Conclusion
KubeVirt offers a cloud‑native virtualization layer that integrates VM management into Kubernetes, making it a viable alternative to OpenStack for private‑cloud environments, though it may still lag behind public‑cloud IaaS offerings.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
