Restoring From Backup#
Note
Please refer to the official migration documentation to familiarize yourself with potential limitations of the Velero backup system.
In the event of disaster, you can restore from a backup by doing the following:
-
Create a clean k0rdent installation, including
veleroand its plugins. Specifically, you want to avoid creating aManagementobject and similar objects because they will be part of your restored cluster. You can remove these objects after installation, but you can also install k0rdent without them in the first place:helm install kcm oci://ghcr.io/k0rdent/kcm/charts/kcm \ --version <version> \ --create-namespace \ --namespace kcm-system \ --set controller.createManagement=false \ --set controller.createAccessManagement=false \ --set controller.createRelease=false \ --set controller.createTemplates=false \ --set velero.initContainers[0].name=velero-plugin-for-<provider-name> \ --set velero.initContainers[0].image=velero/velero-plugin-for-<provider-name>:<provider-plugin-tag> \ --set velero.initContainers[0].volumeMounts[0].mountPath=/target \ --set velero.initContainers[0].volumeMounts[0].name=plugins -
Create the
BackupStorageLocation/Secretobjects that were created during the preparation stage of creating a backup (preferably the same depending on a plugin). -
Restore the
kcmsystem creating theRestoreobject. Note that it is important to set the.spec.existingResourcePolicyfield value toupdate:apiVersion: velero.io/v1 kind: Restore metadata: name: <restore-name> namespace: kcm-system spec: backupName: <backup-name> existingResourcePolicy: update includedNamespaces: - '*' -
Wait until the
Restorestatus isCompletedand allkcmcomponents are up and running.
If the Restore fails#
At the time of this writing, there is a mis-match between what k0rdent expects
and the objects velero provides, which may result in a PartiallyFailed result. A fix for this problem
is coming soon, but in the meantime, you will need to rename the kcm-velero Deployment to velero.
Follow these steps:
-
Export the YAML for the object, then delete it:
kubectl -n kcm-system get deployment kcm-velero -o yaml > velero-deployment.yaml kubectl delete -n kcm-system deployment kcm-velerodeployment.apps "kcm-velero" deleted -
Edit the
velero-deployment.yamlfile to changemetadata.namefromkcm-velerotovelero:... component: velero helm.sh/chart: velero-9.1.2 name: velero namespace: kcm-system resourceVersion: "1653" ... -
Recreate the
Deploymentwith the new name:kubectl apply -n kcm-system -f velero-deployment.yamldeployment.apps/velero created -
Delete the failed
Restore:kubectl delete restore -n <your-namespace> <restore-name> -
Recreate the
Restoreobject as before. It should now complete successfully.
Caveats#
For some CAPI providers it is necessary to make changes to the Restore
object due to the large number of different resources and logic in each provider.
The resources described below are not excluded from a ManagementBackup by
default to avoid logical dependencies on one or another provider, and to create a provider-agnostic system.
Note
The described caveats apply only to the Restore
object creation step and do not affect the other steps.
Azure (CAPZ)#
The following resources should be excluded from the Restore object:
natgateways.network.azure.comresourcegroups.resources.azure.comvirtualnetworks.network.azure.comvirtualnetworkssubnets.network.azure.com
Due to the webhook conversion,
objects of these resources cannot be restored, and they will
be created in the management cluster by the CAPZ provider
automatically with the same spec as in the backup.
The resulting Restore object:
apiVersion: velero.io/v1
kind: Restore
metadata:
name: <restore-name>
namespace: kcm-system
spec:
backupName: <backup-name>
existingResourcePolicy: update
excludedResources:
- natgateways.network.azure.com
- resourcegroups.resources.azure.com
- virtualnetworks.network.azure.com
- virtualnetworkssubnets.network.azure.com
includedNamespaces:
- '*'
vSphere (CAPV)#
The following resources should be excluded from the Restore object:
mutatingwebhookconfiguration.admissionregistration.k8s.iovalidatingwebhookconfiguration.admissionregistration.k8s.io
Due to the Velero Restoration Order,
some of the CAPV core objects cannot be restored,
and they will not be recreated automatically.
Because all of the objects have already passed both mutations
and validations, there is not much sense in validating them again.
The webhook configurations will be restored during installation
of the CAPV provider.
The resulting Restore object:
apiVersion: velero.io/v1
kind: Restore
metadata:
name: <restore-name>
namespace: kcm-system
spec:
backupName: <backup-name>
existingResourcePolicy: update
excludedResources:
- mutatingwebhookconfiguration.admissionregistration.k8s.io
- validatingwebhookconfiguration.admissionregistration.k8s.io
includedNamespaces:
- '*'