次の方法で共有


Create Kubernetes clusters using Bicep

This article describes how to create Kubernetes clusters in Azure Local using Bicep. The workflow is as follows:

  1. Create an SSH key pair
  2. Create a Kubernetes cluster in Azure Local using Bicep. By default, the cluster is Azure Arc-connected.
  3. Validate the deployment and connect to the cluster.

Before you begin

Before you begin, make sure you have the following prerequisites:

  1. Get the following details from your on-premises infrastructure administrator:

    • Azure subscription ID: the Azure subscription ID that uses Azure Local for deployment and registration.
    • Custom location name or ID: the Azure Resource Manager ID of the custom location. The custom location is configured during the Azure Local cluster deployment. Your infrastructure admin should give you the Resource Manager ID of the custom location. This parameter is required in order to create Kubernetes clusters. You can also get the Resource Manager ID using az customlocation show --name "<custom location name>" --resource-group <azure resource group> --query "id" -o tsv, if the infrastructure admin provides a custom location name and resource group name.
    • Logical network name or ID: the Azure Resource Manager ID of the Azure Local logical network that was created following these steps. Your admin should give you the ID of the logical network. This parameter is required in order to create Kubernetes clusters. You can also get the Azure Resource Manager ID using az stack-hci-vm network lnet show --name "<lnet name>" --resource-group <azure resource group> --query "id" -o tsv if you know the resource group in which the logical network was created.
  2. Make sure you have the latest version of Azure CLI on your development machine. You can also upgrade your Azure CLI version using az upgrade.

  3. Download and install kubectl on your development machine. The Kubernetes command-line tool, kubectl, enables you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.

Create an SSH key pair

Azure で SSH キー ペアを作成し、トラブルシューティングとログ収集のために秘密キー ファイルを格納します。 詳細な手順については、「Azure CLI を使用した SSH キーの作成と格納」または「Azure portal」を参照してください。

  1. Web ブラウザーで Cloud Shell セッション を開くか、ローカル コンピューターでターミナルを起動します。

  2. az sshkey create コマンドを使用して SSH キー ペアを作成します。

    az sshkey create --name "mySSHKey" --resource-group $<resource_group_name>
    

    または、ssh-keygen コマンドを使用します。

    ssh-keygen -t rsa -b 4096 
    
  3. Azure またはローカル コンピューターの /.ssh/id_rsa.pub から公開キーの値を取得します。

その他のオプションについては、「AKS クラスター の SSH キーを構成する」に従って SSH キーを作成するか、クラスターの作成時に SSH アクセス を制限するを使用します。 後でノードにアクセスするには、「SSHを使用して Windows または Linux ワーカー ノードに接続する」を参照してください。

Bicep スクリプトをダウンロードして更新する

Bicep デプロイ用の AKSArc GitHub リポジトリ から、main.bicep aksarc.bicepparamの 2 つのファイルをダウンロードします。 main.bicep のすべてのデフォルト値 が正しいことを確認し、必要に応じて aksarc.bicepparam からパラメーターを更新します。

The Microsoft.HybridContainerService/provisionedClusterInstances resource type is defined in main.bicep. クラスター作成用にさらにプロパティをカスタマイズする場合は、provisionedClusterInstances API リファレンスを参照してください。

Bicep テンプレートをデプロイする

Create a Bicep deployment using Azure CLI:

az deployment group create --name BicepDeployment --resource-group <Resource_Group_Name> --parameters aksarc.bicepparam

デプロイを検証し、クラスターに接続する

開発用コンピューターからコマンド az connectedk8s proxy 実行して、Kubernetes クラスターに接続できるようになりました。 You can also use kubectl to see the node and pod status. Follow the same steps as described in Connect to the Kubernetes cluster.

Next steps

Create Kubernetes clusters using Azure CLI