カスタム組織のポリシーを使用したフリート管理

組織ポリシー サービスとカスタム制約を使用すると、組織の Managed Service for Apache Spark クラスタ全体に特定の構成を適用できます。この一元化されたアプローチにより、コンプライアンスの確保、費用の管理、Managed Service for Apache Spark フリートの標準化が可能になります。

このガイドでは、Managed Service for Apache Spark クラスタのカスタム組織のポリシーを作成して適用する方法について説明します。詳細については、組織のポリシーの概要をご覧ください。

始める前に

  1. アカウントにログインします。 Google Cloud を初めて使用する場合は、 アカウントを作成して、実際のシナリオで Google プロダクトのパフォーマンスを評価してください。 Google Cloud新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the Resource Manager API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  5. Make sure that you have the following role or roles on the project: Organization Policy Administrator

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. 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.

    4. 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

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. Click Select a role, then search for the role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  6. Google Cloud CLI をインストールします。

  7. 外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。

  8. gcloud CLI を初期化するには、次のコマンドを実行します:

    gcloud init
  9. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  10. Verify that billing is enabled for your Google Cloud project.

  11. Enable the Resource Manager API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  12. Make sure that you have the following role or roles on the project: Organization Policy Administrator

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. 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.

    4. 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

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. Click Select a role, then search for the role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  13. Google Cloud CLI をインストールします。

  14. 外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。

  15. gcloud CLI を初期化するには、次のコマンドを実行します:

    gcloud init

カスタム制約を適用する

次の手順では、一般的なセキュリティ要件(すべての新しい Managed Service for Apache Spark クラスタで Kerberos が有効になっていること)を適用する方法について説明します。

  1. カスタム制約を定義します。

    1. 次の内容で 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 に置き換えます。

  2. カスタム制約を設定して、組織で使用できるようにします。

    gcloud org-policies set-custom-constraint CONSTRAINT_PATH
    

    CONSTRAINT_PATH は、YAML 制約ファイルのパスに置き換えます。

  3. 制約を適用する組織のポリシーを作成します。

    1. 次の内容で別の YAML ファイルを作成します。
    name: projects/PROJECT_ID/policies/custom.dataprocKerberos
    spec:
      rules:
        -   enforce: true
    

    PROJECT_ID は、ポリシーを適用するプロジェクト に置き換えます。このポリシーは、フォルダレベルまたは 組織レベルで適用することもできます。

  4. ポリシーを適用します。

    gcloud org-policies set-policy POLICY_PATH
    

    POLICY_PATH は、YAML ポリシー ファイルのパスに置き換えます。

ポリシーを適用すると、指定したリソースに Kerberos を有効にせずに Managed Service for Apache Spark クラスタを作成しようとすると失敗します。

カスタム制約のユースケース

カスタム制約を作成して、Managed Service for Apache Spark フリートに幅広いポリシーを適用できます。フリート ポリシーを適用すると、費用の管理、標準化、セキュリティに役立ちます。

例: 特定のマシンタイプを必須にしたり、クラスタノードでパブリック IP アドレスを禁止したりできます。

次のステップ