4.2.2.2. 配置 Amazon Web Services
您可以为 OpenShift API 配置 Amazon Web Services(AWS)以进行数据保护(OADP)。
先决条件
- 已安装 AWS CLI。
步骤
设置
BUCKET
变量:$ BUCKET=<your_bucket>
设置
REGION
变量:$ REGION=<your_region>
创建 AWS S3 存储桶:
$ aws s3api create-bucket \ --bucket $BUCKET \ --region $REGION \ --create-bucket-configuration LocationConstraint=$REGION 1
- 1
us-east-1
不支持LocationConstraint
。如果您的区域是us-east-1
,忽略--create-bucket-configuration LocationConstraint=$REGION
。
创建一个 IAM 用户:
$ aws iam create-user --user-name velero 1
- 1
- 如果要使用 Velero 备份具有多个 S3 存储桶的集群,请为每个集群创建一个唯一用户名。
创建
velero-policy.json
文件:$ 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", "s3:GetBucketLocation", "s3:ListBucketMultipartUploads" ], "Resource": [ "arn:aws:s3:::${BUCKET}" ] } ] } EOF
附加策略,为
velero
用户授予所需权限:$ aws iam put-user-policy \ --user-name velero \ --policy-name velero \ --policy-document file://velero-policy.json
为
velero
用户创建访问密钥:$ aws iam create-access-key --user-name velero
输出示例
{ "AccessKey": { "UserName": "velero", "Status": "Active", "CreateDate": "2017-07-31T22:24:41.576Z", "SecretAccessKey": <AWS_SECRET_ACCESS_KEY>, "AccessKeyId": <AWS_ACCESS_KEY_ID> } }
创建
credentials-velero
文件:$ cat << EOF > ./credentials-velero [default] aws_access_key_id=<AWS_ACCESS_KEY_ID> aws_secret_access_key=<AWS_SECRET_ACCESS_KEY> EOF
在安装数据保护应用程序前,您可以使用
credentials-velero
文件为 AWS 创建Secret
对象。