Skip to main content
本繁體中文版使用機器翻譯,譯文僅供參考,若與英文版本牴觸,應以英文版本為準。

使用 Trident Protect AppVault 物件來管理貯體

貢獻者 netapp-mwallis netapp-shwetav

Trident Protect 的貯體自訂資源( CR )稱為 AppVault 。AppVault 物件是儲存貯體的宣告性 Kubernetes 工作流程表示。AppVault CR 包含用於保護作業(例如備份,快照,還原作業和 SnapMirror 複寫)的儲存庫所需的組態。只有管理員可以建立 AppVaults 。

在應用程式上執行資料保護操作時,您需要手動或從命令列建立 AppVault CR。 AppVaultCR 特定於您的環境,您可以使用本頁上的範例作為建立 AppVault CR 的指南。

註 確保 AppVault CR 位於安裝了Trident Protect 的叢集上。如果 AppVault CR 不存在或您無法訪問,命令列將顯示錯誤。

設定 AppVault 驗證和密碼

在建立 AppVault CR 之前,請確保您選擇的 AppVault 和資料移動器可以向提供者和任何相關資源進行驗證。

資料移動器儲存庫密碼

使用 CR 或Trident Protect CLI 外掛程式建立 AppVault 物件時,您可以指定 Kubernetes 金鑰,並使用自訂密碼進行 Restic 和 Kopia 加密。如果您未指定金鑰, Trident Protect 將使用預設密碼。

  • 手動建立 AppVault CR 時,使用 spec.dataMoverPasswordSecretRef 欄位指定金鑰。

  • 使用 Trident Protect CLI 建立 AppVault 物件時,使用 `--data-mover-password-secret-ref`參數來指定秘密。

建立資料移動者儲存庫密碼機密

請使用下列範例建立密碼機密。當您建立 AppVault 物件時,可以指示 Trident Protect 使用此密碼來驗證資料移動器儲存庫。

註
  • 視您使用的資料移動器而定,您只需要加入該資料移動器的對應密碼。例如,如果您使用 Restic ,而且不打算在未來使用 Kopia ,則在建立機密時,只能包含 Restic 密碼。

  • 請將密碼保存在安全的地方。您將需要它來還原同一叢集或其他叢集上的資料。如果集群或 `trident-protect`命名空間被刪除後,沒有密碼您將無法還原備份或快照。

使用 CR
---
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
使用CLI
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、Generic S3)時, "StorageGRID S3" , 或者 "ONTAP S3"使用 Trident 保護時,您需要確保您提供的使用者憑證具有存取儲存桶所需的權限。以下是一個策略範例,該策略授予使用 Trident 保護存取所需的最低權限。您可以將此策略套用至管理與 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 支援 EKS Pod Identity 進行 Kopia 資料移動器操作。此功能可實現對 S3 儲存桶的安全訪問,而無需將 AWS 憑證儲存在 Kubernetes 機密中。

帶有Trident保護的 EKS Pod Identity 的要求

在使用具有Trident保護的 EKS Pod Identity 之前,請確保以下事項:

  • 您的 EKS 叢集已啟用 Pod Identity。

  • 您已建立具有必要的 S3 儲存桶權限的 IAM 角色。要了解更多信息,請參閱"S3 相容於儲存 IAM 權限"

  • IAM 角色與下列Trident保護服務帳戶相關聯:

    • <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 驗證。如何產生憑證金鑰將根據提供者的不同而有所不同。以下是幾個提供者的命令列金鑰產生範例。您可以使用下列範例為每個雲端提供者的憑證建立金鑰。

Google Cloud
kubectl create secret generic <secret-name> \
--from-file=credentials=<mycreds-file.json> \
-n trident-protect
Amazon S3 ( AWS )
kubectl create secret generic <secret-name> \
--from-literal=accessKeyID=<objectstorage-accesskey> \
--from-literal=secretAccessKey=<amazon-s3-trident-protect-src-bucket-secret> \
-n trident-protect
Microsoft Azure
kubectl create secret generic <secret-name> \
--from-literal=accountKey=<secret-name> \
-n trident-protect
一般S3
kubectl create secret generic <secret-name> \
--from-literal=accessKeyID=<objectstorage-accesskey> \
--from-literal=secretAccessKey=<generic-s3-trident-protect-src-bucket-secret> \
-n trident-protect
ONTAP S3
kubectl create secret generic <secret-name> \
--from-literal=accessKeyID=<objectstorage-accesskey> \
--from-literal=secretAccessKey=<ontap-s3-trident-protect-src-bucket-secret> \
-n trident-protect
StorageGRID S3
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 物件。

註
  • 您可以選擇性地指定 Kubernetes 機密,其中包含 Restic 和 Kopia 儲存庫加密的自訂密碼。如需詳細資訊、請參閱 資料移動器儲存庫密碼

  • 對於 Amazon S3 ( AWS ) AppVault 物件,您可以選擇性地指定一個工作區權杖,如果您使用單一登入( SSO )進行驗證,這會很有用。當您在中為提供者產生金鑰時適用於雲端供應商的 AppVault 主要世代範例,就會建立此權杖。

  • 對於 S3 AppVault 物件,您可以選擇使用金鑰來指定傳出 S3 流量的外傳 Proxy URL spec.providerConfig.S3.proxyURL

Google Cloud
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
Amazon S3 ( AWS )
---
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`配置。
Microsoft Azure
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
一般S3
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
ONTAP S3
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
StorageGRID S3
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 範例

您可以使用下列 CLI 命令範例,為每個供應商建立 AppVault CRS 。

註
  • 您可以選擇性地指定 Kubernetes 機密,其中包含 Restic 和 Kopia 儲存庫加密的自訂密碼。如需詳細資訊、請參閱 資料移動器儲存庫密碼

  • 對於 S3 AppVault 物件,您可以選擇使用引數,為輸出 S3 流量指定外傳 Proxy URL --proxy-url <ip_address:port>

Google Cloud
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
Amazon S3 ( AWS )
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
Microsoft Azure
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
一般S3
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
ONTAP S3
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
StorageGRID S3
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 物件相關資訊。

步驟
  1. 檢視 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) |
    +-------------+-------+----------+-----------------------------+---------------------------+
  2. (可選)要查看每個資源的 AppVaultPath ,請使用標誌 --show-paths

    只有在 Trident Protect helm 安裝中指定叢集名稱時,表格第一欄中的叢集名稱才能使用。例如 --set clusterName=production1:。

移除 AppVault

您可以隨時移除 AppVault 物件。

註 刪除 AppVault 物件之前,請勿移除 finalizers AppVault CR 中的機碼。如果您這麼做,可能會導致 AppVault 貯體中的剩餘資料,以及叢集中的孤立資源。
開始之前

請確定您已刪除要刪除的 AppVault 所使用的所有快照和備份 CRS 。

使用 Kubernetes CLI 移除 AppVault
  1. 移除 AppVault 物件,以要移除的 AppVault 物件名稱取代 appvault-name

    kubectl delete appvault <appvault-name> \
    -n trident-protect
使用 Trident Protect CLI 移除 AppVault
  1. 移除 AppVault 物件,以要移除的 AppVault 物件名稱取代 appvault-name

    tridentctl-protect delete appvault <appvault-name> \
    -n trident-protect