Share via


クイック スタート: Azure Resource Manager テンプレートまたは Bicep ファイルを使用して Azure Red Hat OpenShift クラスターをデプロイする

このクイックスタートでは、Azure Resource Manager テンプレート (ARM テンプレート) または Bicep を使用して Azure Red Hat OpenShift クラスターを作成する方法を説明します。 PowerShell または Azure コマンド ライン インターフェイス (Azure CLI) のいずれかを使用して、Azure Red Hat OpenShift クラスターをデプロイできます。

Azure Resource Manager テンプレートは JavaScript Object Notation (JSON) ファイルであり、プロジェクトのインフラストラクチャと構成が定義されています。 このテンプレートでは、宣言型の構文が使用されています。 デプロイしようとしているものを、デプロイを作成する一連のプログラミング コマンドを記述しなくても記述できます。

Bicep は、宣言型の構文を使用して Azure リソースをデプロイするドメイン固有言語 (DSL) です。 Bicep ファイル内で、Azure にデプロイするインフラストラクチャを定義し、そのファイルを開発ライフサイクル全体にわたって使用して、インフラストラクチャを繰り返しデプロイします。 リソースは一貫した方法でデプロイされます。

前提条件

ARM テンプレートまたは Bicep ファイルを作成する

Azure Resource Manager テンプレート (ARM テンプレート) または Azure Bicep ファイルを選択します。 次に、Azure コマンド ライン (azure-cli) または PowerShell を使用してテンプレートをデプロイできます。

ARM テンプレートを使用する

次の例は、ARM テンプレートを Azure RedHat OpenShift クラスター用に構成すると、どのようになるかを示しています。

このテンプレートには、3 つの Azure リソースが定義されています:

Azure Red Hat OpenShift テンプレートのその他のサンプルについては、Red Hat OpenShift の Web サイトを参照してください。

次の例を azuredeploy.bicep として保存します:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "location" : {
        "type": "string",
        "defaultValue": "eastus",
        "metadata": {
          "description": "Location"
        }
      },
      "domain": {
          "type": "string",
          "defaultValue": "",
          "metadata": {
              "description": "Domain Prefix"
          }
      },
      "pullSecret": {
          "type": "string",
          "metadata": {
              "description": "Pull secret from cloud.redhat.com. The json should be input as a string"
          }
      },
      "clusterVnetName": {
          "type": "string",
          "defaultValue": "aro-vnet",
          "metadata": {
              "description": "Name of ARO vNet"
          }
      },
      "clusterVnetCidr": {
          "type": "string",
          "defaultValue": "10.100.0.0/15",
          "metadata": {
              "description": "ARO vNet Address Space"
          }
      },
      "workerSubnetCidr": {
          "type": "string",
          "defaultValue": "10.100.70.0/23",
          "metadata": {
              "description": "Worker node subnet address space"
          }
      },
      "masterSubnetCidr": {
          "type": "string",
          "defaultValue": "10.100.76.0/24",
          "metadata": {
              "description": "Master node subnet address space"
          }
      },
      "masterVmSize" : {
          "type": "string",
          "defaultValue": "Standard_D8s_v3",
          "metadata": {
              "description": "Master Node VM Type"
          }
      },
      "workerVmSize": {
          "type": "string",
          "defaultValue": "Standard_D4s_v3",
          "metadata": {
              "description": "Worker Node VM Type"
          }
      },
      "workerVmDiskSize": {
          "type" : "int",
          "defaultValue": 128,
          "minValue": 128,
          "metadata": {
              "description": "Worker Node Disk Size in GB"
          }
      },
      "workerCount": {
          "type": "int",
          "defaultValue": 3,
          "minValue": 3,
          "metadata": {
              "description": "Number of Worker Nodes"
          }
      },
      "podCidr": {
          "type": "string",
          "defaultValue": "10.128.0.0/14",
          "metadata": {
              "description": "Cidr for Pods"
          }
      },
      "serviceCidr": {
          "type": "string",
          "defaultValue": "172.30.0.0/16",
          "metadata": {
              "decription": "Cidr of service"
          }
      },
      "clusterName" : {
        "type": "string",
        "metadata": {
          "description": "Unique name for the cluster"
        }
      },
      "tags": {
          "type": "object",
          "defaultValue" : {
              "env": "Dev",
              "dept": "Ops"
          },
          "metadata": {
              "description": "Tags for resources"
          }
      },
      "apiServerVisibility": {
          "type": "string",
          "allowedValues": [
              "Private",
              "Public"
          ],
          "defaultValue": "Public",
          "metadata": {
              "description": "Api Server Visibility"
          }
      },
      "ingressVisibility": {
          "type": "string",
          "allowedValues": [
              "Private",
              "Public"
          ],
          "defaultValue": "Public",
          "metadata": {
              "description": "Ingress Visibility"
          }
      },
      "aadClientId" : {
        "type": "string",
        "metadata": {
          "description": "The Application ID of an Azure Active Directory client application"
        }
      },
      "aadObjectId": {
          "type": "string",
          "metadata": {
              "description": "The Object ID of an Azure Active Directory client application"
          }
      },
      "aadClientSecret" : {
        "type":"securestring",
        "metadata": {
          "description": "The secret of an Azure Active Directory client application"
        }
      },
      "rpObjectId": {
          "type": "String",
          "metadata": {
              "description": "The ObjectID of the Resource Provider Service Principal"
          }
      }
    },
    "variables": {
        "contribRole": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]"
    },
    "resources": [
        {
            "type": "Microsoft.Network/virtualNetworks",
            "apiVersion": "2020-05-01",
            "name": "[parameters('clusterVnetName')]",
            "location": "[parameters('location')]",
            "tags": "[parameters('tags')]",
            "properties": {
                "addressSpace": {
                "addressPrefixes": [
                    "[parameters('clusterVnetCidr')]"
                    ]
                },
                "subnets": [
                {
                    "name": "master",
                    "properties": {
                        "addressPrefix": "[parameters('masterSubnetCidr')]",
                        "serviceEndpoints": [
                            {
                                "service": "Microsoft.ContainerRegistry"
                            }
                        ],
                        "privateLinkServiceNetworkPolicies": "Disabled"
                    }
                },
                {
                    "name": "worker",
                    "properties": {
                        "addressPrefix": "[parameters('workerSubnetCidr')]",
                        "serviceEndpoints": [
                            {
                                "service": "Microsoft.ContainerRegistry"
                            }
                        ]
                    }
                }]
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/providers/roleAssignments",
            "apiVersion": "2018-09-01-preview",
            "name": "[concat(parameters('clusterVnetName'), '/Microsoft.Authorization/', guid(resourceGroup().id, deployment().name, parameters('aadObjectId')))]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', parameters('clusterVnetName'))]"
            ],
            "properties": {
                "roleDefinitionId": "[variables('contribRole')]",
                "principalId":"[parameters('aadObjectId')]"
            }
        },
        {
            "type": "Microsoft.Network/virtualNetworks/providers/roleAssignments",
            "apiVersion": "2018-09-01-preview",
            "name": "[concat(parameters('clusterVnetName'), '/Microsoft.Authorization/', guid(resourceGroup().id, deployment().name, parameters('rpObjectId')))]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', parameters('clusterVnetName'))]"
            ],
            "properties": {
                "roleDefinitionId": "[variables('contribRole')]",
                "principalId":"[parameters('rpObjectId')]"
            }
        },
        {
            "type": "Microsoft.RedHatOpenShift/OpenShiftClusters",
            "apiVersion": "2020-04-30",
            "name": "[parameters('clusterName')]",
            "location": "[parameters('location')]",
            "tags": "[parameters('tags')]",
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', parameters('clusterVnetName'))]"
            ],
            "properties": {
                "clusterProfile": {
                    "domain": "[parameters('domain')]",
                    "resourceGroupId": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/aro-', parameters('domain'))]",
                    "pullSecret": "[parameters('pullSecret')]"
                },
                "networkProfile": {
                    "podCidr": "[parameters('podCidr')]",
                    "serviceCidr": "[parameters('serviceCidr')]"
                },
                "servicePrincipalProfile": {
                    "clientId": "[parameters('aadClientId')]",
                    "clientSecret": "[parameters('aadClientSecret')]"
                },
                "masterProfile": {
                    "vmSize": "[parameters('masterVmSize')]",
                    "subnetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('clusterVnetName'), 'master')]"
                },
                "workerProfiles": [
                    {
                        "name": "worker",
                        "vmSize": "[parameters('workerVmSize')]",
                        "diskSizeGB": "[parameters('workerVmDiskSize')]",
                        "subnetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('clusterVnetName'), 'worker')]",
                        "count": "[parameters('workerCount')]"
                    }
                ],
                "apiserverProfile": {
                    "visibility": "[parameters('apiServerVisibility')]"
                },
                "ingressProfiles": [
                    {
                        "name": "default",
                        "visibility": "[parameters('ingressVisibility')]"
                    }
                ]
            }
        }
    ],
    "outputs": {
         "clusterCredentials": {
             "type": "object",
             "value": "[listCredentials(resourceId('Microsoft.RedHatOpenShift/OpenShiftClusters', parameters('clusterName')), '2020-04-30')]"
         },
         "oauthCallbackURL": {
             "type": "string",
             "value": "[concat('https://oauth-openshift.apps.', parameters('domain'), '.', parameters('location'), '.aroapp.io/oauth2callback/AAD')]"
         }
    }
}

Bicep ファイルを作成する

次の例は、Azure Bicep ファイルを Azure Red Hat OpenShift クラスター用に構成すると、どのようになるかを示しています。

Bicep ファイルには、3 つの Azure リソースが定義されています:

その他の Azure Red Hat OpenShift テンプレートについては、Red Hat OpenShift の Web サイトを参照してください。

Azure Red Hat OpenShift クラスターの定義を含む次の Bicep ファイルを作成します。 次の例は、Bicep ファイルを構成すると、どのようになるかを示しています。

次のファイルを azuredeploy.bicep として保存します。

@description('Location')
param location string = 'eastus'

@description('Domain Prefix')
param domain string = ''

@description('Pull secret from cloud.redhat.com. The json should be input as a string')
param pullSecret string

@description('Name of ARO vNet')
param clusterVnetName string = 'aro-vnet'

@description('ARO vNet Address Space')
param clusterVnetCidr string = '10.100.0.0/15'

@description('Worker node subnet address space')
param workerSubnetCidr string = '10.100.70.0/23'

@description('Master node subnet address space')
param masterSubnetCidr string = '10.100.76.0/24'

@description('Master Node VM Type')
param masterVmSize string = 'Standard_D8s_v3'

@description('Worker Node VM Type')
param workerVmSize string = 'Standard_D4s_v3'

@description('Worker Node Disk Size in GB')
@minValue(128)
param workerVmDiskSize int = 128

@description('Number of Worker Nodes')
@minValue(3)
param workerCount int = 3

@description('Cidr for Pods')
param podCidr string = '10.128.0.0/14'

@metadata({
  description: 'Cidr of service'
})
param serviceCidr string = '172.30.0.0/16'

@description('Unique name for the cluster')
param clusterName string

@description('Tags for resources')
param tags object = {
  env: 'Dev'
  dept: 'Ops'
}

@description('Api Server Visibility')
@allowed([
  'Private'
  'Public'
])
param apiServerVisibility string = 'Public'

@description('Ingress Visibility')
@allowed([
  'Private'
  'Public'
])
param ingressVisibility string = 'Public'

@description('The Application ID of an Azure Active Directory client application')
param aadClientId string

@description('The Object ID of an Azure Active Directory client application')
param aadObjectId string

@description('The secret of an Azure Active Directory client application')
@secure()
param aadClientSecret string

@description('The ObjectID of the Resource Provider Service Principal')
param rpObjectId string

@description('Specify if FIPS validated crypto modules are used')
@allowed([
  'Enabled'
  'Disabled'
])
param fips string = 'Disabled'

@description('Specify if master VMs are encrypted at host')
@allowed([
  'Enabled'
  'Disabled'
])
param masterEncryptionAtHost string = 'Disabled'

@description('Specify if worker VMs are encrypted at host')
@allowed([
  'Enabled'
  'Disabled'
])
param workerEncryptionAtHost string = 'Disabled'

var contributorRoleDefinitionId = resourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')
var resourceGroupId = '/subscriptions/${subscription().subscriptionId}/resourceGroups/aro-${domain}-${location}'
var masterSubnetId=resourceId('Microsoft.Network/virtualNetworks/subnets', clusterVnetName, 'master')
var workerSubnetId=resourceId('Microsoft.Network/virtualNetworks/subnets', clusterVnetName, 'worker')

resource clusterVnetName_resource 'Microsoft.Network/virtualNetworks@2020-05-01' = {
  name: clusterVnetName
  location: location
  tags: tags
  properties: {
    addressSpace: {
      addressPrefixes: [
        clusterVnetCidr
      ]
    }
    subnets: [
      {
        name: 'master'
        properties: {
          addressPrefix: masterSubnetCidr
          serviceEndpoints: [
            {
              service: 'Microsoft.ContainerRegistry'
            }
          ]
          privateLinkServiceNetworkPolicies: 'Disabled'
        }
      }
      {
        name: 'worker'
        properties: {
          addressPrefix: workerSubnetCidr
          serviceEndpoints: [
            {
              service: 'Microsoft.ContainerRegistry'
            }
          ]
        }
      }
    ]
  }
}

resource clusterVnetName_Microsoft_Authorization_id_name_aadObjectId 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
  name: guid(aadObjectId, clusterVnetName_resource.id, contributorRoleDefinitionId)
  scope: clusterVnetName_resource
  properties: {
    roleDefinitionId: contributorRoleDefinitionId
    principalId: aadObjectId
    principalType: 'ServicePrincipal'
  }
}

resource clusterVnetName_Microsoft_Authorization_id_name_rpObjectId 'Microsoft.Authorization/roleAssignments@2020-10-01-preview' = {
  name: guid(rpObjectId, clusterVnetName_resource.id, contributorRoleDefinitionId)
  scope: clusterVnetName_resource
  properties: {
    roleDefinitionId: contributorRoleDefinitionId
    principalId: rpObjectId
    principalType: 'ServicePrincipal'
  }
}

resource clusterName_resource 'Microsoft.RedHatOpenShift/OpenShiftClusters@2023-04-01' = {
  name: clusterName
  location: location
  tags: tags
  properties: {
    clusterProfile: {
      domain: domain
      resourceGroupId: resourceGroupId
      pullSecret: pullSecret
      fipsValidatedModules: fips
    }
    networkProfile: {
      podCidr: podCidr
      serviceCidr: serviceCidr
    }
    servicePrincipalProfile: {
      clientId: aadClientId
      clientSecret: aadClientSecret
    }
    masterProfile: {
      vmSize: masterVmSize
      subnetId: masterSubnetId
      encryptionAtHost: masterEncryptionAtHost
    }
    workerProfiles: [
      {
        name: 'worker'
        vmSize: workerVmSize
        diskSizeGB: workerVmDiskSize
        subnetId: workerSubnetId
        count: workerCount
        encryptionAtHost: workerEncryptionAtHost
      }
    ]
    apiserverProfile: {
      visibility: apiServerVisibility
    }
    ingressProfiles: [
      {
        name: 'default'
        visibility: ingressVisibility
      }
    ]
  }
  dependsOn: [
    clusterVnetName_resource
  ]
}

azuredeploy.json テンプレートをデプロイする

このセクションでは、azuredeploy.json テンプレートのデプロイについて説明します。

azuredeploy.json パラメーター

azuredeploy.json テンプレートを使用して、Azure Red Hat OpenShift クラスターをデプロイします。 以下のパラメーターが必要です。

注意

domain パラメーターには、OpenShift コンソールと API サーバーの自動生成された DNS 名の一部として使用されるドメイン プレフィックスを指定します。 このプレフィックスは、クラスター VM をホストするために作成されるリソース グループの名前の一部としても使用されます。

プロパティ 説明 有効なオプション Default value
domain クラスターのドメイン プレフィックスです。 なし
pullSecret Red Hat OpenShift Cluster Manager Web サイトから取得したプル シークレットです。
clusterName クラスターの名前です。
aadClientId Microsoft Entra クライアント アプリケーションのアプリケーション ID (GUID)。
aadObjectId Microsoft Entra クライアント アプリケーションのサービス プリンシパルのオブジェクト ID (GUID) です。
aadClientSecret セキュリティで保護された文字列としての、Microsoft Entra クライアント アプリケーションのサービス プリンシパルのクライアント シークレットです。
rpObjectId リソース プロバイダー サービス プリンシパルのオブジェクト ID (GUID) です。

以下のテンプレート パラメーターには既定値があります。 これらを指定できますが、明示的に必要ではありません。

プロパティ 説明 有効なオプション Default value
location 新しい ARO クラスターの場所。 この場所は、リソース グループのリージョンと同じでも異なっていてもかまいません。 eastus
clusterVnetName ARO クラスターの仮想ネットワークの名前。 aro-vnet
clusterVnetCidr ARO 仮想ネットワークのアドレス空間 (Classless Inter-Domain Routing (CIDR) 表記)。 10.100.0.0/15
workerSubnetCidr ワーカー ノード サブネットのアドレス空間 (CIDR 表記)。 10.100.70.0/23
masterSubnetCidr コントロール プレーン ノード サブネットのアドレス空間 (CIDR 表記)。 10.100.76.0/24
masterVmSize コントロール プレーン ノードの仮想マシンの種類/サイズ Standard_D8s_v3
workerVmSize ワーカー ノードの仮想マシンの種類/サイズ。 Standard_D4s_v3
workerVmDiskSize ワーカー ノードのディスク サイズ (ギガバイト単位)。 128
workerCount ワーカー ノードの数。 3
podCidr ポッドのアドレス空間 (CIDR 表記)。 10.128.0.0/14
serviceCidr サービスのアドレス空間 (CIDR 表記)。 172.30.0.0/16
tags リソース タグのハッシュ テーブル。 @{env = 'Dev'; dept = 'Ops'}
apiServerVisibility API サーバー (Public または Private) の可視性。 パブリック
ingressVisibility イングレス (入り口) の可視性 (Public または Private)。 パブリック

次のセクションでは、PowerShell または Azure CLI を使用する手順について説明します。

PowerShell ステップ

PowerShell を使用している場合は、次の手順を実行します。

開始する前に - PowerShell

このクイックスタートのコマンドを実行する前に、Connect-AzAccount を実行することが必要になる場合があります。 続行する前に、Azure への接続があるかどうかを確認してください。 接続があるかどうかを確認するには、Get-AzContext を実行して、アクティブな Azure サブスクリプションへのアクセス権があるかどうかを確認します。

Note

このテンプレートでは、Red Hat OpenShift Cluster Manager Web サイトから取得したプル シークレット テキストを使用します。 先に進む前に、プル シークレットが pull-secret.txt としてローカルに保存されていることを確認してください。

$rhosPullSecret= Get-Content .\pull-secret.txt -Raw # the pull secret text that was obtained from the Red Hat OpenShift Cluster Manager website

次のパラメーターを環境変数として定義する - PowerShell

$resourceGroup="aro-rg"	     # the new resource group for the cluster
$location="eastus"    		 # the location of the new ARO cluster
$domain="mydomain"           # the domain prefix for the cluster  
$aroClusterName="cluster"    # the name of the cluster

必要なリソース プロバイダーを登録する - PowerShell

サブスクリプションに、Microsoft.RedHatOpenShiftMicrosoft.ComputeMicrosoft.StorageMicrosoft.Authorization の各リソース プロバイダーを登録します。

Register-AzResourceProvider -ProviderNamespace Microsoft.RedHatOpenShift
Register-AzResourceProvider -ProviderNamespace Microsoft.Compute
Register-AzResourceProvider -ProviderNamespace Microsoft.Storage
Register-AzResourceProvider -ProviderNamespace Microsoft.Authorization

新しいリソース グループを作成する - PowerShell

New-AzResourceGroup -Name $resourceGroup -Location $location

新しいサービス プリンシパルを作成してロールを割り当てる - PowerShell

$suffix=Get-Random # random suffix for the Service Principal
$spDisplayName="sp-$resourceGroup-$suffix"
$azureADAppSp = New-AzADServicePrincipal -DisplayName $spDisplayName -Role Contributor

New-AzRoleAssignment -ObjectId $azureADAppSp.Id -RoleDefinitionName 'User Access Administrator' -ResourceGroupName $resourceGroup -ObjectType 'ServicePrincipal'
New-AzRoleAssignment -ObJectId $azureADAppSp.Id -RoleDefinitionName 'Contributor' -ResourceGroupName $resourceGroup -ObjectType 'ServicePrincipal'

サービス プリンシパルのパスワードを取得する - PowerShell

$aadClientSecretDigest = ConvertTo-SecureString -String $azureADAppSp.PasswordCredentials.SecretText -AsPlainText -Force

OpenShift リソース プロバイダーのサービス プリンシパルを取得する - PowerShell

$rpOpenShift =  Get-AzADServicePrincipal -DisplayName 'Azure Red Hat OpenShift RP' | Select-Object -ExpandProperty Id -Property Id -First 1

クラスターをデプロイする前にパラメーターを確認する - PowerShell

# setup the parameters for the deployment
$templateParams = @{  
    domain = $domain
    clusterName = $aroClusterName
    location = $location
    aadClientId = $azureADAppSp.AppId
    aadObjectId = $azureADAppSp.Id
    aadClientSecret = $aadClientSecretDigest 
    rpObjectId = $rpOpenShift.Id
    pullSecret = $rhosPullSecret
}

Write-Verbose (ConvertTo-Json $templateParams) -Verbose

ARM テンプレートを使用して Azure Red Hat OpenShift クラスターをデプロイする - PowerShell

New-AzResourceGroupDeployment -ResourceGroupName $resourceGroup @templateParams `
    -TemplateFile azuredeploy.json

クラスターへの接続

新しいクラスターに接続するには、Azure Red Hat OpenShift 4 クラスターへの接続に関するページの手順を確認します。

リソースをクリーンアップする - PowerShell

完了したら、次のコマンドを実行して、このチュートリアルで作成したリソース グループとすべてのリソースを削除します。

Remove-AzResourceGroup -Name $resourceGroup -Force

Azure CLI の手順

Azure CLI を使用している場合は、次の手順を実行します。

開始する前に - Azure CLI

このクイックスタートのコマンドを実行する前に、az login を実行することが必要になる場合があります。 続行する前に、Azure への接続があるかどうかを確認してください。 接続があるかどうかを確認するには、az account list を実行して、アクティブな Azure サブスクリプションへのアクセス権があることを確認します。

Note

このテンプレートでは、Red Hat OpenShift Cluster Manager Web サイトから取得したプル シークレット テキストを使用します。 続行する前に、シークレットが pull-secret.txt としてローカルに保存されていることを確認してください。

PULL_SECRET=$(cat pull-secret.txt)    # the pull secret text 

次のパラメーターを環境変数として定義する - Azure CLI

RESOURCEGROUP=aro-rg            # the new resource group for the cluster
LOCATION=eastus                 # the location of the new cluster
DOMAIN=mydomain                 # the domain prefix for the cluster
ARO_CLUSTER_NAME=aro-cluster    # the name of the cluster

必要なリソース プロバイダーを登録する - Azure CLI

サブスクリプションに、Microsoft.RedHatOpenShiftMicrosoft.ComputeMicrosoft.StorageMicrosoft.Authorization の各リソース プロバイダーを登録します。

az provider register --namespace 'Microsoft.RedHatOpenShift' --wait
az provider register --namespace 'Microsoft.Compute' --wait
az provider register --namespace 'Microsoft.Storage' --wait
az provider register --namespace 'Microsoft.Authorization' --wait

新しいリソース グループを作成する - Azure CLI

az group create --name $RESOURCEGROUP --location $LOCATION

新しい Microsoft Entra アプリケーションのサービス プリンシパルを作成する

  • Azure CLI
az ad sp create-for-rbac --name "sp-$RG_NAME-${RANDOM}" > app-service-principal.json
SP_CLIENT_ID=$(jq -r '.appId' app-service-principal.json)
SP_CLIENT_SECRET=$(jq -r '.password' app-service-principal.json)
SP_OBJECT_ID=$(az ad sp show --id $SP_CLIENT_ID | jq -r '.id')

新しいサービス プリンシパルに共同作成者ロールを割り当てる - Azure CLI

az role assignment create \
    --role 'User Access Administrator' \
    --assignee-object-id $SP_OBJECT_ID \
    --scope $SCOPE \
    --assignee-principal-type 'ServicePrincipal'

az role assignment create \
    --role 'Contributor' \
    --assignee-object-id $SP_OBJECT_ID \
    --scope $SCOPE \
    --assignee-principal-type 'ServicePrincipal'

OpenShift リソース プロバイダーのサービス プリンシパル オブジェクト ID を取得する - Azure CLI

ARO_RP_SP_OBJECT_ID=$(az ad sp list --display-name "Azure Red Hat OpenShift RP" --query [0].id -o tsv)

クラスターをデプロイする - Azure CLI

az deployment group create \
    --name aroDeployment \
    --resource-group $RESOURCEGROUP \
    --template-file azuredeploy.bicep \
    --parameters location=$LOCATION \
    --parameters domain=$DOMAIN \
    --parameters pullSecret=$PULL_SECRET \
    --parameters clusterName=$ARO_CLUSTER_NAME \
    --parameters aadClientId=$SP_CLIENT_ID \
    --parameters aadObjectId=$SP_OBJECT_ID \
    --parameters aadClientSecret=$SP_CLIENT_SECRET \
    --parameters rpObjectId=$ARO_RP_SP_OBJECT_ID

クラスターに接続する - Azure CLI

新しいクラスターに接続するには、Azure Red Hat OpenShift 4 クラスターへの接続に関するページの手順を確認します。

リソースをクリーンアップする - Azure CLI

完了したら、次のコマンドを実行して、このチュートリアルで作成したリソース グループとすべてのリソースを削除します。

az aro delete --resource-group $RESOURCEGROUP --name $CLUSTER

ヒント

問題がある場合は、 Azure Red Hat Openshift (ARO) リポジトリで問題を開いて、GitHub でお知らせください。

次のステップ

この記事では、ARM テンプレートと Bicep の両方を使用して、OpenShift 4 を実行する Azure Red Hat OpenShift クラスターを作成する方法について説明しました。

次の記事に進み、Microsoft Entra ID を使用して認証のためにクラスターを構成する方法について学習します。