次の方法で共有


Azure Stack Edge Pro GPU デバイス上の Kubernetes クラスターで Azure Arc を有効にする

適用対象:はい (Pro GPU SKU の場合)Azure Stack Edge Pro - GPUはい (Pro 2 SKU の場合)Azure Stack Edge Pro 2はい (Pro R SKU の場合)Azure Stack Edge Pro Rはい (Mini R SKU の場合)Azure Stack Edge Mini R

この記事では、Azure Stack Edge Pro デバイス上の既存の Kubernetes クラスターで Azure Arc を有効にする方法について説明します。

この手順では、次の記事を読んで理解していることを前提としています。

前提条件

Azure Stack Edge Pro デバイスと、デバイスへのアクセスに使用するクライアントで次の前提条件が満たされていることを確認してください。

デバイスでは

  1. 1 ノードの Azure Stack Edge Pro デバイスに対するサインイン資格情報がある。

    1. デバイスがアクティブ化されている。 デバイスをアクティブにするに関する記事を参照してください。
    2. デバイスに、Azure portal を使用して構成されたコンピューティング ロールがあり、Kubernetes クラスターがある。 コンピューティングの構成に関する記事を参照してください。
  2. サブスクリプションへの所有者アクセス権を持っている。 サービス プリンシパルのロールの割り当て手順でこのアクセス権が必要になります。

デバイスにアクセスするクライアントの場合

  1. Azure Stack Edge Pro デバイスへのアクセスに使用される Windows クライアント システムがある。

  2. Azure Stack Edge Pro デバイス上の Kubernetes クラスターへのアクセスに関する記事で説明されている手順を完了している。 完了した内容:

    • クライアントに kubectl がインストールされている。
    • kubectl クライアントのバージョンと、Azure Stack Edge Pro デバイスで実行されている Kubernetes マスターのバージョンの差が 1 未満であることを確認する。
      • クライアントで実行されている kubectl のバージョンを確認するには、kubectl version を使用します。 完全なバージョンをメモしておきます。

      • Azure Stack Edge Pro デバイスのローカル UI で、[ソフトウェア更新プログラム] に移動し、Kubernetes サーバーのバージョン番号をメモします。

        Kubernetes サーバーのバージョン番号の確認のスクリーンショット。

      • これら 2 つのバージョンに互換性があることを確認します。

Kubernetes リソース プロバイダーを登録する

Kubernetes クラスターで Azure Arc を有効にする前に、サブスクリプションに対して Microsoft.KubernetesMicrosoft.KubernetesConfiguration を有効にして登録する必要があります。

  1. リソース プロバイダーを有効にするには、Azure portal で、デプロイに使用する予定のサブスクリプションに移動します。 [リソース プロバイダー] に移動します。

  2. 右側のペインで、追加するプロバイダーを検索します。 この例では、Microsoft.KubernetesMicrosoft.KubernetesConfiguration です。

    Kubernetes リソース プロバイダーの登録のスクリーンショット。

  3. リソース プロバイダーを選択し、コマンド バーの上部から [登録] を選択します。 登録には数分かかります。

    Kubernetes リソース プロバイダーの登録 2 のスクリーンショット。

  4. リソース プロバイダーが登録されていることがわかるまで、UI を最新の情報に更新します。 両方のリソース プロバイダーに対してこのプロセスを繰り返します。

    Kubernetes リソース プロバイダー登録のスクリーンショット 3。

az cli を使用してリソース プロバイダーを登録することもできます。 詳細については、「Azure Arc 対応 Kubernetes 用の 2 つのプロバイダーを登録する」を参照してください。

サービス プリンシパルの作成、ロールの割り当て

  1. Azure Stack Edge サービスのリソースのデプロイに使用した Subscription ID とリソース グループの名前があることを確認します。 サブスクリプション ID を取得するには、Azure portal で Azure Stack Edge リソースに移動します。 [概要] > [基本] に移動します。

    サブスクリプション ID の取得のスクリーンショット。

    リソース グループ名を取得するには、[プロパティ] に移動します。

    リソース グループ名の取得のスクリーンショット。

  2. サービス プリンシパルを作成するには、az cli で次のコマンドを使用します。

    az ad sp create-for-rbac --name "<Informative name for service principal>"

    az cli にログインする方法については、Azure portal で Cloud Shell を開始する方法に関する記事を参照してください。 ローカル クライアントで az cli を使用してサービス プリンシパルを作成する場合は、バージョン 2.25 以降を実行していることを確認してください。

    次に例を示します。

    PS /home/user> az ad sp create-for-rbac --name "https://azure-arc-for-ase-k8s"
    {
      "appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "displayName": "azure-arc-for-ase-k8s",
      "name": "https://azure-arc-for-ase-k8s",
      "password": "<password>",
      "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    }
    PS /home/user>
    
  3. 次のコマンドの入力としてこれらの値を使用するため、appIdnamepassword、および tenantID をメモします。

    appIdを取得するには、いくつかの方法があります。 推奨される方法は、次の 3 つのオプションです。 次のいずれかのオプションを使用する場合は、前のセクションから手順 1、2、3 をスキップし、次の手順 4 に直接移動できます。

    • オプション 1 - ミニシェルを使用して、次の PowerShell コマンドレットを実行します。

      [Device-IP]: PS> Get-AzureDataBoxEdgeApplicationId
      xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
      [Device-IP]: PS>
      
    • オプション 2 - 次の手順を使用して、Azure portal でデバイスの JSON の詳細を表示します。

      1. Azure Stack Edge デバイスの 概要 に移動し、右上にある JSON ビュー を選択します。

        Azure Stack Edge デバイスの [概要] ページのスクリーンショット。

      2. デバイスの リソース JSON の詳細で、 principalIdをメモします。

        Azure Stack Edge デバイスの JSON の詳細を表示するスクリーンショット。

    • オプション 3 - クライアント コンピューターで Azure Stack Edge 以外の PowerShell を使用して、次のコマンドを実行します。

      // ASE resource group and resource name can be obtained from Azure portal
      PS C:\> $ASEResource= GetAzResource –ResourceGroupName <resource-group-name> -ResourceName <resource-name>
      PS C:\> $ASEResource.Identity.PrincipalId
      xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
      PS C:\>
      
  4. 新しいサービス プリンシパルを作成した後、またはこれらのオプションのいずれかを使用して取得した後、新しく作成したプリンシパルに Kubernetes Cluster - Azure Arc Onboarding ロールを割り当てます。 これは、アクセス許可が制限された組み込みの Azure ロールです (コマンドでロール ID を使用します)。 次のコマンドを使用します:

    az role assignment create --role 34e09817-6cbe-4d01-b1a2-e0eac5743d41 --assignee <appId-from-service-principal> --scope /subscriptions/<SubscriptionID>/resourceGroups/<Resource-group-name>

    次に例を示します。

    PS /home/user> az role assignment create --role 34e09817-6cbe-4d01-b1a2-e0eac5743d41 --assignee xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --scope /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myaserg1
    {
      "canDelegate": null,
      "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myaserg1/providers/Microsoft.Authorization/roleAssignments/00000000-0000-0000-0000-000000000000",
      "name": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "principalId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "principalType": "ServicePrincipal",
      "resourceGroup": "myaserg1",
      "roleDefinitionId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Authorization/roleDefinitions/34e09817-6cbe-4d01-b1a2-e0eac5743d41",
      "scope": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myaserg1",
      "type": "Microsoft.Authorization/roleAssignments"
    }
    PS /home/user>
    

Kubernetes クラスターで Arc を有効にする

Azure Arc 管理用に Kubernetes クラスターを構成するには、次の手順を実行します。

  1. デバイスの PowerShell インターフェイスに接続します

  2. 次のコマンドを実行します。

    Set-HcsKubernetesAzureArcAgent -SubscriptionId "<Your Azure Subscription Id>" -ResourceGroupName "<Resource Group Name>" -ResourceName "<Azure Arc resource name (shouldn't exist already)>" -Location "<Region associated with resource group>" -TenantId "<Tenant Id of service principal>" -ClientId "<App id of service principal>"

    このコマンドを実行すると、 ClientSecretを指定するためのフォローアップ プロンプトが表示されます。 プロンプトでサービス プリンシパルのパスワードを指定します。

    Azure パブリック以外のクラウドを使用している場合は、CloudEnvironment パラメーターを追加します。 このパラメーターは、AZUREPUBLICCLOUDAZURECHINACLOUDAZUREGERMANCLOUD、および AZUREUSGOVERNMENTCLOUD に設定できます。

    使用に関する考慮事項:

    • デバイスに Azure Arc をデプロイするには、 Azure Arc でサポートされているリージョンを使用していることを確認します。
    • az account list-locations コマンドを使用して、Set-HcsKubernetesAzureArcAgent コマンドレットで渡す正確な場所の名前を確認します。 場所の名前は通常、スペースなしの形式が使用されます。

    Important

    古いメソッドを使用して新しいサービス プリンシパルを作成する代わりに Id を取得する場合は、 ClientIdTenantId、または ClientSecretを指定しないでください。

    次に例を示します。

    [10.100.10.10]: PS>Set-HcsKubernetesAzureArcAgent -SubscriptionId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ResourceGroupName "myaserg1" -ResourceName "myasetestresarc" -Location "westeurope" -TenantId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ClientId "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
    
    WARNING: A script or application on the remote computer 10.126.76.0 is sending a prompt request. When you are prompted,
    enter sensitive information, such as credentials or passwords, only if you trust the remote computer and the
    application or script that is requesting the data.
    
    cmdlet Set-HcsKubernetesAzureArcAgent at command pipeline position 1
    
    Supply values for the following parameters:
    ClientSecret: **********************************
    [10.100.10.10]: PS>
    

    Azure portal で、前のコマンドで指定した名前でリソースを作成する必要があります。

    Azure Arc リソースに移動するスクリーンショット。

  3. Azure Arc が正常に有効になったことを確認するには、PowerShell インターフェイスから次のコマンドを実行します。

    kubectl get deployments,pods -n azure-arc

    これは、azure-arc 名前空間の Kubernetes クラスターに展開された Azure Arc エージェントを示すサンプル出力です。

    [10.128.44.240]: PS>kubectl get deployments,pods -n azure-arc
    NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
    deployment.apps/cluster-metadata-operator   1/1     1            1           13d
    deployment.apps/clusterconnect-agent        1/1     1            1           13d
    deployment.apps/clusteridentityoperator     1/1     1            1           13d
    deployment.apps/config-agent                1/1     1            1           13d
    deployment.apps/controller-manager          1/1     1            1           13d
    deployment.apps/extension-manager           1/1     1            1           13d
    deployment.apps/flux-logs-agent             1/1     1            1           13d
    deployment.apps/kube-aad-proxy              1/1     1            1           13d
    deployment.apps/metrics-agent               1/1     1            1           13d
    deployment.apps/resource-sync-agent         1/1     1            1           13d
    
    NAME                                            READY   STATUS    RESTARTS   AGE
    pod/cluster-metadata-operator-9568b899c-2stjn   2/2     Running   0          13d
    pod/clusterconnect-agent-576758886d-vggmv       3/3     Running   0          13d
    pod/clusteridentityoperator-6f59466c87-mm96j    2/2     Running   0          13d
    pod/config-agent-7cbd6cb89f-9fdnt               2/2     Running   0          13d
    pod/controller-manager-df6d56db5-kxmfj          2/2     Running   0          13d
    pod/extension-manager-58c94c5b89-c6q72          2/2     Running   0          13d
    pod/flux-logs-agent-6db9687fcb-rmxww            1/1     Running   0          13d
    pod/kube-aad-proxy-67b87b9f55-bthqv             2/2     Running   0          13d
    pod/metrics-agent-575c565fd9-k5j2t              2/2     Running   0          13d
    pod/resource-sync-agent-6bbd8bcd86-x5bk5        2/2     Running   0          13d
    [10.128.44.240]: PS>
    

これらのエージェントの概念の概要については、こちらを参照してください。

Kubernetes クラスターから Arc を削除する

Azure Arc 管理を削除するには、次の手順を実行します。

  1. デバイスの PowerShell インターフェイスに接続します

  2. 次のコマンドを実行します。

    Remove-HcsKubernetesAzureArcAgent

Note

既定では、リソース yamls が Git リポジトリから削除されると、対応するリソースは Kubernetes クラスターから削除されません。 Git リポジトリから削除したときにリソースが削除されるようにするには、Arc OperatorParams に --sync-garbage-collection を設定する必要があります。 詳細については、「構成を削除する」を参照してください。

次のステップ

Azure Arc デプロイを実行する方法については、「 Azure Stack Edge Pro デバイスで GitOps を使用して Redis を使用してステートレス PHP Guestbook アプリケーションをデプロイする」を参照してください。