Skip to content

Commit 59b7b40

Browse files
authored
Merge pull request #84179 from lahinson/osdocs-12142-backup-restore-hcp-kubevirt
[OSDOCS-12142]: Adding backup/restore docs for HCP on OpenShift Virt
2 parents 4bc87ed + ed92fd1 commit 59b7b40

File tree

4 files changed

+194
-0
lines changed

4 files changed

+194
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,8 @@ Topics:
25072507
File: hcp-backup-restore-on-premise
25082508
- Name: Backing up and restoring etcd on AWS
25092509
File: hcp-backup-restore-aws
2510+
- Name: Backing up and restoring a hosted cluster on OpenShift Virtualization
2511+
File: hcp-backup-restore-virt
25102512
- Name: Disaster recovery for a hosted cluster in AWS
25112513
File: hcp-disaster-recovery-aws
25122514
- Name: Disaster recovery for a hosted cluster by using OADP
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
[id="hcp-backup-restore-virt"]
3+
= Backing up and restoring a hosted cluster on {VirtProductName}
4+
include::_attributes/common-attributes.adoc[]
5+
:context: hcp-backup-restore-virt
6+
7+
toc::[]
8+
9+
You can back up and restore a hosted cluster on {VirtProductName} to fix failures.
10+
11+
include::modules/backup-hosted-cluster-virt.adoc[leveloffset=+1]
12+
13+
include::modules/restore-hosted-cluster-virt.adoc[leveloffset=+1]
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// Module included in the following assembly:
2+
//
3+
// * hosted_control_planes/hcp_high_availability/hcp-backup-restore-virt.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="backup-hosted-cluster-virt_{context}"]
7+
= Backing up a hosted cluster on {VirtProductName}
8+
9+
When you back up a hosted cluster on {VirtProductName}, the hosted cluster can remain running. The backup contains the hosted control plane components and the etcd for the hosted cluster.
10+
11+
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.
12+
13+
.Procedure
14+
15+
. Create a Velero backup resource by creating a YAML file that is similar to the following example:
16+
+
17+
[source,yaml]
18+
----
19+
apiVersion: velero.io/v1
20+
kind: Backup
21+
metadata:
22+
name: hc-clusters-hosted-backup
23+
namespace: openshift-adp
24+
labels:
25+
velero.io/storage-location: default
26+
spec:
27+
includedNamespaces: <1>
28+
- clusters
29+
- clusters-hosted
30+
includedResources:
31+
- sa
32+
- role
33+
- rolebinding
34+
- deployment
35+
- statefulset
36+
- pv
37+
- pvc
38+
- bmh
39+
- configmap
40+
- infraenv
41+
- priorityclasses
42+
- pdb
43+
- hostedcluster
44+
- nodepool
45+
- secrets
46+
- hostedcontrolplane
47+
- cluster
48+
- datavolume
49+
- service
50+
- route
51+
excludedResources: [ ]
52+
labelSelector: <2>
53+
matchExpressions:
54+
- key: 'hypershift.openshift.io/is-kubevirt-rhcos'
55+
operator: 'DoesNotExist'
56+
storageLocation: default
57+
preserveNodePorts: true
58+
ttl: 4h0m0s
59+
snapshotMoveData: true <3>
60+
datamover: "velero" <4>
61+
defaultVolumesToFsBackup: false <5>
62+
----
63+
+
64+
<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>`.
65+
<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.
66+
<3> This field and the `datamover` field enable automatically uploading the CSI `VolumeSnapshots` to remote cloud storage.
67+
<4> This field and the `snapshotMoveData` field enable automatically uploading the CSI `VolumeSnapshots` to remote cloud storage.
68+
<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.
69+
70+
. Apply the changes to the YAML file by entering the following command:
71+
+
72+
[source,terminal]
73+
----
74+
$ oc apply -f <backup_file_name>.yaml
75+
----
76+
+
77+
Replace `<backup_file_name>` with the name of your file.
78+
79+
. Monitor the backup process in the backup object status and in the Velero logs.
80+
+
81+
** To monitor the backup object status, enter the following command:
82+
+
83+
[source,terminal]
84+
----
85+
$ watch "oc get backup -n openshift-adp <backup_file_name> -o jsonpath='{.status}' | jq"
86+
----
87+
+
88+
** To monitor the Velero logs, enter the following command:
89+
+
90+
[source,terminal]
91+
----
92+
$ oc logs -n openshift-adp -ldeploy=velero -f
93+
----
94+
95+
.Verification
96+
97+
* When the `status.phase` field is `Completed`, the backup process is considered complete.
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Module included in the following assembly:
2+
//
3+
// * hosted_control_planes/hcp_high_availability/hcp-backup-restore-virt.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="restore-hosted-cluster-virt_{context}"]
7+
= Restoring a hosted cluster on {VirtProductName}
8+
9+
After you back up a hosted cluster on {VirtProductName}, you can restore the backup.
10+
11+
[NOTE]
12+
====
13+
The restore process can be completed only on the same management cluster where you created the backup.
14+
====
15+
16+
.Procedure
17+
18+
. Ensure that no pods or persistent volume claims (PVCs) are running in the `HostedControlPlane` namespace.
19+
20+
. Delete the following objects from the management cluster:
21+
22+
** `HostedCluster`
23+
** `NodePool`
24+
** PVCs
25+
26+
. Create a restoration manifest YAML file that is similar to the following example:
27+
+
28+
[source,yaml]
29+
----
30+
apiVersion: velero.io/v1
31+
kind: Restore
32+
metadata:
33+
name: hc-clusters-hosted-restore
34+
namespace: openshift-adp
35+
spec:
36+
backupName: hc-clusters-hosted-backup
37+
restorePVs: true <1>
38+
existingResourcePolicy: update <2>
39+
excludedResources:
40+
- nodes
41+
- events
42+
- events.events.k8s.io
43+
- backups.velero.io
44+
- restores.velero.io
45+
- resticrepositories.velero.io
46+
----
47+
+
48+
<1> This field starts the recovery of pods with the included persistent volumes.
49+
<2> Setting `existingResourcePolicy` to `update` ensures that any existing objects are overwritten with backup content. This action can cause issues with objects that contain immutable fields, which is why you deleted the `HostedCluster`, node pools, and PVCs. If you do not set this policy, the Velero engine skips the restoration of objects that already exist.
50+
51+
. Apply the changes to the YAML file by entering the following command:
52+
+
53+
[source,terminal]
54+
----
55+
$ oc apply -f <restore_resource_file_name>.yaml
56+
----
57+
+
58+
Replace `<restore_resource_file_name>` with the name of your file.
59+
60+
. Monitor the restore process by checking the restore status field and the Velero logs.
61+
+
62+
** To check the restore status field, enter the following command:
63+
+
64+
[source,terminal]
65+
----
66+
$ watch "oc get restore -n openshift-adp <backup_file_name> -o jsonpath='{.status}' | jq"
67+
----
68+
+
69+
** To check the Velero logs, enter the following command:
70+
+
71+
[source,terminal]
72+
----
73+
$ oc logs -n openshift-adp -ldeploy=velero -f
74+
----
75+
76+
.Verification
77+
78+
* When the `status.phase` field is `Completed`, the restore process is considered complete.
79+
80+
.Next steps
81+
82+
* After some time, the KubeVirt VMs are created and join the hosted cluster as compute nodes. Make sure that the hosted cluster workloads are running again as expected.

0 commit comments

Comments
 (0)