2.4. サービスプリンシパルの作成
OpenShift Container Platform とそのインストールプログラムは Azure Resource Manager を使用して Microsoft Azure リソースを作成するため、それを表すサービスプリンシパルを作成する必要があります。
前提条件
- Azure CLI のインストールまたは更新を実行します。
- Azure アカウントには、使用するサブスクリプションに必要なロールがなければなりません。
手順
環境を登録します。
$ az cloud register -n AzureStackCloud --endpoint-resource-manager <endpoint>1 - 1
- Azure Resource Manager エンドポイント `https://management.<region>.<fqdn>/` を指定します。
詳細は、Microsoft のドキュメント を参照してください。
アクティブな環境を設定します。
$ az cloud set -n AzureStackCloudAzure Stack Hub に特定の API バージョンを使用するように、環境設定を更新します。
$ az cloud update --profile 2019-03-01-hybridAzure CLI にログインします。
$ az loginマルチテナント環境の場合は、テナント ID も指定する必要があります。
Azure アカウントでサブスクリプションを使用している場合は、適切なサブスクリプションを使用していることを確認してください。
利用可能なアカウントの一覧を表示し、クラスターに使用するサブスクリプションの
tenantIdの値を記録します。$ az account list --refresh出力例
[ { "cloudName": AzureStackCloud", "id": "9bab1460-96d5-40b3-a78e-17b15e978a80", "isDefault": true, "name": "Subscription Name", "state": "Enabled", "tenantId": "6057c7e9-b3ae-489d-a54e-de3f6bf6a8ee", "user": { "name": "you@example.com", "type": "user" } } ]アクティブなアカウントの詳細を表示し、
tenantId値が使用するサブスクリプションと一致することを確認します。$ az account show出力例
{ "environmentName": AzureStackCloud", "id": "9bab1460-96d5-40b3-a78e-17b15e978a80", "isDefault": true, "name": "Subscription Name", "state": "Enabled", "tenantId": "6057c7e9-b3ae-489d-a54e-de3f6bf6a8ee",1 "user": { "name": "you@example.com", "type": "user" } }- 1
tenantIdパラメーターの値が正しいサブスクリプション ID であることを確認してください。
適切なサブスクリプションを使用していない場合には、アクティブなサブスクリプションを変更します。
$ az account set -s <subscription_id>1 - 1
- サブスクリプション ID を指定します。
サブスクリプション ID の更新を確認します。
$ az account show出力例
{ "environmentName": AzureStackCloud", "id": "33212d16-bdf6-45cb-b038-f6565b61edda", "isDefault": true, "name": "Subscription Name", "state": "Enabled", "tenantId": "8049c7e9-c3de-762d-a54e-dc3f6be6a7ee", "user": { "name": "you@example.com", "type": "user" } }
-
出力から
tenantIdおよびidパラメーター値を記録します。OpenShift Container Platform のインストール時にこれらの値が必要になります。 アカウントのサービスプリンシパルを作成します。
$ az ad sp create-for-rbac --role Contributor --name <service_principal> \1 --scopes /subscriptions/<subscription_id>2 --years <years>3 出力例
Creating 'Contributor' role assignment under scope '/subscriptions/<subscription_id>' The output includes credentials that you must protect. Be sure that you do not include these credentials in your code or check the credentials into your source control. For more information, see https://aka.ms/azadsp-cli { "appId": "ac461d78-bf4b-4387-ad16-7e32e328aec6", "displayName": <service_principal>", "password": "00000000-0000-0000-0000-000000000000", "tenantId": "8049c7e9-c3de-762d-a54e-dc3f6be6a7ee" }-
直前の出力の
appIdおよびpasswordパラメーターの値を記録します。OpenShift Container Platform のインストール時にこれらの値が必要になります。