Search…
2.10.X
Backup and Restore Virtual Machine running on OpenShift
A guide for performing the backup and restore of the Virtual Machine (VM) running on the OpenShift environment.
Red Hat OpenShift Container Platform (OCP) is the market-leading Kubernetes platform. OpenShift efficiently manages your Kubernetes-based applications deployed on it. With the help of the OpenShift Virtualization operator, users can also run their VMs into a pod and these pods are also managed by OpenShift similar to other pods running Kubernetes-based applications.

Install OpenShift Virtualization Operator

  1. 1.
    Log in to the OpenShift Management Console and go to OperatorHub.
  2. 2.
    Search the Operator “OpenShift Virtualization”
Search OpenShift Virtualization Operator
3. Click on the “Install” and proceed with the installation.
OpenShift Virtualization Operator
4. Select the appropriate options and proceed with the installation
Install OpenShift Virtualization Operator
5. Once the installation is complete, the user needs to create HyperConverged using the Local Storage Class Name. HyperConverged creates and maintains the OpenShift Virtualization Deployments.
6. Once the installation is complete, you can check a new option “Virtualization” visible under the Workload section.
Note: You can learn more about OpenShift Virtualization in this video.
Follow the below steps to install and configure the underlying storage required to run virtual machines.

Install and Configure the OpenShift Data Foundation Operator for underlying Storage for VM Deployment

Once the OpenShift Virtualization Operator is installed, it also needs underlying storage for the VM deployments. You will install OpenShift Data Foundation (ODF) (Formerly known as OpenShift Container Storage (OCS)) Operator which will configure the underlying storage for the VMs to use.
Follow the steps below to install and configure the ODF Operator:
  1. 1.
    Login to OpenShift Management Console and go to the OperatorHub
  2. 2.
    Search the Operator “OpenShift Data Foundation” operator
Search OpenShift Data Foundation Operator
3. Select the Operator and provide appropriate input values. Click on Install.
ODF Operator Description
4. After the installation is complete, you have to create a Storage System which would in-turn create a Storage Cluster. You have to provide an existing Storage class to provision the new storage for Storage Cluster creation to proceed.
Installed ODF Operator
Storage system created by ODF Operator
5. Once the Storage System creation is complete, in the background, it will install different storage components such as BackingStore, BucketClass, CephBlockPool, etc.
6. Once all the components are in the Ready state, you can check that the storage class is also created in the backend.
Storage classes created by the storage cluster
7. Now, you are ready to deploy a virtual machine on OpenShift.

Deploy a Virtual Machine on OpenShift

Since, you are have installed the OpenShift Virtualization Operator and you might already be aware of how to deploy a VM or you have already deployed a VM.
If not, it's very easy and similar to the Virtual Machine deployment on any other other virtualization technology. You can follow this video from the OpenShift team to deploy a VM.

Backup a Virtual Machine Using TVK

After setting up all the prerequisites to deploy TrilioVault for Kubernetes, you might have already launched TVK Management Console. Follow the UI authentication section to login into console using OpenShift credentials.
Now, we can proceed to perform a VM backup. Follow the below instructions steps to create a VM backup:
  1. 1.
    On the TVK Management console, select the namespace in the primary cluster from the top dropdown where the VM is created.
Select a Namespace with a running VM
2. Select the namespace and click on the “Action” or “Bulk Action” button on the right and select the option “Create Backup”
Option to create Namespace Backup
3. To select the resources to be backed up, we need to create a backupplan that can be used in the future to create backups.
Create a backupplan configuration
4. After selecting the backupplan, you can click on “Continue” to provide a backup name and click on “Create Backup” to start the namespace backup operation.
Enter the backup name
5. Once the backup is triggered, you can verify the metadata objects captured as a part of the backup from the `In Progress` backup
Verify the metadata objects captured in the backup
6. Now, you can monitor the backup status on the status log window.
Backup is in Completed state
7. With all steps marked as green in above screenshot, the backup status shows that it's completed successfully and we can proceed to understand how to restore the VM backup on the same OpenShift cluster.

Restore a Virtual Machine Using TVK

Remove existing VM from OpenShift Cluster

Follow the below steps to delete the VM from the OpenShift Cluster:
  1. 1.
    Go to the OpenShift Console, Click on Virtualization under the Workload tab. Click on the three dots on the right side of the VM entry and click on the last option “Delete Virtual Machine”.
Virtual Machine Options - Delete Virtual Machine
2. Once the VM entry is removed from the OCP console, check that both PVC created for the VM disks are also removed
No PVC present in the Namespace after VM is deleted
3. After you have deleted the VM and all its related resources, you are good to proceed with the namespace restore operation.

Perform a VM Restore from the Backup

In the below steps, you will learn how to restore the VM through namespace backup performed earlier in this article. Follow the below steps to perform the namespace restore from the backup present on the target.
  1. 1.
    Login to TVK Management Console and select “Backup & Recovery -> Backupplans”. Click on the “Namespace” dropdown at the top and select the namespace that we have taken a backup of.
Select the source namespace of the backup
2. Click on the “Actions” button to get the option to see the “View Backup & Restore Summary”
Select the View Backup & Restore Summary
3. On the next pop-up of the Monitoring summary of the backup and restores for the namespace, click on the accordion to expand the backup details. Click on the “Restore” option at the bottom.
Backup Summary of the source namespace
4. On the restore pop-up window, provide the “Restore Name” and “Restore Namespace” where we want to restore the VM.
Enter restore name and restore namespace
5. Click on the “Next” button to move to “Transform Components” and “Exclude Resources”.
6. Click on the Exclude Resources, if there is a “DataVolume” resource object present in the backup, then add it to be excluded during the restore.
Exclude the resources if any
7. Now, click on the “Transform Components” -> “Add Transform Components” - > Select “Custom” from the dropdown to list down the resources present in the backup. Since we are creating the first transformation, click on `Create New`.
Click on Create New transformation
8. Now, we will perform the Transformation for PersistentVolumeClaim of the rootdisk and datadisk-0 PVC.
PersistentVolumeClaim Transformation
9. We will perform the below transformations on one rootdisk PVC at a time:
  • Remove the datadisk-0 PVC from the Objects list
  • Provide a transformation name
rootdisk PVC transformation
  • You need to understand the rootdisk PVC yaml to learn a bit about why specific transformations are added. Follow the below transformations for the rootdisk PVC.
  • If annotation cdi.kubevirt.io/storage.populatedFor exists in the PVC, then don’t need to add the annotation, but if the PVC does not have the annotation then the user needs to add the annotation as below: /metadata/annotations/cdi.kubevirt.io~1storage.populatedFor : "rhel8-korean-leopard-rootdisk-i27do"
  • If the annotation cdi.kubevirt.io/ownedByDataVolume exists in the PVC, then remove the annotation using remove operation and value /metadata/annotations/cdi.kubevirt.io~1ownedByDataVolume
  • Remove the path /spec/volumeName
  • Remove the ownerReferences /metadata/ownerReferences/0
  • Replace the dataSource name - /spec/dataSource/name with the VM name rhel8-korean-leopard
rootdisk PVC tranformations
  • Click on the “Preview Changes” to make sure that the annotations are correct, if not the dry run would fail and it will show an error message.
Preview the transformation changes in the PVC
  • If everything looks similar to the above screenshot, then close the windows and click on the “Apply” button.
  • Now, expand the “PersistentVolumeClaim” to see the added transformation, and click on the “Set Transformation” button to go to the datadisk-0 PVC transformation.
Set Transformation to add for datadisk-0 PVC
10. We will perform the below transformations on one datadisk-0 PVC at a time:
  • Remove the datadisk-0 PVC from the Objects list
  • Provide a transformation name
datadisk-0 PVC transformation
  • You need to understand the datadisk-0 PVC yaml to learn a bit about why specific transformations are added. Follow the below transformations for the datadisk-0 PVC
  • If annotation cdi.kubevirt.io/storage.populatedFor exists in the PVC, then don’t need to add the annotation, but if the PVC does not have the annotation then the user needs to add the annotation as below: /metadata/annotations/cdi.kubevirt.io~1storage.populatedFor : "rhel8-korean-leopard-datadisk-0-f92h1"
  • For datadisk-0 PVC the annotation cdi.kubevirt.io/ownedByDataVolume does not exist, so don’t need to perform any transformation.
  • Remove the path /spec/volumeName
  • Remove the ownerReferences - /metadata/ownerReferences/0
  • Since the /spec/dataSource path is not present in the datadisk-0 PVC spec, don’t need to perform any transformation for the dataSource name.
datadisk-0 PVC transformations
  • Click on the “Preview Changes” to make sure that the annotations are correct, if not the dry run would fail and it will show an error message.
Preview the transformation changes in the PVC
  • If everything looks good line the above screenshot, then close the windows and click on the “Apply” button
  • Now, expand the “PersistentVolumeClaim” to see the added transformation for datadisk-0 PVC. Click on the Add button to save the datadisk-0 PVC transformation to see the details of the PVC transformation components.
Consolidated transformations for both PVCs
11. Click on the Save button to start the Restore operation. It will take a few minutes to complete the restore depending on the size of PVCs being restored.
Restore operation is completed successfully
12. After some time, you can check that both the PVCs are created in the restore namespace.
Both PVCs are restored into the restore namespace
13. The VM is running as expected and both the disks are present with the VM.
14. After this, you can call that the Restore operation is successful and validate the data on the disks which you have created before taking the backup. After the data validation, you can say that the VM is successfully restored by using the restore transformation feature.
Copy link
Outline
Install OpenShift Virtualization Operator
Install and Configure the OpenShift Data Foundation Operator for underlying Storage for VM Deployment
Deploy a Virtual Machine on OpenShift
Backup a Virtual Machine Using TVK
Restore a Virtual Machine Using TVK
Remove existing VM from OpenShift Cluster
Perform a VM Restore from the Backup