Velero is an open-source backup and migration tool for Kubernetes clusters. It integrates the persistent volume (PV) data backup capability of the Restic tool and can be used to back up Kubernetes resource objects (such as Deployments, jobs, Services, and ConfigMaps) in the source cluster. Data in the PV mounted to the pod is backed up and uploaded to the object storage. When a disaster occurs or migration is required, the target cluster can use Velero to obtain the corresponding backup data from OBS and restore cluster resources as required.
According to Migration Solution, prepare temporary object storage to store backup files before the migration. Velero supports OSB or MinIO as the object storage. OBS requires sufficient storage space for storing backup files. You can estimate the storage space based on your cluster scale and data volume. You are advised to use OBS for backup. For details about how to deploy Velero, see Installing Velero.
MinIO is an open-source, high-performance object storage tool compatible with the S3 API protocol. If MinIO is used to store backup files for cluster migration, you need a temporary server to deploy MinIO and provide services for external systems. If you use OBS to store backup files, skip this section and go to Installing Velero.
MinIO can be installed in any of the following locations:
If the MinIO server is installed outside the cluster, backup files will not be affected when a catastrophic fault occurs in the cluster.
For example, to install MinIO in a container, run the following command:
Regardless of which deployment method is used, the server where MinIO is installed must have sufficient storage space, an EIP must be bound to the server, and the MinIO service port must be enabled in the security group. Otherwise, backup files cannot be uploaded or downloaded.
In this example, MinIO is installed on a temporary ECS outside the cluster.
mkdir /opt/minio mkdir /opt/miniodata cd /opt/minio wget https://dl.minio.io/server/minio/release/linux-amd64/minio chmod +x minio
export MINIO_ROOT_USER=minio export MINIO_ROOT_PASSWORD=minio123
./minio server /opt/miniodata/ --console-address ":30840" &
Enable the API and console ports in the firewall and security group on the server where MinIO is to be installed. Otherwise, access to the object bucket will fail.
Go to the OBS console or MinIO console and create a bucket named velero to store backup files. You can custom the bucket name, which must be used when installing Velero. Otherwise, the bucket cannot be accessed and the backup fails. For details, see 5.
Download the latest, stable binary file from https://github.com/vmware-tanzu/velero/releases. This section uses Velero 1.13.1 as an example. The installation process in the source cluster is the same as that in the target cluster.
wget https://github.com/vmware-tanzu/velero/releases/download/v1.13.1/velero-v1.13.1-linux-amd64.tar.gz
tar -xvf velero-v1.13.1-linux-amd64.tar.gz cp ./velero-v1.13.1-linux-amd64/velero /usr/local/bin
vim credentials-velero
[default] aws_access_key_id = {AK} aws_secret_access_key = {SK}
velero install \ --provider aws \ --plugins velero/velero-plugin-for-aws:v1.9.1 \ --bucket velero \ --secret-file ./credentials-velero \ --use-node-agent \ --use-volume-snapshots=false \ --backup-location-config region=eu-de,s3ForcePathStyle="true",s3Url=http://obs.eu-de.otc.t-systems.com
Parameter |
Description |
---|---|
--provider |
AWS S3 component to be used |
--plugins |
API component compatible with AWS S3. Both OBS and MinIO support the S3 protocol. |
--bucket |
Name of the object storage bucket for storing backup files. The bucket must be created in advance. |
--secret-file |
Secret file for accessing the object storage, that is, the credentials-velero file created in 4. |
--use-node-agent |
Whether to enable PV data backup. You are advised to enable this function. Otherwise, storage volume resources cannot be backed up. |
--use-volume-snapshots |
Whether to create the VolumeSnapshotLocation object for PV snapshot, which requires support from the snapshot program. Set this parameter to false. |
--backup-location-config |
OBS bucket configurations, including region, s3ForcePathStyle, and s3Url. |
region |
Region to which object storage bucket belongs.
|
s3ForcePathStyle |
The value true indicates that the S3 file path format is used. |
s3Url |
API access address of the object storage bucket.
|
$ kubectl get pod -n velero NAME READY STATUS RESTARTS AGE node-agent-rn29c 1/1 Running 0 16s velero-c9ddd56-tkzpk 1/1 Running 0 16s
To prevent memory insufficiency during backup in the actual production environment, you are advised to change the CPU and memory allocated to node-agent and Velero by referring to Backup Tool Resources Are Insufficient.
$ velero backup-location get NAME PROVIDER BUCKET/PREFIX PHASE LAST VALIDATED ACCESS MODE DEFAULT default aws velero Available 2021-10-22 15:21:12 +0800 CST ReadWrite true