カスタム組織ポリシーによるフリート管理
カスタム制約で 組織ポリシー サービスを使用すると、組織の Managed Service for Apache Spark クラスタ全体で特定の構成を適用できます。この一元化されたアプローチにより、コンプライアンスの確保、費用の管理、Managed Service for Apache Spark フリートの標準化が可能になります。
このガイドでは、Managed Service for Apache Spark クラスタのカスタム組織のポリシーを作成して適用する方法について説明します。詳細については、組織のポリシーの概要をご覧ください。
始める前に
- Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオで Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分も差し上げます。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Resource Manager API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Make sure that you have the following role or roles on the project: Organization Policy Administrator
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Resource Manager API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.-
Make sure that you have the following role or roles on the project: Organization Policy Administrator
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
カスタム制約を適用する
次の手順では、すべての新しい Managed Service for Apache Spark クラスタで Kerberos が有効になっていることを確認するという一般的なセキュリティ要件を適用する方法について説明します。
カスタム制約を定義します。
- 次の内容で YAML ファイルを作成します。
name: organizations/ORGANIZATION_ID/customConstraints/custom.dataprocKerberos resourceTypes: - dataproc.googleapis.com/Cluster methodTypes: - CREATE condition: "resource.config.securityConfig.kerberosConfig.enableKerberos == true" actionType: ALLOW displayName: Cluster must have Kerberos enabled.ここで、
ORGANIZATION_IDは実際の組織 ID に置き換えます。カスタム制約を設定して、組織で使用できるようにします。
gcloud org-policies set-custom-constraint CONSTRAINT_PATHCONSTRAINT_PATHは、YAML 制約ファイルのパスに置き換えます。制約を適用する組織のポリシーを作成します。
- 次の内容で別の YAML ファイルを作成します。
name: projects/PROJECT_ID/policies/custom.dataprocKerberos spec: rules: - enforce: truePROJECT_IDは、ポリシーを適用するプロジェクトの ID に置き換えます。このポリシーは、フォルダレベルまたは組織レベルで適用することもできます。ポリシーを適用します。
gcloud org-policies set-policy POLICY_PATHPOLICY_PATHは、YAML ポリシー ファイルのパスに置き換えます。
ポリシーを適用すると、Kerberos が有効になっていない指定されたリソースに Managed Service for Apache Spark クラスタを作成しようとすると失敗します。
カスタム制約のユースケース
カスタム制約を作成して、Managed Service for Apache Spark フリートに幅広いポリシーを適用できます。フリート ポリシーを適用すると、費用の制御、標準化、セキュリティに役立ちます。
例: 特定のマシンタイプを必須にしたり、クラスタノードでパブリック IP アドレスを使用できないようにしたりできます。
次のステップ
- 組織のポリシーの概要を読む
- カスタム制約について詳細を学習する。