使用 Azure 備份來管理 Azure Kubernetes Service 備份

本文說明如何在您的訂用帳戶上註冊資源提供者,以使用備份擴充功能和信任存取。 此外,其也提供 Azure CLI 命令對其進行管理。

Azure 備份現在可讓您使用必須安裝在叢集中的備份擴充功能來備份 AKS 叢集 (叢集資源和連結至叢集的永續性磁碟區)。 AKS 叢集需要啟用備份保存庫的信任存取權,讓保存庫可以與備份擴充功能進行通訊,以執行備份和還原作業。

資源提供者註冊

  • 您必須先在訂用帳戶上註冊這些資源提供者,才能起始任何備份和還原作業。
  • 註冊完成後,您即可在訂用帳戶下的所有叢集上執行備份和還原作業。

註冊備份擴充功能

若要安裝備份擴充功能,您必須在訂用帳戶上註冊 Microsoft.KubernetesConfiguration 資源提供者。 若要執行註冊,請執行下列命令:

az provider register --namespace Microsoft.KubernetesConfiguration

註冊最多可能需要 10 分鐘的時間。 若要監視註冊程序,請執行下列命令:

az provider show --name Microsoft.KubernetesConfiguration --output table

本節提供一組 Azure CLI 命令,可在備份擴充功能上執行建立、更新或刪除作業。 您可以使用 update 命令來變更基礎備份擴充功能 Pod 的計算限制。

安裝備份擴充功能

若要安裝備份擴充功能,請執行下列命令:

az k8s-extension create --name azure-aks-backup --extension-type microsoft.dataprotection.kubernetes --scope cluster --cluster-type managedClusters --cluster-name <aksclustername> --resource-group <aksclusterrg> --release-train stable --configuration-settings blobContainer=<containername> storageAccount=<storageaccountname> storageAccountResourceGroup=<storageaccountrg> storageAccountSubscriptionId=<subscriptionid>

檢視備份擴充功能安裝狀態

若要檢視備份擴充功能安裝進度,請使用下列命令:

az k8s-extension show --name azure-aks-backup --cluster-type managedClusters --cluster-name <aksclustername> --resource-group <aksclusterrg>

更新備份擴充功能中的資源

若要更新備份擴充功能中的 Blob 容器、CPU 和記憶體,請使用下列命令:

az k8s-extension update --name azure-aks-backup --cluster-type managedClusters --cluster-name <aksclustername> --resource-group <aksclusterrg> --release-train stable --configuration-settings [blobContainer=<containername> storageAccount=<storageaccountname> storageAccountResourceGroup=<storageaccountrg> storageAccountSubscriptionId=<subscriptionid>] [cpuLimit=1] [memoryLimit=1Gi]

[]: denotes the 3 different sub-groups of updates possible (discard the brackets while using the command)

刪除備份擴充功能安裝作業

若要停止備份擴充功能安裝作業,請使用下列命令:

az k8s-extension delete --name azure-aks-backup --cluster-type managedClusters --cluster-name <aksclustername> --resource-group <aksclusterrg>

授與儲存體帳戶的權限

若要為儲存體帳戶上的擴充功能身分識別提供儲存體帳戶參與者權限,請執行下列命令:

az role assignment create --assignee-object-id $(az k8s-extension show --name azure-aks-backup --cluster-name <aksclustername> --resource-group <aksclusterrg> --cluster-type managedClusters --query aksAssignedIdentity.principalId --output tsv) --role 'Storage Blob Data Contributor' --scope /subscriptions/<subscriptionid>/resourceGroups/<storageaccountrg>/providers/Microsoft.Storage/storageAccounts/<storageaccountname> 

若要啟用備份保存庫與 AKS 叢集之間的信任存取,請使用下列 Azure CLI 命令:

az aks trustedaccess rolebinding create \
--resource-group <aksclusterrg> \
--cluster-name <aksclustername> \
--name <randomRoleBindingName> \
--source-resource-id $(az dataprotection backup-vault show --resource-group <vaultrg> --vault <VaultName> --query id -o tsv) \
--roles Microsoft.DataProtection/backupVaults/backup-operator   

深入了解與信任存取相關的其他命令

監視 AKS 作業已完成,但出現警告

執行排程或隨選備份或還原作業時,會建立一個作業 (job) 來對應至作業以追蹤其進度。 如果失敗,這些作業可讓您識別錯誤碼並修正問題,以便稍後執行成功的作業。

針對 AKS 備份,備份與還原作業可以顯示狀態 [已完成,但出現警告]。 當備份與還原作業因使用者定義組態或工作負載內部狀態的問題而無法完全成功時,就會顯示此狀態。

顯示備份與還原作業已完成,但出現警告的螢幕擷取畫面。

例如,如果 AKS 叢集的備份作業完成,且狀態為 [已完成,但出現警告],則會建立還原點,但可能無法根據備份組態備份叢集中的所有資源。 作業會顯示警告詳細資料,並提供作業期間受影響的問題資源

若要檢視這些警告,請選取 [警告詳細資料] 旁的 [檢視詳細資料]

顯示作業警告詳細資料的螢幕擷取畫面。

了解如何識別並解決錯誤

下一步