Sub topic 8
How Velero works
This chapter assumes you can use kubectl, know Pods, Deployments and PersistentVolumeClaims, and understand that etcd holds cluster state. It also assumes you know what an S3-compatible bucket is. Installation comes in the next chapter. Here you build the working model.
What Velero backs up
An etcd snapshot copies the whole state store of one cluster. Velero works at a different level. It asks the Kubernetes API for objects, writes them to object storage as an archive, and can recreate them later. Because it uses the API, you can pick a subset: one namespace, a label selector, or certain resource types. You can also restore into a different cluster.
Components
Velero has three parts that you will meet again in later chapters.
- The Velero server is a Deployment in the
veleronamespace. It runs controllers that watch Velero's custom resources and do the backup and restore work. - Plugins add support for storage systems. An object store plugin, such as the AWS plugin, reads and writes backup files in a bucket. Volume snapshotter plugins talk to a cloud or CSI snapshot API.
- The node agent is an optional DaemonSet. It runs on every node and copies the contents of volumes at file level. You enable it with
--use-node-agentat install time.
The velero command-line tool does not do the work itself. It creates custom resources in the cluster, and the server acts on them.
Custom resources
Velero extends the API with custom resource definitions (CRDs). These are the ones you will use most.
| Resource | Purpose |
|---|---|
| `BackupStorageLocation` | Points to the bucket and prefix where backup files are stored |
| `VolumeSnapshotLocation` | Holds settings for provider volume snapshots |
| `Backup` | A request to back up, with its scope and retention |
| `Schedule` | A cron expression plus a Backup template |
| `Restore` | A request to restore from a named Backup |
Because these are ordinary Kubernetes objects, you can inspect them with kubectl. For example, kubectl -n velero get backups lists backup requests.
The backup flow
When you run velero backup create, this happens:
- The CLI creates a
Backupobject. - The server's backup controller sees it and queries the API server for the objects that match the scope.
- It writes the objects as JSON inside a compressed archive, with metadata and logs, to the bucket named by the
BackupStorageLocation. - If volumes are included, Velero also captures their data, either as snapshots or as file-level copies through the node agent.
- The
Backupstatus moves toCompleted, or toPartiallyFailedorFailedif problems occurred.
Restore follows the reverse path. A Restore object tells the server to read a backup from the bucket and recreate its objects through the API.
Common mistakes
- Assuming volume data is included by default. Without a snapshot or file system backup option, you save only the PersistentVolumeClaim objects, not their data.
- Losing access to the bucket. Backups live outside the cluster, so the credentials secret and bucket permissions must keep working.
- Treating
Completedas proof of a good restore. Only a restore test proves that.
Exercise
You run velero backup create and later delete the Velero Deployment. Where are the backup files, and which resource tells a new Velero install where to find them?
Show answer
The backup files are in the object storage bucket, not in the cluster. A BackupStorageLocation pointing to that bucket and prefix lets a new Velero install find and list the backups.