Docker & DevOps

KubeVirt explained: run virtual machines on Kubernetes

How KubeVirt lets Kubernetes manage KVM virtual machines alongside containers, its main resources (VirtualMachine, DataVolume), requirements, a basic example and when it makes sense.

AdvancedKubernetes clusters2 min read

Many organisations run containers on Kubernetes but still have workloads that need full VMs: legacy apps, Windows, or special kernels. KubeVirt adds virtual machines to Kubernetes, so the same cluster, tools and GitOps workflows manage both.

Before you start

  • A Kubernetes cluster you administer. For learning, see Kubernetes basics with k3s.
  • Worker nodes with hardware virtualization (bare metal or nested virtualization). KubeVirt can fall back to software emulation for testing only.
  • A storage class that supports the volumes your VMs need.

How KubeVirt works

  • KubeVirt installs an operator and custom resources into the cluster.
  • Each VM runs inside a pod (virt-launcher) that contains a QEMU/KVM process managed by libvirt.
  • Kubernetes networking, storage, scheduling and RBAC apply to VMs as they do to pods.

Key resources

ResourcePurpose
VirtualMachineDesired VM definition, start/stop state
VirtualMachineInstanceA running VM
DataVolume (CDI)Import disk images from URLs or registries into PVCs
VirtualMachineInstanceMigrationLive migrate a VM between nodes

A minimal VM manifest

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: demo-vm
spec:
  runStrategy: Always
  template:
    spec:
      domain:
        resources:
          requests:
            memory: 1Gi
        devices:
          disks:
            - name: rootdisk
              disk: { bus: virtio }
            - name: cloudinit
              disk: { bus: virtio }
      volumes:
        - name: rootdisk
          containerDisk:
            image: quay.io/containerdisks/fedora:latest
        - name: cloudinit
          cloudInitNoCloud:
            userData: |
              #cloud-config
              password: changeme
              chpasswd: { expire: false }

Apply with kubectl apply -f vm.yaml, then use virtctl console demo-vm to connect. The containerDisk is ephemeral; use DataVolumes/PVCs for persistent disks. Use SSH keys rather than passwords for anything beyond a demo; see cloud-init user-data.

When KubeVirt makes sense

  • You already run Kubernetes and want one platform for containers and the VMs that cannot be containerised yet.
  • Gradual modernisation: run a legacy VM next to the microservices replacing it.
  • Not a replacement for a simple hypervisor: for VM-only needs, Proxmox or plain KVM is far simpler.

Frequently asked questions

Can KubeVirt run Windows?

Yes, with VirtIO drivers and suitable storage; see VirtIO drivers.

Does it support live migration?

Yes, when the VM's storage is shared (ReadWriteMany) or migratable.

How is it different from Kata Containers?

Kata runs container images in lightweight VMs for isolation; KubeVirt runs traditional full VMs. See microVMs explained.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.