使用Trident Protect AppVault 对象来管理存储桶。
Trident Protect 的存储桶自定义资源 (CR) 被称为 AppVault。AppVault 对象是存储桶的声明性 Kubernetes 工作流表示。AppVault CR 包含存储桶在保护操作(例如备份、快照、恢复操作和SnapMirror复制)中使用的必要配置。只有管理员才能创建应用保险库。
在对应用程序执行数据保护操作时,您需要手动或使用命令行创建 AppVault CR,并且 AppVault CR 需要位于安装了Trident Protect 的集群上。 AppVault CR 是针对您的环境的;您可以参考此页面上的示例来创建 AppVault CR。
配置AppVault身份验证和密码
在创建AppVault CR之前、您需要确保所选的AppVault和数据移动工具可以向提供程序和任何相关资源进行身份验证。
数据移动工具存储库密码
当您使用 CR 或Trident Protect CLI 插件创建 AppVault 对象时,您可以选择性地指示Trident Protect 使用包含 Restic 和 Kopia 存储库加密自定义密码的 Kubernetes secret。如果您不指定密钥, Trident Protect 将使用默认密码。
-
手动创建 AppVault CR 时,使用 spec.dataMoverPasswordSecretRef 字段指定密钥。
-
使用Trident Protect CLI 创建 AppVault 对象时,请使用 `--data-mover-password-secret-ref`用于指定密钥的参数。
创建数据移动工具存储库密码密钥
请参考以下示例创建密码密钥。创建 AppVault 对象时,您可以指示Trident Protect 使用此密钥向数据移动器存储库进行身份验证。
|
|
根据所使用的数据移动工具、您只需包含该数据移动工具的相应密码即可。例如、如果您正在使用Restic、并且将来不打算使用KONIA、则在创建密钥时只能包含Restic密码。 |
---
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 文档" 。
云提供商的AppVault密钥生成示例
定义AppVault CR时、您需要包含凭据才能访问由提供程序托管的资源。根据提供程序的不同、为凭据生成密钥的方式也会有所不同。以下是多个提供程序的命令行密钥生成示例。您可以使用以下示例为每个云提供商的凭据创建密钥。
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
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