On macOS, you can use Homebrew to install the velero
client:
brew install velero
Velero is an open-source utility designed to facilitate the backup, restoration, and migration of Kubernetes cluster resources and persistent volumes on Amazon S3-compatible Object Storage. Originally developed by Heptio, it became part of VMware following an acquisition. Velero offers a straightforward and effective approach to protecting your Kubernetes applications and data through regular backups and supporting disaster recovery measures.
With Velero, users can generate either scheduled or on-demand backups encompassing the entire cluster or specific namespaces. These backups comprehensively capture the state of all resources within the cluster, including deployments, services, config maps, secrets, and persistent volumes. Velero ensures the preservation of associated metadata and labels, guaranteeing the completeness and accuracy of the backups for potential restoration.
Beyond backups, Velero allows users to restore applications and data either within the same Kubernetes cluster or to different clusters. This capability proves valuable in diverse scenarios, such as recovering from accidental deletions, migrating applications between clusters, or implementing robust disaster recovery plans.
Velero seamlessly integrates with Kubernetes through custom resource definitions (CRDs) and operates as a deployment within the cluster. Leveraging plugins, Velero addresses various aspects of backup and restore operations, allowing for flexibility, extensibility, and customization.
To complete the actions presented below, you must have:
Velero will be installed on your local PC or Mac.
Download the latest Velero release for your platform from Veleros GitHub repository.
Extract the tarball:
tar -xvf <RELEASE-TARBALL-NAME>.tar.gz
Move the extracted velero
binary to the desired location in your $PATH
(/usr/local/bin
for most users).
On macOS, you can use Homebrew to install the velero
client:
brew install velero
Create a credentials file for Velero, named velero-credentials
:
nano velero-credentials
Copy the following content in the file and set your access key and secret key. Then save the file and exit the text editor.
[default]aws_access_key_id=SCALEWAY_ACCESS_KEYaws_secret_access_key=SCALEWAY_SECRET_KEY
Initialize Verlero. Make sure to replace VELERO-BUCKET-NAME
with the name of the Object Storage bucket you want to use. Edit the backup location if your bucket is in a zone other than fr-par
.
velero install \--provider velero.io/aws \--bucket k8s-velero-backup \--plugins velero/velero-plugin-for-aws:v1.7.0 \--backup-location-config s3Url=https://s3.fr-par.scw.cloud,region=fr-par \--use-volume-snapshots=false \--secret-file=./velero-credentials
Verlero is being installed on your Kubernetes cluster. The following message displays, once the installation is complete:
Velero is installed! ⛵ Use 'kubectl logs deployment/velero -n velero' to view the status.
velero backup create full-backup --include-namespaces '*'
velero get backup
command:
$ velero get backupNAME STATUS ERRORS WARNINGS CREATED EXPIRES STORAGE LOCATION SELECTORfull-backup Completed 0 0 2023-06-02 15:33:45 +0200 CEST 29d default <none>
backup
folder created by Velero:
You can also automate your backups using scheduled jobs, with execution times defined by cron expressions.
velero schedule create NAME --schedule="* * * * *" [flags]
Refer to the official Velero documentation for more information.
Create a restore job from the full backup made in the previous step:
velero restore create full-restore --from-backup full-backup
Check the status of your restore:
velero restore describe full-restore
When the Phase
status changes to Completed
, your backup has been restored successfully:
Phase: Completed
For more information about restoring your data using Velero, refer to the Velero restore reference documentation.