mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-26 18:04:31 +00:00
Extract providers (#1985)
* Remove cloud providers and reorg code Signed-off-by: Carlisia <carlisia@vmware.com> * Update dependencies Signed-off-by: Carlisia <carlisia@vmware.com> * Fix tests Signed-off-by: Carlisia <carlisia@vmware.com> * fix dependency issues Signed-off-by: Carlisia <carlisia@vmware.com> * Delete dup test Signed-off-by: Carlisia <carlisia@vmware.com> * Add back spaces to file Signed-off-by: Carlisia <carlisia@vmware.com> * Remove and update docs Signed-off-by: Carlisia <carlisia@vmware.com> * Make the plugins flag required Signed-off-by: Carlisia <carlisia@vmware.com> * Add changelog Signed-off-by: Carlisia <carlisia@vmware.com> * Make the plugins flag conditional Signed-off-by: Carlisia <carlisia@vmware.com>
This commit is contained in:
committed by
Adnan Abdulhussein
parent
69f993aebd
commit
d26bf05b33
@@ -1,306 +0,0 @@
|
||||
# Run Velero on AWS
|
||||
|
||||
To set up Velero on AWS, you:
|
||||
|
||||
* Download an official release of Velero
|
||||
* Create your S3 bucket
|
||||
* Create an AWS IAM user for Velero
|
||||
* Install the server
|
||||
|
||||
If you do not have the `aws` CLI locally installed, follow the [user guide][5] to set it up.
|
||||
|
||||
## Download Velero
|
||||
|
||||
1. Download the [latest official release's](https://github.com/vmware-tanzu/velero/releases) tarball for your client platform.
|
||||
|
||||
_We strongly recommend that you use an [official release](https://github.com/vmware-tanzu/velero/releases) 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!_
|
||||
|
||||
2. 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.
|
||||
|
||||
3. Move the `velero` binary from the Velero directory to somewhere in your PATH.
|
||||
|
||||
## Create S3 bucket
|
||||
|
||||
Velero requires an object storage bucket to store backups in, preferrably unique to a single Kubernetes cluster (see the [FAQ][20] for more details). Create an S3 bucket, replacing placeholders appropriately:
|
||||
|
||||
```bash
|
||||
BUCKET=<YOUR_BUCKET>
|
||||
REGION=<YOUR_REGION>
|
||||
aws s3api create-bucket \
|
||||
--bucket $BUCKET \
|
||||
--region $REGION \
|
||||
--create-bucket-configuration LocationConstraint=$REGION
|
||||
```
|
||||
NOTE: us-east-1 does not support a `LocationConstraint`. If your region is `us-east-1`, omit the bucket configuration:
|
||||
|
||||
```bash
|
||||
aws s3api create-bucket \
|
||||
--bucket $BUCKET \
|
||||
--region us-east-1
|
||||
```
|
||||
|
||||
## Create IAM user
|
||||
|
||||
For more information, see [the AWS documentation on IAM users][14].
|
||||
|
||||
1. Create the IAM user:
|
||||
|
||||
```bash
|
||||
aws iam create-user --user-name velero
|
||||
```
|
||||
|
||||
If you'll be using Velero to backup multiple clusters with multiple S3 buckets, it may be desirable to create a unique username per cluster rather than the default `velero`.
|
||||
|
||||
2. Attach policies to give `velero` the necessary permissions:
|
||||
|
||||
```
|
||||
cat > velero-policy.json <<EOF
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"ec2:DescribeVolumes",
|
||||
"ec2:DescribeSnapshots",
|
||||
"ec2:CreateTags",
|
||||
"ec2:CreateVolume",
|
||||
"ec2:CreateSnapshot",
|
||||
"ec2:DeleteSnapshot"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject",
|
||||
"s3:PutObject",
|
||||
"s3:AbortMultipartUpload",
|
||||
"s3:ListMultipartUploadParts"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::${BUCKET}/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::${BUCKET}"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
```bash
|
||||
aws iam put-user-policy \
|
||||
--user-name velero \
|
||||
--policy-name velero \
|
||||
--policy-document file://velero-policy.json
|
||||
```
|
||||
|
||||
3. Create an access key for the user:
|
||||
|
||||
```bash
|
||||
aws iam create-access-key --user-name velero
|
||||
```
|
||||
|
||||
The result should look like:
|
||||
|
||||
```json
|
||||
{
|
||||
"AccessKey": {
|
||||
"UserName": "velero",
|
||||
"Status": "Active",
|
||||
"CreateDate": "2017-07-31T22:24:41.576Z",
|
||||
"SecretAccessKey": <AWS_SECRET_ACCESS_KEY>,
|
||||
"AccessKeyId": <AWS_ACCESS_KEY_ID>
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
4. Create a Velero-specific credentials file (`credentials-velero`) in your local directory:
|
||||
|
||||
```bash
|
||||
[default]
|
||||
aws_access_key_id=<AWS_ACCESS_KEY_ID>
|
||||
aws_secret_access_key=<AWS_SECRET_ACCESS_KEY>
|
||||
```
|
||||
|
||||
where the access key id and secret are the values returned from the `create-access-key` request.
|
||||
|
||||
|
||||
## Install and start Velero
|
||||
|
||||
Install Velero, including all prerequisites, into the cluster and start the deployment. This will create a namespace called `velero`, and place a deployment named `velero` in it.
|
||||
|
||||
```bash
|
||||
velero install \
|
||||
--provider aws \
|
||||
--bucket $BUCKET \
|
||||
--secret-file ./credentials-velero \
|
||||
--backup-location-config region=$REGION \
|
||||
--snapshot-location-config region=$REGION
|
||||
```
|
||||
|
||||
Additionally, you can specify `--use-restic` to enable restic support, and `--wait` to wait for the deployment to be ready.
|
||||
|
||||
(Optional) Specify [additional configurable parameters][21] for the `--backup-location-config` flag.
|
||||
|
||||
(Optional) Specify [additional configurable parameters][6] for the `--snapshot-location-config` flag.
|
||||
|
||||
(Optional) Specify [CPU and memory resource requests and limits][22] for the Velero/restic pods.
|
||||
|
||||
For more complex installation needs, use either the Helm chart, or add `--dry-run -o yaml` options for generating the YAML representation for the installation.
|
||||
|
||||
## Setting AWS_CLUSTER_NAME (Optional)
|
||||
|
||||
If you have multiple clusters and you want to support migration of resources between them, you can use `kubectl edit deploy/velero -n velero` to edit your deployment:
|
||||
|
||||
Add the environment variable `AWS_CLUSTER_NAME` under `spec.template.spec.env`, with the current cluster's name. When restoring backup, it will make Velero (and cluster it's running on) claim ownership of AWS volumes created from snapshots taken on different cluster.
|
||||
The best way to get the current cluster's name is to either check it with used deployment tool or to read it directly from the EC2 instances tags.
|
||||
|
||||
The following listing shows how to get the cluster's nodes EC2 Tags. First, get the nodes external IDs (EC2 IDs):
|
||||
|
||||
```bash
|
||||
kubectl get nodes -o jsonpath='{.items[*].spec.externalID}'
|
||||
```
|
||||
|
||||
Copy one of the returned IDs `<ID>` and use it with the `aws` CLI tool to search for one of the following:
|
||||
|
||||
* The `kubernetes.io/cluster/<AWS_CLUSTER_NAME>` tag of the value `owned`. The `<AWS_CLUSTER_NAME>` is then your cluster's name:
|
||||
|
||||
```bash
|
||||
aws ec2 describe-tags --filters "Name=resource-id,Values=<ID>" "Name=value,Values=owned"
|
||||
```
|
||||
|
||||
* If the first output returns nothing, then check for the legacy Tag `KubernetesCluster` of the value `<AWS_CLUSTER_NAME>`:
|
||||
|
||||
```bash
|
||||
aws ec2 describe-tags --filters "Name=resource-id,Values=<ID>" "Name=key,Values=KubernetesCluster"
|
||||
```
|
||||
|
||||
## ALTERNATIVE: Setup permissions using kube2iam
|
||||
|
||||
[Kube2iam](https://github.com/jtblin/kube2iam) is a Kubernetes application that allows managing AWS IAM permissions for pod via annotations rather than operating on API keys.
|
||||
|
||||
> This path assumes you have `kube2iam` already running in your Kubernetes cluster. If that is not the case, please install it first, following the docs here: [https://github.com/jtblin/kube2iam](https://github.com/jtblin/kube2iam)
|
||||
|
||||
It can be set up for Velero by creating a role that will have required permissions, and later by adding the permissions annotation on the velero deployment to define which role it should use internally.
|
||||
|
||||
1. Create a Trust Policy document to allow the role being used for EC2 management & assume kube2iam role:
|
||||
|
||||
```
|
||||
cat > velero-trust-policy.json <<EOF
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"Service": "ec2.amazonaws.com"
|
||||
},
|
||||
"Action": "sts:AssumeRole"
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Principal": {
|
||||
"AWS": "arn:aws:iam::<AWS_ACCOUNT_ID>:role/<ROLE_CREATED_WHEN_INITIALIZING_KUBE2IAM>"
|
||||
},
|
||||
"Action": "sts:AssumeRole"
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
|
||||
2. Create the IAM role:
|
||||
|
||||
```bash
|
||||
aws iam create-role --role-name velero --assume-role-policy-document file://./velero-trust-policy.json
|
||||
```
|
||||
|
||||
3. Attach policies to give `velero` the necessary permissions:
|
||||
|
||||
```
|
||||
BUCKET=<YOUR_BUCKET>
|
||||
cat > velero-policy.json <<EOF
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"ec2:DescribeVolumes",
|
||||
"ec2:DescribeSnapshots",
|
||||
"ec2:CreateTags",
|
||||
"ec2:CreateVolume",
|
||||
"ec2:CreateSnapshot",
|
||||
"ec2:DeleteSnapshot"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:GetObject",
|
||||
"s3:DeleteObject",
|
||||
"s3:PutObject",
|
||||
"s3:AbortMultipartUpload",
|
||||
"s3:ListMultipartUploadParts"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::${BUCKET}/*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:ListBucket"
|
||||
],
|
||||
"Resource": [
|
||||
"arn:aws:s3:::${BUCKET}"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
```
|
||||
```bash
|
||||
aws iam put-role-policy \
|
||||
--role-name velero \
|
||||
--policy-name velero-policy \
|
||||
--policy-document file://./velero-policy.json
|
||||
```
|
||||
|
||||
4. Use the `--pod-annotations` argument on `velero install` to add the following annotation:
|
||||
|
||||
```bash
|
||||
velero install \
|
||||
--pod-annotations iam.amazonaws.com/role=arn:aws:iam::<AWS_ACCOUNT_ID>:role/<VELERO_ROLE_NAME> \
|
||||
--provider aws \
|
||||
--bucket $BUCKET \
|
||||
--backup-location-config region=$REGION \
|
||||
--snapshot-location-config region=$REGION \
|
||||
--no-secret
|
||||
```
|
||||
|
||||
[0]: namespace.md
|
||||
[5]: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html
|
||||
[6]: api-types/volumesnapshotlocation.md#aws
|
||||
[14]: http://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html
|
||||
[20]: faq.md
|
||||
[21]: api-types/backupstoragelocation.md#aws
|
||||
[22]: install-overview.md#velero-resource-requirements
|
||||
@@ -1,205 +0,0 @@
|
||||
# Run Velero on Azure
|
||||
|
||||
To configure Velero on Azure, you:
|
||||
|
||||
* Download an official release of Velero
|
||||
* Create your Azure storage account and blob container
|
||||
* Create Azure service principal for Velero
|
||||
* Install the server
|
||||
|
||||
If you do not have the `az` Azure CLI 2.0 installed locally, follow the [install guide][18] to set it up.
|
||||
|
||||
Run:
|
||||
|
||||
```bash
|
||||
az login
|
||||
```
|
||||
|
||||
## Kubernetes cluster prerequisites
|
||||
|
||||
Ensure that the VMs for your agent pool allow Managed Disks. If I/O performance is critical,
|
||||
consider using Premium Managed Disks, which are SSD backed.
|
||||
|
||||
## Download Velero
|
||||
|
||||
1. Download the [latest official release's](https://github.com/vmware-tanzu/velero/releases) tarball for your client platform.
|
||||
|
||||
_We strongly recommend that you use an [official release](https://github.com/vmware-tanzu/velero/releases) 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!_
|
||||
|
||||
1. Extract the tarball:
|
||||
|
||||
```bash
|
||||
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.
|
||||
|
||||
1. Move the `velero` binary from the Velero directory to somewhere in your PATH.
|
||||
|
||||
## (Optional) Change to the Azure subscription you want to create your backups in
|
||||
|
||||
By default, Velero will store backups in the same Subscription as your VMs and disks and will
|
||||
not allow you to restore backups to a Resource Group in a different Subscription. To enable backups/restore
|
||||
across Subscriptions you will need to specify the Subscription ID to backup to.
|
||||
|
||||
Use `az` to switch to the Subscription the backups should be created in.
|
||||
|
||||
First, find the Subscription ID by name.
|
||||
|
||||
```bash
|
||||
AZURE_BACKUP_SUBSCRIPTION_NAME=<NAME_OF_TARGET_SUBSCRIPTION>
|
||||
AZURE_BACKUP_SUBSCRIPTION_ID=$(az account list --query="[?name=='$AZURE_BACKUP_SUBSCRIPTION_NAME'].id | [0]" -o tsv)
|
||||
```
|
||||
|
||||
Second, change the Subscription.
|
||||
|
||||
```bash
|
||||
az account set -s $AZURE_BACKUP_SUBSCRIPTION_ID
|
||||
```
|
||||
|
||||
Execute the next step – creating an storage account and blob container – using the active Subscription.
|
||||
|
||||
## Create Azure storage account and blob container
|
||||
|
||||
Velero requires a storage account and blob container in which to store backups.
|
||||
|
||||
The storage account can be created in the same Resource Group as your Kubernetes cluster or
|
||||
separated into its own Resource Group. The example below shows the storage account created in a
|
||||
separate `Velero_Backups` Resource Group.
|
||||
|
||||
The storage account needs to be created with a globally unique id since this is used for dns. In
|
||||
the sample script below, we're generating a random name using `uuidgen`, but you can come up with
|
||||
this name however you'd like, following the [Azure naming rules for storage accounts][19]. The
|
||||
storage account is created with encryption at rest capabilities (Microsoft managed keys) and is
|
||||
configured to only allow access via https.
|
||||
|
||||
Create a resource group for the backups storage account. Change the location as needed.
|
||||
|
||||
```bash
|
||||
AZURE_BACKUP_RESOURCE_GROUP=Velero_Backups
|
||||
az group create -n $AZURE_BACKUP_RESOURCE_GROUP --location WestUS
|
||||
```
|
||||
|
||||
Create the storage account.
|
||||
|
||||
```bash
|
||||
AZURE_STORAGE_ACCOUNT_ID="velero$(uuidgen | cut -d '-' -f5 | tr '[A-Z]' '[a-z]')"
|
||||
az storage account create \
|
||||
--name $AZURE_STORAGE_ACCOUNT_ID \
|
||||
--resource-group $AZURE_BACKUP_RESOURCE_GROUP \
|
||||
--sku Standard_GRS \
|
||||
--encryption-services blob \
|
||||
--https-only true \
|
||||
--kind BlobStorage \
|
||||
--access-tier Hot
|
||||
```
|
||||
|
||||
Create the blob container named `velero`. Feel free to use a different name, preferably unique to a single Kubernetes cluster. See the [FAQ][20] for more details.
|
||||
|
||||
```bash
|
||||
BLOB_CONTAINER=velero
|
||||
az storage container create -n $BLOB_CONTAINER --public-access off --account-name $AZURE_STORAGE_ACCOUNT_ID
|
||||
```
|
||||
|
||||
## Get resource group for persistent volume snapshots
|
||||
|
||||
_(Optional) If you decided to backup to a different Subscription, make sure you change back to the Subscription
|
||||
of your cluster's resources before continuing._
|
||||
|
||||
1. Set the name of the Resource Group that contains your Kubernetes cluster's virtual machines/disks.
|
||||
|
||||
**WARNING**: If you're using [AKS][22], `AZURE_RESOURCE_GROUP` must be set to the name of the auto-generated resource group that is created
|
||||
when you provision your cluster in Azure, since this is the resource group that contains your cluster's virtual machines/disks.
|
||||
|
||||
```bash
|
||||
AZURE_RESOURCE_GROUP=<NAME_OF_RESOURCE_GROUP>
|
||||
```
|
||||
|
||||
If you are unsure of the Resource Group name, run the following command to get a list that you can select from. Then set the `AZURE_RESOURCE_GROUP` environment variable to the appropriate value.
|
||||
|
||||
```bash
|
||||
az group list --query '[].{ ResourceGroup: name, Location:location }'
|
||||
```
|
||||
|
||||
Get your cluster's Resource Group name from the `ResourceGroup` value in the response, and use it to set `$AZURE_RESOURCE_GROUP`.
|
||||
|
||||
## Create service principal
|
||||
|
||||
To integrate Velero with Azure, you must create a Velero-specific [service principal][17].
|
||||
|
||||
1. Obtain your Azure Account Subscription ID and Tenant ID:
|
||||
|
||||
```bash
|
||||
AZURE_SUBSCRIPTION_ID=`az account list --query '[?isDefault].id' -o tsv`
|
||||
AZURE_TENANT_ID=`az account list --query '[?isDefault].tenantId' -o tsv`
|
||||
```
|
||||
|
||||
1. Create a service principal with `Contributor` role. This will have subscription-wide access, so protect this credential.
|
||||
|
||||
If you'll be using Velero to backup multiple clusters with multiple blob containers, it may be desirable to create a unique username per cluster rather than the default `velero`.
|
||||
|
||||
Create service principal and let the CLI generate a password for you. Make sure to capture the password.
|
||||
|
||||
_(Optional) If you are using a different Subscription for backups and cluster resources, make sure to specify both subscriptions
|
||||
in the `az` command using `--scopes`._
|
||||
|
||||
```bash
|
||||
AZURE_CLIENT_SECRET=`az ad sp create-for-rbac --name "velero" --role "Contributor" --query 'password' -o tsv \
|
||||
[--scopes /subscriptions/$AZURE_BACKUP_SUBSCRIPTION_ID /subscriptions/$AZURE_SUBSCRIPTION_ID]`
|
||||
```
|
||||
|
||||
After creating the service principal, obtain the client id.
|
||||
|
||||
```bash
|
||||
AZURE_CLIENT_ID=`az ad sp list --display-name "velero" --query '[0].appId' -o tsv`
|
||||
```
|
||||
|
||||
1. Now you need to create a file that contains all the environment variables you just set. The command looks like the following:
|
||||
|
||||
```
|
||||
cat << EOF > ./credentials-velero
|
||||
AZURE_SUBSCRIPTION_ID=${AZURE_SUBSCRIPTION_ID}
|
||||
AZURE_TENANT_ID=${AZURE_TENANT_ID}
|
||||
AZURE_CLIENT_ID=${AZURE_CLIENT_ID}
|
||||
AZURE_CLIENT_SECRET=${AZURE_CLIENT_SECRET}
|
||||
AZURE_RESOURCE_GROUP=${AZURE_RESOURCE_GROUP}
|
||||
AZURE_CLOUD_NAME=AzurePublicCloud
|
||||
EOF
|
||||
```
|
||||
|
||||
> available `AZURE_CLOUD_NAME` values: `AzurePublicCloud`, `AzureUSGovernmentCloud`, `AzureChinaCloud`, `AzureGermanCloud`
|
||||
|
||||
## Install and start Velero
|
||||
|
||||
Install Velero, including all prerequisites, into the cluster and start the deployment. This will create a namespace called `velero`, and place a deployment named `velero` in it.
|
||||
|
||||
```bash
|
||||
velero install \
|
||||
--provider azure \
|
||||
--bucket $BLOB_CONTAINER \
|
||||
--secret-file ./credentials-velero \
|
||||
--backup-location-config resourceGroup=$AZURE_BACKUP_RESOURCE_GROUP,storageAccount=$AZURE_STORAGE_ACCOUNT_ID[,subscriptionId=$AZURE_BACKUP_SUBSCRIPTION_ID] \
|
||||
--snapshot-location-config apiTimeout=<YOUR_TIMEOUT>[,resourceGroup=$AZURE_BACKUP_RESOURCE_GROUP,subscriptionId=$AZURE_BACKUP_SUBSCRIPTION_ID]
|
||||
```
|
||||
|
||||
Additionally, you can specify `--use-restic` to enable restic support, and `--wait` to wait for the deployment to be ready.
|
||||
|
||||
(Optional) Specify [additional configurable parameters][21] for the `--backup-location-config` flag.
|
||||
|
||||
(Optional) Specify [additional configurable parameters][8] for the `--snapshot-location-config` flag.
|
||||
|
||||
(Optional) Specify [CPU and memory resource requests and limits][23] for the Velero/restic pods.
|
||||
|
||||
For more complex installation needs, use either the Helm chart, or add `--dry-run -o yaml` options for generating the YAML representation for the installation.
|
||||
|
||||
[0]: namespace.md
|
||||
[8]: api-types/volumesnapshotlocation.md#azure
|
||||
[17]: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-application-objects
|
||||
[18]: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
|
||||
[19]: https://docs.microsoft.com/en-us/azure/architecture/best-practices/naming-conventions#storage
|
||||
[20]: faq.md
|
||||
[21]: api-types/backupstoragelocation.md#azure
|
||||
[22]: https://azure.microsoft.com/en-us/services/kubernetes-service/
|
||||
[23]: install-overview.md#velero-resource-requirements
|
||||
@@ -1,170 +0,0 @@
|
||||
# Run Velero on GCP
|
||||
|
||||
You can run Kubernetes on Google Cloud Platform in either:
|
||||
|
||||
* Kubernetes on Google Compute Engine virtual machines
|
||||
* Google Kubernetes Engine
|
||||
|
||||
If you do not have the `gcloud` and `gsutil` CLIs locally installed, follow the [user guide][16] to set them up.
|
||||
|
||||
## Download Velero
|
||||
|
||||
1. Download the [latest official release's](https://github.com/vmware-tanzu/velero/releases) tarball for your client platform.
|
||||
|
||||
_We strongly recommend that you use an [official release](https://github.com/vmware-tanzu/velero/releases) 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!_
|
||||
|
||||
1. Extract the tarball:
|
||||
|
||||
```bash
|
||||
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.
|
||||
|
||||
1. Move the `velero` binary from the Velero directory to somewhere in your PATH.
|
||||
|
||||
## Create GCS bucket
|
||||
|
||||
Velero requires an object storage bucket in which to store backups, preferably unique to a single Kubernetes cluster (see the [FAQ][20] for more details). Create a GCS bucket, replacing the <YOUR_BUCKET> placeholder with the name of your bucket:
|
||||
|
||||
```bash
|
||||
BUCKET=<YOUR_BUCKET>
|
||||
|
||||
gsutil mb gs://$BUCKET/
|
||||
```
|
||||
|
||||
## Create service account
|
||||
|
||||
To integrate Velero with GCP, create a Velero-specific [Service Account][15]:
|
||||
|
||||
1. View your current config settings:
|
||||
|
||||
```bash
|
||||
gcloud config list
|
||||
```
|
||||
|
||||
Store the `project` value from the results in the environment variable `$PROJECT_ID`.
|
||||
|
||||
```bash
|
||||
PROJECT_ID=$(gcloud config get-value project)
|
||||
```
|
||||
|
||||
2. Create a service account:
|
||||
|
||||
```bash
|
||||
gcloud iam service-accounts create velero \
|
||||
--display-name "Velero service account"
|
||||
```
|
||||
|
||||
> If you'll be using Velero to backup multiple clusters with multiple GCS buckets, it may be desirable to create a unique username per cluster rather than the default `velero`.
|
||||
|
||||
Then list all accounts and find the `velero` account you just created:
|
||||
|
||||
```bash
|
||||
gcloud iam service-accounts list
|
||||
```
|
||||
|
||||
Set the `$SERVICE_ACCOUNT_EMAIL` variable to match its `email` value.
|
||||
|
||||
```bash
|
||||
SERVICE_ACCOUNT_EMAIL=$(gcloud iam service-accounts list \
|
||||
--filter="displayName:Velero service account" \
|
||||
--format 'value(email)')
|
||||
```
|
||||
|
||||
3. Attach policies to give `velero` the necessary permissions to function:
|
||||
|
||||
```bash
|
||||
ROLE_PERMISSIONS=(
|
||||
compute.disks.get
|
||||
compute.disks.create
|
||||
compute.disks.createSnapshot
|
||||
compute.snapshots.get
|
||||
compute.snapshots.create
|
||||
compute.snapshots.useReadOnly
|
||||
compute.snapshots.delete
|
||||
compute.zones.get
|
||||
)
|
||||
|
||||
gcloud iam roles create velero.server \
|
||||
--project $PROJECT_ID \
|
||||
--title "Velero Server" \
|
||||
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")"
|
||||
|
||||
gcloud projects add-iam-policy-binding $PROJECT_ID \
|
||||
--member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
|
||||
--role projects/$PROJECT_ID/roles/velero.server
|
||||
|
||||
gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://${BUCKET}
|
||||
```
|
||||
|
||||
4. Create a service account key, specifying an output file (`credentials-velero`) in your local directory:
|
||||
|
||||
```bash
|
||||
gcloud iam service-accounts keys create credentials-velero \
|
||||
--iam-account $SERVICE_ACCOUNT_EMAIL
|
||||
```
|
||||
|
||||
## Credentials and configuration
|
||||
|
||||
If you run Google Kubernetes Engine (GKE), make sure that your current IAM user is a cluster-admin. This role is required to create RBAC objects.
|
||||
See [the GKE documentation][22] for more information.
|
||||
|
||||
|
||||
## Install and start Velero
|
||||
|
||||
Install Velero, including all prerequisites, into the cluster and start the deployment. This will create a namespace called `velero`, and place a deployment named `velero` in it.
|
||||
|
||||
```bash
|
||||
velero install \
|
||||
--provider gcp \
|
||||
--bucket $BUCKET \
|
||||
--secret-file ./credentials-velero
|
||||
```
|
||||
|
||||
Additionally, you can specify `--use-restic` to enable restic support, and `--wait` to wait for the deployment to be ready.
|
||||
|
||||
(Optional) Specify `--snapshot-location-config snapshotLocation=<YOUR_LOCATION>` to keep snapshots in a specific availability zone. See the [VolumeSnapshotLocation definition][8] for details.
|
||||
|
||||
(Optional) Specify [additional configurable parameters][7] for the `--backup-location-config` flag.
|
||||
|
||||
(Optional) Specify [additional configurable parameters][8] for the `--snapshot-location-config` flag.
|
||||
|
||||
(Optional) Specify [CPU and memory resource requests and limits][23] for the Velero/restic pods.
|
||||
|
||||
For more complex installation needs, use either the Helm chart, or add `--dry-run -o yaml` options for generating the YAML representation for the installation.
|
||||
|
||||
## Using Workload Identity (Optional)
|
||||
|
||||
If you are running Velero on a GKE cluster with workload identity enabled, you may want to bind Velero's Kubernetes service account to a GCP service account with the appropriate permissions instead of providing the key file during installation.
|
||||
|
||||
To do this, you must grant the GCP service account(the one you created in Step 3) the 'iam.serviceAccounts.signBlob' role. This is so that Velero's Kubernetes service account can create signed urls for the GCP bucket.
|
||||
|
||||
Next, add an IAM policy binding to grant Velero's Kubernetes service account access to your created GCP service account.
|
||||
|
||||
```bash
|
||||
gcloud iam service-accounts add-iam-policy-binding \
|
||||
--role roles/iam.workloadIdentityUser \
|
||||
--member serviceAccount:[PROJECT_ID].svc.id.goog[velero/velero] \
|
||||
[GSA_NAME]@[PROJECT_ID].iam.gserviceaccount.com
|
||||
```
|
||||
|
||||
For more information on configuring workload identity on GKE, look at the [official GCP documentation][24] for more details.
|
||||
|
||||
Finally, you must add a service account annotation to the Kubernetes service account so that it will know which GCP service account to use. You can do this during installation with `--sa-annotations`. Furthermore, you must also use the flag `--no-secret` so that Velero will know not to look for a key file. You must also add the GCP service account name in `--backup-location-config`.
|
||||
|
||||
```bash
|
||||
velero install --provider gcp --no-secret --sa-annotations iam.gke.io/gcp-service-account=[GSA_NAME]@[PROJECT_ID].iam.gserviceaccount.com --backup-location-config serviceAccount=[GSA_NAME]@[PROJECT_ID].iam.gserviceaccount.com
|
||||
```
|
||||
|
||||
[0]: namespace.md
|
||||
[7]: api-types/backupstoragelocation.md#gcp
|
||||
[8]: api-types/volumesnapshotlocation.md#gcp
|
||||
[15]: https://cloud.google.com/compute/docs/access/service-accounts
|
||||
[16]: https://cloud.google.com/sdk/docs/
|
||||
[20]: faq.md
|
||||
[22]: https://cloud.google.com/kubernetes-engine/docs/how-to/role-based-access-control#iam-rolebinding-bootstrap
|
||||
[23]: install-overview.md#velero-resource-requirements
|
||||
[24]: https://cloud.google.com/kubernetes-engine/docs/how-to/workload-identity
|
||||
@@ -50,11 +50,11 @@ In the case you want to take volume snapshots but didn't find a plugin for your
|
||||
[5]: http://www.noobaa.com/
|
||||
[6]: api-types/backupstoragelocation.md#aws
|
||||
[7]: https://aws.amazon.com/s3/
|
||||
[8]: aws-config.md
|
||||
[8]: https://github.com/vmware-tanzu/velero-plugin-for-aws
|
||||
[9]: https://azure.microsoft.com/en-us/services/storage/blobs
|
||||
[10]: azure-config.md
|
||||
[10]: https://github.com/vmware-tanzu/velero-plugin-for-microsoft-azure
|
||||
[11]: https://cloud.google.com/storage/
|
||||
[12]: gcp-config.md
|
||||
[12]: https://github.com/vmware-tanzu/velero-plugin-for-gcp
|
||||
[15]: https://www.digitalocean.com/
|
||||
[16]: https://github.com/StackPointCloud/ark-plugin-digitalocean
|
||||
[17]: https://openebs.io/
|
||||
|
||||
Reference in New Issue
Block a user