Backup workload with Velero

Velero is an open source tool to safely back up, recover, and migrate Kubernetes clusters and persistent volumes. Velero consists of a server process running as a deployment in your Kubernetes cluster and a command-line interface (CLI) with which DevOps teams and platform operators configure scheduled backups, trigger ad-hoc backups, perform restores, and more.


Unlike other tools which directly access the Kubernetes etcd database to perform backups and restores, Velero uses the Kubernetes API to capture the state of cluster resources and to restore them when necessary. This API-driven approach has a number of key benefits:

  • Backups can capture subsets of the cluster’s resources, filtering by namespace, resource type, and/or label selector, providing a high degree of flexibility around what’s backed up and restored.
  • Resources exposed through aggregated API servers can easily be backed up and restored even if they’re stored in a separate etcd database.


More information about velero : https://velero.io/

Prérequis

  • An S3 bucket accessible by the cluster as velero store the backups and snapshots in this storage


Please find the list of compatible storage here https://velero.io/docs/v1.6/supported-providers/

For test purpose, you can deploy a minio server to act as a storage object.

Installation

Command line tool

Velero is managed through a command line tool installed on your admin workstation. The tool use the current kubectl config to connect to the kubernetes cluster to make backup, create schedule and restore

ABefore to start the velero binary must be downloaded from the VMware Website, a free account is required and must be created before.

Download Link.

Then you can extract the file downloaded :

Exemple :

Check the installation

Install velero in the cluster

Create a secret file containing the access & secret key to access your S3 bucket

Start the installation

Example for a minio setup :

Backup

For more details, you can rely on the official documentation : https://velero.io/docs

List backups

On-demand backup

Backup all objects

Backup all objects from a specific namespace

Backup a specific app using labels

Describe and debug a backup

Get the logs for a backup

Schedule a backup

Cron schedules use the following format.

# ┌───────────── minute (0 - 59) 
# │ ┌───────────── heure (0 - 23)
# │ │ ┌───────────── jour du mois (1 - 31)
# │ │ │ ┌───────────── mois (1 - 12)
# │ │ │ │ ┌───────────── jour de la semaine (0 - 6) (Dimanche au Samedi;
# │ │ │ │ │ 7 est également dimanche sur certains systèmes)
# │ │ │ │ │
# │ │ │ │ │
# * * * * *




For example, the command below creates a backup that runs every day at 3am.

Restore

To restore the entire backup on same namespace

To restore the entire backup on another namespace

Backup & Restore Management cluster

You can backup and restore management cluster with velero, the cluster api CustomResourceDefination will be backup and restored.

In order to not make duplicate resources you can ignore these namespaces : capi-kubeadm-bootstrap-system, capi-kubeadm-control-plane-system, capi-system, capvcd-system

Before starting the backup it is recommended to put in pause mode all your workload clusters on the management cluster to avoid modification of the objects during the backup.

/!\ There is no impact on your workloads, just on the management of this workload clusters.