README ¶
Overview
Velero is a utility to back up and restore your Kubernetes resource and persistent volumes.
To do backup/restore on Alibaba Cloud through Velero utility, you need to install and configure velero and velero-plugin for alibabacloud.
Run velero on AlibabaCloud
To set up Velero on AlibabaCloud, you:
- Download an official release of Velero
- Create your OSS bucket
- Create an RAM user for Velero
- Install the velero and velero-plugin for alibabacloud
Download Velero
-
Download the latest official release's tarball for your client platform.
We strongly recommend that you use an official release of Velero. The tarballs for each release contain the
velero
command-line client. The code in the master branch of the Velero repository is under active development and is not guaranteed to be stable! -
Extract the tarball:
tar -xvf <RELEASE-TARBALL-NAME>.tar.gz -C /dir/to/extract/to
We'll refer to the directory you extracted to as the "Velero directory" in subsequent steps.
-
Move the
velero
binary from the Velero directory to somewhere in your PATH.
Create OSS bucket
Velero requires an object storage bucket to store backups in, preferrably unique to a single Kubernetes cluster. Create an OSS bucket, replacing placeholders appropriately:
BUCKET=<YOUR_BUCKET>
REGION=<YOUR_REGION>
ossutil mb oss://$BUCKET \
--storage-class Standard \
--acl=private
Create RAM user
For more information, see the AlibabaCloud documentation on RAM users guides.
-
Create the RAM user:
Follow the AlibabaCloud documentation on RAM users.
If you'll be using Velero to backup multiple clusters with multiple OSS buckets, it may be desirable to create a unique username per cluster rather than the default
velero
. -
Attach policies to give
velero
the necessary permissions:{ "Version": "1", "Statement": [ { "Action": [ "ecs:DescribeSnapshots", "ecs:CreateSnapshot", "ecs:DeleteSnapshot", "ecs:DescribeDisks", "ecs:CreateDisk", "ecs:Addtags", "oss:PutObject", "oss:GetObject", "oss:DeleteObject", "oss:GetBucket", "oss:ListObjects" ], "Resource": [ "*" ], "Effect": "Allow" } ] }
-
Create an access key for the user:
-
Create a Velero-specific credentials file (
credentials-velero
) in yourinstall
directory:ALIBABA_CLOUD_ACCESS_KEY_ID=<ALIBABA_CLOUD_ACCESS_KEY_ID> ALIBABA_CLOUD_ACCESS_KEY_SECRET=<ALIBABA_CLOUD_ACCESS_KEY_SECRET>
where the access key id and secret are the values get from the step 3.
Install velero and velero-plugin for alibabacloud
-
Set some environment variables
BUCKET=<YOUR_BUCKET> REGION=<YOUR_REGION>
-
Create a namespace velero and a secret cloud-credentials
Run the following command to create a namespace named
velero
kubectl create namespace velero
Run the following command to create a secret named
cloud-credentials
kubectl create secret generic cloud-credentials --namespace velero --from-file cloud=install/credentials-velero
-
Create and run velero and velero-plugin for alibabacloud
Run the following command to create and run velero and velero-plugin for alibabacloud
kubectl apply -f install/00-crds.yaml
sed -i "s#<BUCKET>#$BUCKET#" install/01-velero.yaml sed -i "s#<REGION>#$REGION#" install/01-velero.yaml kubectl apply -f install/01-velero.yaml
-
Cleanup velero installation
Run the following command to cleanup the velero installation
kubectl delete namespace/velero clusterrolebinding/velero kubectl delete crds -l component=velero
Installing the nginx example (optional)
-
nginx example without persistent volumes
Run the following command to create a nginx example without persistent volumes:
kubectl apply -f examples/base.yaml
Create a backup:
velero backup create nginx-backup --include-namespaces nginx-example --wait
Destroy the nginx example:
kubectl delete namespaces nginx-example
Create a restore from nginx-backup:
velero restore create --from-backup nginx-backup --wait
-
nginx example with persistent volumes
Run the following command to create a nginx example with persistent volumes:
kubectl apply -f examples/with-pv.yaml
Create a backup:
velero backup create nginx-backup-volume --include-namespaces nginx-example --wait
Destroy the nginx example:
kubectl delete namespaces nginx-example
Create a restore from nginx-backup-volume:
velero restore create --from-backup nginx-backup-volume --wait