Using InstancetypeReferencePolicy to expand VirtualMachines
Environment
- Red Hat OpenShift Virtualization v4.19.0
Issue
- VirtualMachines using instance types and preferences may not be supported by third party backup vendors
- VirtualMachines using instance types and preferences may not be recovered correctly by Red Hat Advaned Cluster Manager / OpenShift Data Foundation Disaster Recovery
Resolution
With Red Hat OpenShift Virtualization v4.19.0 a number of workarounds are available to users, who want to restore VirtualMachines without the required instance type and preference ControllerRevisions.
InstancetypeReferencePolicy
One workaround is to force the expansion of all VirtualMachines within a cluster to remove the need for these objects to be backed up or restored.
The InstancetypeReferencePolicy cluster configurable allows cluster admins to enforce the expansion of VirtualMachines within their environment, removing any references to an instance type or preference.
The current options to the configurable are:
- reference (default) - This is the default behaviour and will capture copies of an instance type or preference in a ControllerRevision, that is then referenced by the VirtualMachine.
- expand - This option will force all new VirtualMachines to have any instance type or preference references expanded.
- expandAll - This option will force all VirtualMachines to have any instance type or preference references expanded.
Use the following command to enable the expand option and the associated feature gate on the cluster:
$ oc patch -n openshift-cnv hco kubevirt-hyperconverged --type=merge \
-p '{"spec":{"instancetypeConfig": {"referencePolicy": "expand"}}}'
Verify that VirtualMachines are expanded on creation. They should contain no references to an instance type or preference within their spec:
$ virtctl create vm \
--name fedora \
--instancetype u1.medium \
--preference fedora \
--volume-containerdisk src:quay.io/containerdisks/fedora:latest | kubectl apply -f -
$ kubectl get vm fedora -o json | jq .
Root Cause
VirtualMachines referencing an instance type or preference retain a reference to a ControllerRevision containing a point in time copy of the original instance type or preference object. This is done to ensure that the resulting running VirtualMachineInstance of a VirtualMachine is always the same. As such these ControllerRevisions also need to be backed up or restored in the context of disaster recovery.
Some third party backup vendors have previously shipped implementations that do not back up or restore the referenced instance type, preference or ControllerRevision objects correctly.
This should no longer be the case as these requirements are now expressed through Content from github.com is not included.KubeVirt’s reference Velero plugin, Content from github.com is not included.backup reference documentation and Content from github.com is not included.PartnerComp functional tests used by Red Hat to verify third party back up and restore implementations.
Additionally RHACM / ODF disaster recovery does not automatically capture and restore these ControllerRevisions, however this is the same for all dependencies of a VirtualMachine.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.