Using Velero
Use Veleroβ
You can use Velero to back up virtual clusters.
Ensure your cluster supports volume snapshots to allow Velero to backup persistent volumes and persistent volume claims that save the virtual cluster state. Alternatively, you can use Velero's restic integration to back up the virtual cluster state.
Back up a vClusterβ
Install the Velero CLI, Velero server components and run the following command:
velero backup create <backup-name> --include-namespaces=my-vcluster-namespace
Verify a backup was successfully created with the following command:
velero backup describe <backup-name>
This should create an output similar to the following:
Name: <backup-name>
Namespace: velero
Labels: velero.io/storage-location=default
Annotations: velero.io/source-cluster-k8s-gitversion=v1.24.0
velero.io/source-cluster-k8s-major-version=1
velero.io/source-cluster-k8s-minor-version=24
Phase: Completed
Errors: 0
Warnings: 0
Namespaces:
Included: test
Excluded: <none>
Resources:
Included: *
Excluded: <none>
Cluster-scoped: auto
...
Restore a vClusterβ
After creating a backup with the Velero CLI or a scheduled backup, you can restore a vCluster using the Velero CLI:
velero restore create <restore-name> --from-backup <backup-name>
Verify the restore process using the following command:
velero restore logs <restore-name>
This restores the vCluster workloads, configuration, and state in the virtual cluster namespace.
Moving a vCluster from one namespace to another can be challenging because some objects, such as cluster role bindings and persistent volumes, contain namespace references. Velero supports namespace mapping, which works in most cases, but use cautionβthis may not be compatible with all vCluster setups.
Use Velero inside vClusterβ
You can use Velero inside vCluster to protect your workloads and data. To use Velero for backups:
-
Enable the hostpath-mapper component in vCluster.
-
After enabling
hostpath-mapper
, install the Velero CLI (as described above), connect to your vCluster, and install Velero inside the virtual cluster:Velero inside the virtual clustervelero install --provider <provider> --bucket <bucket_name> --secret-file <your_secret_file> --plugins velero/velero-plugin-for-<provider>:<semver> --use-restic
noteReplace
provider
,bucket_name
,secret-file
, and other placeholders with the correct values for your environment. -
After installation is complete, check the status of the Velero resources:
Verify the status of the Velero resources$ kubectl get all -n velero
NAME READY STATUS RESTARTS AGE
pod/restic-5szkb 1/1 Running 0 118s
pod/velero-75c5479dfd-4x7sl 1/1 Running 0 118s
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
daemonset.apps/restic 1 1 1 1 1 <none> 118s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/velero 1/1 1 1 119s
NAME DESIRED CURRENT READY AGE
replicaset.apps/velero-75c5479dfd 1 1 1 119s -
Create a backup using
restic
:Create a backup with resticvelero backup create test1 --default-volumes-to-restic
-
Wait for the backup to complete. Once complete, you should see the following output:
Sample Velero backup output$ velero backup describe test1
Name: test1
Namespace: velero
Labels: velero.io/storage-location=default
Annotations: velero.io/source-cluster-k8s-gitversion=v1.25.0+k3s1
velero.io/source-cluster-k8s-major-version=1
velero.io/source-cluster-k8s-minor-version=25
Phase: Completed
Errors: 0
Warnings: 0
Namespaces:
Included: *
Excluded: <none>
Resources:
Included: *
Excluded: <none>
Cluster-scoped: auto
...