共用方式為


使用受控識別

使用Microsoft Entra 受控識別,為 Azure CycleCloud 授與管理訂用帳戶中叢集的許可權。 此方法可作為使用 服務主體的替代方案。 將受控識別指派給 CycleCloud VM,以提供記憶體、Key Vault 或 Azure 容器登錄等 Azure 資源的存取權。

使用管理式身分識別的 CycleCloud 的 VM 許可權

CycleCloud 會將對 Azure Resource Manager 的許多呼叫自動化,以管理 HPC 叢集。 此自動化需要 CycleCloud 的特定許可權。 您可以藉由設定服務主體或將 受控識別 指派給 CycleCloud VM,為 CycleCloud 提供此存取權。

我們建議使用 系統指派User-Assigned 受控識別 來授與這些許可權,而不是服務主體。

當您在 Azure VM 上安裝 Azure CycleCloud 並將受控識別指派給 VM 時, [新增訂 用帳戶] 對話框的運作方式稍有不同。 對話框會啟用並預先選取 受控識別 驗證選項。 它也會在訂用帳戶識別碼中填入主機 VM 的訂用帳戶。

新增訂用帳戶受控識別

新增訂用帳戶受控識別

您仍然可以選取 [ 應用程式註冊 驗證] 選項來輸入標準組認證。 當您選取此選項時,標準欄位會出現在表單中。 您也可以使用不同的訂用帳戶 標識碼;所提供的值只是為了方便起見。

當您使用系統指派的受控識別時,請將 ClientID 字段保留空白。 但是,當您使用 CycleCloud 搭配使用者指派的受控識別,請將 ClientID 設定為叢集協調流程需要的特定受控識別的 ClientID。

記憶體保險箱存取

除了在 CycleCloud VM 上使用叢集協調流程的受控識別之外,您還可以設定 CycleCloud 將使用者指派的受控識別指派給叢集,以便從叢集節點存取記憶體帳戶和保險箱存取。 此方法會使用使用者指派的受控識別,而不是衍生自記憶體帳戶共用存取密鑰的 SAS 令牌。

若要將叢集設定為使用使用者指派的受控識別,而不是共用存取密鑰,請在記憶體帳戶範圍建立具有 記憶體 Blob 資料讀取器 存取權的專用使用者指派受控識別。 首先,在 Azure 訂用帳戶中建立記憶體帳戶和使用者指派的受控識別。 然後,在 [新增訂用帳戶] 對話方塊的 [記憶體保險箱組態] 區段中,從 [保險箱身分識別] 下拉式清單中選取新的受控識別,並從 [記憶體帳戶] 下拉式清單中選取記憶體帳戶。

建立 CycleCloud 的自訂角色和受控識別

提供足夠訪問許可權的最簡單選項是將訂用帳戶的 ContributorStorage Blob Data Contributor 角色指派給 CycleCloud VM 作為系統指派的受控識別。 不過, Contributor 角色的許可權等級高於 CycleCloud 所需的許可權等級。 您可以建立 自定義角色 並將其指派給 VM。 同樣地,如果您已建立儲存體帳戶,請在儲存體帳戶範圍 (而不是訂用帳戶範圍) 指派 Storage Blob Data Contributor 角色。

此角色涵蓋所有 CycleCloud 功能:

{
    "assignableScopes": [
      "/subscriptions/<SubscriptionId>"
    ],
    "description": "CycleCloud Orchestrator Role",
    "permissions": [
      {
        "actions": [
          "Microsoft.Authorization/*/read",
          "Microsoft.Authorization/roleAssignments/*",
          "Microsoft.Authorization/roleDefinitions/*",
          "Microsoft.Commerce/RateCard/read",
          "Microsoft.Compute/*/read",
          "Microsoft.Compute/availabilitySets/*",
          "Microsoft.Compute/disks/*",
          "Microsoft.Compute/images/read",
          "Microsoft.Compute/locations/usages/read",
          "Microsoft.Compute/register/action",
          "Microsoft.Compute/skus/read",
          "Microsoft.Compute/virtualMachines/*",
          "Microsoft.Compute/virtualMachineScaleSets/*",
          "Microsoft.Compute/virtualMachineScaleSets/virtualMachines/*",
          "Microsoft.ManagedIdentity/userAssignedIdentities/*/read",
          "Microsoft.ManagedIdentity/userAssignedIdentities/*/assign/action",
          "Microsoft.MarketplaceOrdering/offertypes/publishers/offers/plans/agreements/read",
          "Microsoft.MarketplaceOrdering/offertypes/publishers/offers/plans/agreements/write",
          "Microsoft.Network/*/read",
          "Microsoft.Network/locations/*/read",
          "Microsoft.Network/networkInterfaces/read",
          "Microsoft.Network/networkInterfaces/write",
          "Microsoft.Network/networkInterfaces/delete",
          "Microsoft.Network/networkInterfaces/join/action",
          "Microsoft.Network/networkSecurityGroups/read",
          "Microsoft.Network/networkSecurityGroups/write",
          "Microsoft.Network/networkSecurityGroups/delete",
          "Microsoft.Network/networkSecurityGroups/join/action",
          "Microsoft.Network/publicIPAddresses/read",
          "Microsoft.Network/publicIPAddresses/write",
          "Microsoft.Network/publicIPAddresses/delete",
          "Microsoft.Network/publicIPAddresses/join/action",
          "Microsoft.Network/register/action",
          "Microsoft.Network/virtualNetworks/read",
          "Microsoft.Network/virtualNetworks/subnets/read",
          "Microsoft.Network/virtualNetworks/subnets/join/action",
          "Microsoft.Resources/deployments/read",
          "Microsoft.Resources/subscriptions/resourceGroups/read",
          "Microsoft.Resources/subscriptions/resourceGroups/write",
          "Microsoft.Resources/subscriptions/resourceGroups/delete",
          "Microsoft.Resources/subscriptions/resourceGroups/resources/read",
          "Microsoft.Resources/subscriptions/operationresults/read",
          "Microsoft.Storage/*/read",
          "Microsoft.Storage/checknameavailability/read",
          "Microsoft.Storage/register/action",
          "Microsoft.Storage/storageAccounts/blobServices/containers/delete",
          "Microsoft.Storage/storageAccounts/blobServices/containers/read",
          "Microsoft.Storage/storageAccounts/blobServices/containers/write",
          "Microsoft.Storage/storageAccounts/blobServices/generateUserDelegationKey/action",
          "Microsoft.Storage/storageAccounts/read",
          "Microsoft.Storage/storageAccounts/listKeys/action",
          "Microsoft.Storage/storageAccounts/write"
        ],
        "dataActions": [
          "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/delete",
          "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read",
          "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write",
          "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/move/action",
          "Microsoft.Storage/storageAccounts/blobServices/containers/blobs/add/action"
        ],
        "notActions": [],
        "notDataActions": []
      }
    ],
    "Name": "CycleCloud <SubscriptionId>",
    "roleType": "CustomRole",
    "type": "Microsoft.Authorization/roleDefinitions"
}

請務必以您的訂用帳戶識別碼取代 <SubscriptionId> 。 您可以將此角色的範圍設定為訂閱,也可以根據需要將範圍限定為單一資源群組。 名稱對租使用者而言必須是唯一的。

這很重要

若要使用自定義角色,您需要Microsoft Entra ID P1 授權。 如需授權的詳細資訊,請參閱 Microsoft Entra 方案和定價

選用權限

如果您要將 CycleCloud 的範圍設定為針對每個叢集使用單一資源群組,您可以從 中移除下列許可權 actions

          "Microsoft.Resources/subscriptions/resourceGroups/write",
          "Microsoft.Resources/subscriptions/resourceGroups/delete",

如果您未使用 CycleCloud 將受控識別指派給它在叢集內建立的 VM,您可以從 中移除下列許可權 actions

          "Microsoft.Authorization/*/read",
          "Microsoft.Authorization/roleAssignments/*",
          "Microsoft.Authorization/roleDefinitions/*",

警告

未來的 CycleCloud 版本需要能夠將受控識別指派給 VM。 我們不建議移除這些許可權。

建立角色

您可以使用 Azure CLI,從角色定義建立角色。 使用此角色在 Azure 租戶內建立角色定義。 當角色存在於租用戶中時,將角色指派給具有適當範圍的身分識別。

下列範例示範使用 Azure CLI 的基本流程。

# Create a custom role definition
az role definition create --role-definition role.json
# Create user identity
az identity create --name <name>
# Assign the custom role to the identity with proper scope
az role assignment create --role <CycleCloudRole> --assignee-object-id <identity-id> --scope <subscription>

現在,自訂角色已指派並限定於身分識別。 您可以將它與 VM 搭配使用。

使用受控識別將角色指派給叢集 VM

叢集節點通常需要存取 Azure 資源。 例如,許多叢集需要存取 Azure 記憶體、Key Vault 或 Azure 容器登錄,才能執行其工作負載。 強烈建議使用 User-Assigned 受控識別 來提供存取認證,而不是透過叢集組態將秘密或認證傳遞至節點。

您可以使用 node 屬性,在叢集 VM Azure.Identities 上設定使用者指派的受控識別。 將 Azure.Identities 屬性設定為受控識別資源識別字串的逗號分隔清單:

[cluster sample]
...
    [[node defaults]]
    ...
    Azure.Identities = $ManagedServiceIdentity
...

[parameters Required Settings]
...
  [[parameter ManagedServiceIdentity]]
  ParameterType = Azure.ManagedIdentity
  Label = MSI Identity
  Description = The resource ID of the Managed Service Identity to apply to the nodes
...