KubeVirt VM Live Migration with Replicated PV Mayastor and NFS
Overview#
KubeVirt extends Kubernetes with virtual machine (VM) management capabilities, enabling a unified platform for both containerized and virtualized workloads. Live migration of VMs is a critical feature for achieving high availability, zero-downtime maintenance, and workload mobility. However, live migration in KubeVirt requires shared ReadWriteMany (RWX) storage that can be accessed across multiple nodes.
OpenEBS Replicated PV Mayastor is a high-performance, container-native block storage engine that provides persistent storage for Kubernetes. While Replicated PV Mayastor does not natively support RWX volumes, it can be integrated with an NFS server pod and the NFS CSI driver to provide shared access to storage volumes. This document guides you through the setup and validation of a KubeVirt live migration environment using OpenEBS Replicated PV Mayastor and NFS.
Environment#
| Component | Version | 
|---|---|
| KubeVirt | v1.5.0 | 
| Kubernetes (3 nodes) | v1.29.6 | 
| OpenEBS | v4.2.0 | 
| Velero | v1.15.2 | 
| Containerized Data Importer (CDI) | v1.62.0 | 
| kubectl-mayastor Plugin | v2.7.4+0 | 
| virtctl | v1.5.0 | 
Prerequisites#
Setup OpenEBS#
Install OpenEBS
Ensure that OpenEBS is installed in your cluster. Refer to the OpenEBS Installation Documentation for step-by-step instructions.
Install the
kubectl-mayastorPluginEnsure that
kubectl-mayastorplugin is installed. Refer to the Mayastor Kubectl Plugin Documentation to install the plugin.Create StorageClass for NFS Pod (3 Replicas)
- Create a file named 
StorageClass.yaml. 
StorageClass.yaml
- Apply the configuration.
 
- Create StorageClass for Scratch Space (1 Replica)
 
- Create a file named 
StorageClass2.yaml. 
StorageClass2.yaml
- Apply the configuration.
 
- Setup VolumeSnapshotClass
 
- Create a file named 
VolumeSnapshotClass.yaml. 
VolumeSnapshotClass.yaml
- Apply the configuration.
 
Deploying an NFS Server Pod#
- Create a Namespace.
 
- Create PersistentVolumeClaim (PVC) for NFS Storage.
 
nfspvc.yaml
- Deploy NFS Server Pod.
 
nfs-server-deployment.yaml
- Apply the configuration.
 
- Create NFS Service.
 
nfs-server-service.yaml
- Apply the configuration.
 
Deploy NFS CSI Driver and StorageClass#
- Create Namespace.
 
- Create Helm Values for StorageClass.
 
values.yaml
- Install Using Helm.
 
KubeVirt Setup#
- Install KubeVirt Operator.
 
Sample Output
- Create KubeVirt Custom Resource.
 
Sample Output
- Patch to Use Emulation (Optional).
 
note
To perform operations such as accessing the VM console or triggering live migration, you must install the virtctl CLI tool. Refer to the Official KubeVirt Documentation
- Verify KubeVirt Installation.
 
Sample Output
CDI Setup#
- Install CDI Operator and Custom Resource.
 
Sample Output
- Configure Scratch Space StorageClass.
 
Add the following under spec.config:
important
CDI always requests scratch space with a Filesystem volume mode regardless of the volume mode of the related DataVolume. It also always requests it with a ReadWriteOnce accessMode. Therefore, when using block mode DataVolumes, you must ensure that a storage class capable of provisioning Filesystem mode PVCs with ReadWriteOnce accessMode is configured.
- Verify CDI Installation.
 
Sample Output
Deploying a Virtual Machine with NFS Storage#
- Create DataVolume
 
- Create a file named 
dv.yaml. 
dv.yaml
- Apply the Configuration.
 
note
You will see two Scratch PVC being created as NFS Provisioner also creates a scratch PVC before provisioning the orignal KubeVirt Scratch PVC.
- Create a Virtual Machine
 
- Create a file named 
vm1_pvc.yamlto use the PVC prepared by DataVolume as a root disk. 
vm1_pvc.yaml
- Apply the configuration.
 
- Connect to the VM Console.
 
- Login credentials:
Username: 
rootPassword:MySecurePassword123 
- Install Guest Agent.
 
Check Agent Status
Enable Live Migration#
Validate Live Migration#
- Insert Sample Data into VM.
 
Use the VM console to create test files.
- Verify VM Node Location.
 
- Trigger Live Migration.
 
- Monitor Migration Progress.
 
Sample Output
- Verify Post-Migration State.
 
Ensure the VM is running on a new node and that all previously created data remains intact.