KubeVirt VM Backup and Restore using Replicated PV Mayastor VolumeSnapshots and Velero - FileSystem
#
OverviewKubeVirt 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.
#
EnvironmentComponent | Version |
---|---|
KubeVirt | v1.5.0 |
Kubernetes (3 nodes) | v1.29.6 |
OpenEBS | v4.2.0 |
NFS CSI Driver | v4.11.0 |
Containerized Data Importer (CDI) | v1.62.0 |
kubectl-mayastor Plugin | v2.7.4+0 |
virtctl | v1.5.0 |
#
Prerequisites#
Setup OpenEBSInstall OpenEBS
Ensure that OpenEBS is installed in your cluster. Refer to the OpenEBS Installation Documentation for step-by-step instructions.
Install the
kubectl-mayastor
PluginEnsure that
kubectl-mayastor
plugin is installed. Refer to the Mayastor Kubectl Plugin Documentation to install the plugin.Create a StorageClass
- Create a file named
StorageClass.yaml
.
StorageClass.yaml
- Apply the configuration.
#
Create a VolumeSnapshotClass- Create a file named
VolumeSnapshotClass.yaml
.
- Apply the configuration.
#
KubeVirt Setup- Install KubeVirt Operator.
Sample Output
- Create KubeVirt Custom Resource.
Sample Output
- Patch to Use Emulation (Optional).
- Verify KubeVirt Installation.
Sample Output
#
CDI Setup- Install CDI Operator and Custom Resource.
Sample Output - CDI
Sample Output - CR
- 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- Create DataVolume
- Create a file named
dv.yaml
.
dv.yaml
- Apply the Configuration.
- Monitor the Import.
- Create a Virtual Machine
- Create a file named
vm1_pvc.yaml
to use the PVC prepared by DataVolume as a root disk.
vm1_pvc.yaml
- Apply the configuration.
- Connect to the VM Console.
- Login credentials:
Username:
root
Password:MySecurePassword123
- Install Guest Agent.
Check Agent Status
- Insert Sample Data: Connect to the VM and create sample files in the root user home directory for backup verification.
#
Velero Setup- Configuring an AWS S3 Bucket for Velero Backup-Location
Configure AWS CLI (Optionally you can use the AWS GUI). Refer to the AWS CLI Setup Guide for setting up AWS CLI.
Create an AWS S3 Bucket.
- Create Velero User.
- Create an IAM policy with appropriate permissions.
- Assign the IAM policy to velero user.
- Generate Access Keys.
Sample Output
- Install Velero Utility
Install the Velero utility with Homebrew.
- Install Velero
- Create
credentials-velero
file with the access key and secret access key.
- Install Velero.
- Verify the Installation.
Command
Sample Output
- Check Velero backup storage location details.
Command
Sample Output
- Add KubeVirt-Velero Plugin
The KubeVirt-Velero plugin automates reliable backups of KubeVirt and CDI objects.
- Add the plugin.
- Verify the plugin installation.