使用Trident Protect AppVault 对象来管理存储桶。
Trident Protect 的存储桶自定义资源 (CR) 被称为 AppVault。AppVault 对象是存储桶的声明性 Kubernetes 工作流表示。AppVault CR 包含存储桶在保护操作(例如备份、快照、恢复操作和SnapMirror复制)中使用的必要配置。只有管理员才能创建应用保险库。
在应用程序上执行数据保护操作时,您需要手动或从命令行创建 AppVault CR。AppVaultCR 特定于您的环境,您可以使用本页上的示例作为创建 AppVault CR 的指南。
|
|
确保 AppVault CR 位于安装了Trident Protect 的集群上。如果 AppVault CR 不存在或您无法访问,命令行会显示错误。 |
配置AppVault身份验证和密码
在创建 AppVault CR 之前,请确保您选择的 AppVault 和数据移动器可以向提供商和任何相关资源进行身份验证。
数据移动工具存储库密码
当您使用 CR 或Trident Protect CLI 插件创建 AppVault 对象时,您可以为 Restic 和 Kopia 加密指定带有自定义密码的 Kubernetes 密钥。如果您不指定密钥, Trident Protect 将使用默认密码。
-
手动创建 AppVault CR 时,使用 spec.dataMoverPasswordSecretRef 字段指定密钥。
-
使用Trident Protect CLI 创建 AppVault 对象时,请使用 `--data-mover-password-secret-ref`用于指定密钥的参数。
创建数据移动工具存储库密码密钥
请参考以下示例创建密码密钥。创建 AppVault 对象时,您可以指示Trident Protect 使用此密钥向数据移动器存储库进行身份验证。
|
|
|
---
apiVersion: v1
data:
KOPIA_PASSWORD: <base64-encoded-password>
RESTIC_PASSWORD: <base64-encoded-password>
kind: Secret
metadata:
name: my-optional-data-mover-secret
namespace: trident-protect
type: Opaque
kubectl create secret generic my-optional-data-mover-secret \
--from-literal=KOPIA_PASSWORD=<plain-text-password> \
--from-literal=RESTIC_PASSWORD=<plain-text-password> \
-n trident-protect
S3 兼容存储 IAM 权限
当您访问与 S3 兼容的存储(例如 Amazon S3、通用 S3)时, "StorageGRID S3" , 或者 "ONTAP S3"使用Trident Protect 时,您需要确保提供的用户凭据具有访问存储桶的必要权限。以下是授予使用Trident Protect 进行访问所需的最低权限的策略示例。您可以将此策略应用于管理 S3 兼容存储桶策略的用户。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
"s3:DeleteObject"
],
"Resource": "*"
}
]
}
有关 Amazon S3 策略的更多信息,请参阅 "Amazon S3 文档" 。
用于 Amazon S3(AWS)身份验证的 EKS Pod Identity
Trident Protect 支持 Kopia 数据移动器操作的 EKS Pod Identity。此功能可实现对 S3 存储桶的安全访问,而无需将 AWS 凭证存储在 Kubernetes 机密中。
EKS Pod Identity 与Trident Protect 的要求
在将 EKS Pod Identity 与Trident Protect 结合使用之前,请确保以下事项:
-
您的 EKS 集群已启用 Pod Identity。
-
您已创建具有必要的 S3 存储桶权限的 IAM 角色。要了解更多信息,请参阅"S3 兼容存储 IAM 权限"。
-
IAM 角色与以下Trident Protect 服务帐户关联:
-
<trident-protect>-controller-manager -
<trident-protect>-resource-backup -
<trident-protect>-resource-restore -
<trident-protect>-resource-delete
-
有关启用 Pod Identity 以及将 IAM 角色与服务账户关联的详细说明,请参阅 "AWS EKS Pod Identity 文档"。
AppVault 配置 使用 EKS Pod Identity 时,请使用以下配置配置您的 AppVault CR `useIAM: true`标记而不是明确的凭证:
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: eks-protect-vault
namespace: trident-protect
spec:
providerType: AWS
providerConfig:
s3:
bucketName: trident-protect-aws
endpoint: s3.example.com
useIAM: true
云提供商的AppVault密钥生成示例
定义 AppVault CR 时,您需要包含凭证以访问提供商托管的资源,除非您使用 IAM 身份验证。如何生成凭证密钥将根据提供商的不同而有所不同。以下是几个提供商的命令行密钥生成示例。您可以使用以下示例为每个云提供商的凭证创建密钥。
kubectl create secret generic <secret-name> \
--from-file=credentials=<mycreds-file.json> \
-n trident-protect
kubectl create secret generic <secret-name> \
--from-literal=accessKeyID=<objectstorage-accesskey> \
--from-literal=secretAccessKey=<amazon-s3-trident-protect-src-bucket-secret> \
-n trident-protect
kubectl create secret generic <secret-name> \
--from-literal=accountKey=<secret-name> \
-n trident-protect
kubectl create secret generic <secret-name> \
--from-literal=accessKeyID=<objectstorage-accesskey> \
--from-literal=secretAccessKey=<generic-s3-trident-protect-src-bucket-secret> \
-n trident-protect
kubectl create secret generic <secret-name> \
--from-literal=accessKeyID=<objectstorage-accesskey> \
--from-literal=secretAccessKey=<ontap-s3-trident-protect-src-bucket-secret> \
-n trident-protect
kubectl create secret generic <secret-name> \
--from-literal=accessKeyID=<objectstorage-accesskey> \
--from-literal=secretAccessKey=<storagegrid-s3-trident-protect-src-bucket-secret> \
-n trident-protect
AppVault创建示例
以下是每个提供程序的AppVault定义示例。
AppVault CR示例
您可以使用以下CR示例为每个云提供程序创建AppVault对象。
|
|
|
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: gcp-trident-protect-src-bucket
namespace: trident-protect
spec:
dataMoverPasswordSecretRef: my-optional-data-mover-secret
providerType: GCP
providerConfig:
gcp:
bucketName: trident-protect-src-bucket
projectID: project-id
providerCredentials:
credentials:
valueFromSecret:
key: credentials
name: gcp-trident-protect-src-bucket-secret
---
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: amazon-s3-trident-protect-src-bucket
namespace: trident-protect
spec:
dataMoverPasswordSecretRef: my-optional-data-mover-secret
providerType: AWS
providerConfig:
s3:
bucketName: trident-protect-src-bucket
endpoint: s3.example.com
proxyURL: http://10.1.1.1:3128
providerCredentials:
accessKeyID:
valueFromSecret:
key: accessKeyID
name: s3-secret
secretAccessKey:
valueFromSecret:
key: secretAccessKey
name: s3-secret
sessionToken:
valueFromSecret:
key: sessionToken
name: s3-secret
|
|
对于使用 Pod Identity 和 Kopia 数据移动器的 EKS 环境,您可以删除 `providerCredentials`部分并添加 `useIAM: true`根据 `s3`配置。 |
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: azure-trident-protect-src-bucket
namespace: trident-protect
spec:
dataMoverPasswordSecretRef: my-optional-data-mover-secret
providerType: Azure
providerConfig:
azure:
accountName: account-name
bucketName: trident-protect-src-bucket
providerCredentials:
accountKey:
valueFromSecret:
key: accountKey
name: azure-trident-protect-src-bucket-secret
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: generic-s3-trident-protect-src-bucket
namespace: trident-protect
spec:
dataMoverPasswordSecretRef: my-optional-data-mover-secret
providerType: GenericS3
providerConfig:
s3:
bucketName: trident-protect-src-bucket
endpoint: s3.example.com
proxyURL: http://10.1.1.1:3128
providerCredentials:
accessKeyID:
valueFromSecret:
key: accessKeyID
name: s3-secret
secretAccessKey:
valueFromSecret:
key: secretAccessKey
name: s3-secret
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: ontap-s3-trident-protect-src-bucket
namespace: trident-protect
spec:
dataMoverPasswordSecretRef: my-optional-data-mover-secret
providerType: OntapS3
providerConfig:
s3:
bucketName: trident-protect-src-bucket
endpoint: s3.example.com
proxyURL: http://10.1.1.1:3128
providerCredentials:
accessKeyID:
valueFromSecret:
key: accessKeyID
name: s3-secret
secretAccessKey:
valueFromSecret:
key: secretAccessKey
name: s3-secret
apiVersion: protect.trident.netapp.io/v1
kind: AppVault
metadata:
name: storagegrid-s3-trident-protect-src-bucket
namespace: trident-protect
spec:
dataMoverPasswordSecretRef: my-optional-data-mover-secret
providerType: StorageGridS3
providerConfig:
s3:
bucketName: trident-protect-src-bucket
endpoint: s3.example.com
proxyURL: http://10.1.1.1:3128
providerCredentials:
accessKeyID:
valueFromSecret:
key: accessKeyID
name: s3-secret
secretAccessKey:
valueFromSecret:
key: secretAccessKey
name: s3-secret
使用Trident Protect CLI 创建 AppVault 的示例
您可以使用以下命令行界面命令示例为每个提供程序创建AppVault CRS。
|
|
|
tridentctl-protect create vault GCP <vault-name> \
--bucket <mybucket> \
--project <my-gcp-project> \
--secret <secret-name>/credentials \
--data-mover-password-secret-ref <my-optional-data-mover-secret> \
-n trident-protect
tridentctl-protect create vault AWS <vault-name> \
--bucket <bucket-name> \
--secret <secret-name> \
--endpoint <s3-endpoint> \
--data-mover-password-secret-ref <my-optional-data-mover-secret> \
-n trident-protect
tridentctl-protect create vault Azure <vault-name> \
--account <account-name> \
--bucket <bucket-name> \
--secret <secret-name> \
--data-mover-password-secret-ref <my-optional-data-mover-secret> \
-n trident-protect
tridentctl-protect create vault GenericS3 <vault-name> \
--bucket <bucket-name> \
--secret <secret-name> \
--endpoint <s3-endpoint> \
--data-mover-password-secret-ref <my-optional-data-mover-secret> \
-n trident-protect
tridentctl-protect create vault OntapS3 <vault-name> \
--bucket <bucket-name> \
--secret <secret-name> \
--endpoint <s3-endpoint> \
--data-mover-password-secret-ref <my-optional-data-mover-secret> \
-n trident-protect
tridentctl-protect create vault StorageGridS3 <vault-name> \
--bucket <bucket-name> \
--secret <secret-name> \
--endpoint <s3-endpoint> \
--data-mover-password-secret-ref <my-optional-data-mover-secret> \
-n trident-protect
查看AppVault信息
您可以使用Trident Protect CLI 插件查看有关您在集群上创建的 AppVault 对象的信息。
-
查看AppVault对象的内容:
tridentctl-protect get appvaultcontent gcp-vault \ --show-resources all \ -n trident-protect示例输出:
+-------------+-------+----------+-----------------------------+---------------------------+ | CLUSTER | APP | TYPE | NAME | TIMESTAMP | +-------------+-------+----------+-----------------------------+---------------------------+ | | mysql | snapshot | mysnap | 2024-08-09 21:02:11 (UTC) | | production1 | mysql | snapshot | hourly-e7db6-20240815180300 | 2024-08-15 18:03:06 (UTC) | | production1 | mysql | snapshot | hourly-e7db6-20240815190300 | 2024-08-15 19:03:06 (UTC) | | production1 | mysql | snapshot | hourly-e7db6-20240815200300 | 2024-08-15 20:03:06 (UTC) | | production1 | mysql | backup | hourly-e7db6-20240815180300 | 2024-08-15 18:04:25 (UTC) | | production1 | mysql | backup | hourly-e7db6-20240815190300 | 2024-08-15 19:03:30 (UTC) | | production1 | mysql | backup | hourly-e7db6-20240815200300 | 2024-08-15 20:04:21 (UTC) | | production1 | mysql | backup | mybackup5 | 2024-08-09 22:25:13 (UTC) | | | mysql | backup | mybackup | 2024-08-09 21:02:52 (UTC) | +-------------+-------+----------+-----------------------------+---------------------------+
-
(可选)要查看每个资源的AppVaultPath,请使用标志
--show-paths。只有在Trident Protect helm 安装中指定了集群名称时,表格第一列中的集群名称才可用。例如:
--set clusterName=production1。
删除AppVault
您可以随时删除AppVault对象。
|
|
在删除AppVault对象之前、请勿 `finalizers`删除AppVault CR中的密钥。如果这样做、可能会导致AppVault存储分段中有残留数据、集群中会出现孤立资源。 |
确保已删除要删除的AppVault正在使用的所有快照和备份CRS。
-
删除AppVault对象、替换 `appvault-name`为要删除的AppVault对象的名称:
kubectl delete appvault <appvault-name> \ -n trident-protect
-
删除AppVault对象、替换 `appvault-name`为要删除的AppVault对象的名称:
tridentctl-protect delete appvault <appvault-name> \ -n trident-protect