When you back up a hosted cluster on OpenShift Virtualization, the hosted cluster can remain running. The backup contains the hosted control plane components and the etcd for the hosted cluster.
When the hosted cluster is not running compute nodes on external infrastructure, hosted cluster workload data that is stored in persistent volume claims (PVCs) that are provisioned by KubeVirt CSI are also backed up. The backup does not contain any KubeVirt virtual machines (VMs) that are used as compute nodes. Those VMs are automatically re-created after the restore process is completed.
Procedure
-
Create a Velero backup resource by creating a YAML file that is similar to the following example:
apiVersion: velero.io/v1
kind: Backup
metadata:
name: hc-clusters-hosted-backup
namespace: openshift-adp
labels:
velero.io/storage-location: default
spec:
includedNamespaces: (1)
- clusters
- clusters-hosted
includedResources:
- sa
- role
- rolebinding
- deployment
- statefulset
- pv
- pvc
- bmh
- configmap
- infraenv
- priorityclasses
- pdb
- hostedcluster
- nodepool
- secrets
- hostedcontrolplane
- cluster
- datavolume
- service
- route
excludedResources: [ ]
labelSelector: (2)
matchExpressions:
- key: 'hypershift.openshift.io/is-kubevirt-rhcos'
operator: 'DoesNotExist'
storageLocation: default
preserveNodePorts: true
ttl: 4h0m0s
snapshotMoveData: true (3)
datamover: "velero" (4)
defaultVolumesToFsBackup: false (5)
1 |
This field selects the namespaces from the objects to back up. Include namespaces from both the hosted cluster and the hosted control plane. In this example, clusters is a namespace from the hosted cluster and clusters-hosted is a namespace from the hosted control plane. By default, the HostedControlPlane namespace is clusters-<hosted_cluster_name> . |
2 |
The boot image of the VMs that are used as the hosted cluster nodes are stored in large PVCs. To reduce backup time and storage size, you can filter those PVCs out of the backup by adding this label selector. |
3 |
This field and the datamover field enable automatically uploading the CSI VolumeSnapshots to remote cloud storage. |
4 |
This field and the snapshotMoveData field enable automatically uploading the CSI VolumeSnapshots to remote cloud storage. |
5 |
This field indicates whether pod volume file system backup is used for all volumes by default. Set this value to false to back up the PVCs that you want. |
-
Apply the changes to the YAML file by entering the following command:
$ oc apply -f <backup_file_name>.yaml
Replace <backup_file_name>
with the name of your file.
-
Monitor the backup process in the backup object status and in the Velero logs.
-
To monitor the backup object status, enter the following command:
$ watch "oc get backup -n openshift-adp <backup_file_name> -o jsonpath='{.status}' | jq"
-
To monitor the Velero logs, enter the following command:
$ oc logs -n openshift-adp -ldeploy=velero -f