Data protection for VMs in OpenShift Virtualization using Trident Protect
Author: Banu Sundhar, NetApp
This section of the reference document provides details for creating snapshots and backups of VMs using Trident protect.
Virtual machines in the OpenShift Virtualization environment are containerized applications that run in the worker nodes of your OpenShift Container platform. It is important to protect the VM metadata as well as the persistent disks of the VMs, so that when they are lost or corrupted, you can recover them.
The persistent disks of the OpenShift Virtualization VMs can be backed by ONTAP storage integrated to the OpenShift Cluster using Trident CSI. In this section we use Trident protect to create snapshots and backups of VMs including its data volumes to ONTAP Object Storage.
We then restore from a snapshot or a backup when needed.
Trident protect enables snapshots, backups, restore, and disaster recovery of applications and VMs on an OpenShift cluster. For OpenShift Virtualization VMs, data that can be protected with Trident protect include Kubernetes resource objects associated with the VMs, persistent volumes, and internal images.
The following are the versions of the various components used for the examples in this section
Create AppVault
Prior to creating the snapshots and backups for an application or a VM, an Object Storage must be configured in Trident protect to store the snapshots and backups. This is done using the bucket CR. Only administrators can create a bucket CR and configure it.
The bucket CR is known as AppVault in Trident protect. AppVault objects are the declarative Kubernetes workflow representation of a storage bucket. An AppVault CR contains the configurations necessary for a bucket to be used in protection operations, such as backups, snapshots, restore operations, and SnapMirror replication.
In this example, we will show the use of ONTAP S3 as Object storage.
Here is the workflow for creating AppVault CR for ONTAP S3:
1. Create S3 object store server in the SVM in ONTAP Cluster.
2. Create a bucket in the Object Store Server.
3. Create an S3 user in the SVM. Keep the access Key and the Secret Key in a safe location.
4. In OpenShift, create a secret to store the ONTAP S3 credentials.
5. Create an AppVault Object for ONTAP S3
Configure Trident protect AppVault for ONTAP S3
Create a VM in OpenShift Virtualization
The following screen shots show the creation of the VM (demo-fedora in namespace demo) from the console using the template. The root disk chooses the default storage class automatically, so, verify that the default storage class is set appropriately. In this setup, the default storage class is sc-zonea-san. Ensure that when you create the additional disk, you choose the storage class sc-zonea-san and check the “Apply optimized storage settings” checkbox. This will set the Access modes to RWX and Volume Mode to Block.
|
Trident supports RWX access mode in Block Volume mode for SAN (iSCSI, NVMe/TCP and FC). (It is the default access mode for NAS). RWX Access mode is required if you need to do Live migration of the VMs at a later point. |
Create App
Create a trident protect app for the VM
In the example, the demo namespace has one VM and all resources of the namespace is included when creating the app.
Create Backups
Create an On-demand Backup
Create a backup for the app (demo-vm) created previously that includes all resources in the demo namespace. Provide the appvault name where the backups will be stored.
Create Backups on a Schedule
Create a schedule for the backups specifying the granularity and the number of backups to retain.
Restore from Backups
Restore the VM to the same namespace
In the example the backup demo-vm-backup-on-demand contains the backup with the demo-app for the fedora VM.
First, delete the VM and ensure that the PVCs, pod and the VM objects are deleted from the namespace “demo”
Now, create a backup-in-place restore object.
Verify that the VM, pods and PVCs are restored
Restore the VM to a different namespace
First create a new namespace to which you want to restore the app to, in this example demo2. Then create a backup restore object
Verify that the VM, pods and pvcs are created in the new namespace demo2.
Create Snapshots
Create an on-demand snapshot
Create a snapshot for the app and specify the appvault where it needs to be stored.
Create a schedule for snapshots
Create schedule for the snapshots. Specify the granularity and the number of snapshots to be retained.
Restore from Snapshot
Restore the VM from the snapshot to the same namespace
Delete the VM demo-fedora from the demo2 namespace.
Create a snapshot-in-place-restore object from the snapshot of the VM.
Verify that the VM and its PVCs are created in the demo namespace.
Restore the VM from the snapshot to a different namespace
Delete the VM in the demo2 namespace previously restored from the backup.
Create the snapshot restore object from the snapshot and provide the namespace mapping.
Verify that the VM and its PVCs are restored in the new namespace demo2.
Selecting specific VMs in a namespace to create snapshots/backups and restore
In the previous example, we had a single VM within a namespace. By including the entire namespace in the backup, all resources associated with that VM were captured. In the following example, we add another VM to the same namespace and create an app just for this new VM by using a label selector.
Create a new VM (demo-centos vm) in the demo namespace
Label the demo-centos vm and its associated resources
Verify that the demo-centos vm and pvcs got the labels
Create an app for only a specific VM (demo-centos) using the label selector
The method of creating backups and snapshots on-demand and on a schedule is the same as shown previously.
Since the trident-protect app that is being used to create the snapshots or backups only contains the specific VM from the namespace, restoring from them only restores a specific VM.
A sample backup/restore operation is shown as an example below.
Create a backup of a specific VM in a namespace by using its corresponding app
In the previous steps, an app was created using label selectors to include only the centos vm in the demo namespace. Create a backup (on-demand backup, in this example) for this app.
Restore a specific VM to the same namespace
The backup of a specific VM (centos) was created using the corresponding app.
If a backup-in-place-restore or a backup-restore is created from this, only this specific VM is restored.
Delete the Centos VM.
Create a backup in-place restore from demo-centos-backup-on-demand and verify that the centos VM has been recreated.
Restore a specific VM to a different namespace
Create a backup restore to a different namespace (demo3) from demo-centos-backup-on-demand and verify that the centos VM has been recreated.