Flottenverwaltung mit benutzerdefinierten Organisationsrichtlinien

Sie können den Organization Policy Service mit benutzerdefinierten Einschränkungen verwenden, um bestimmte Konfigurationen für die Managed Service for Apache Spark-Cluster Ihrer Organisation zu erzwingen. Dieser zentralisierte Ansatz trägt dazu bei, die Compliance zu gewährleisten, die Kosten zu kontrollieren und Ihre Managed Service for Apache Spark-Flotte zu standardisieren.

In diesem Leitfaden erfahren Sie, wie Sie eine benutzerdefinierte Organisationsrichtlinie für Managed Service for Apache Spark-Cluster erstellen und erzwingen. Weitere Informationen finden Sie unter Einführung in die Organisationsrichtlinie.

Hinweis

  1. Melden Sie sich in Ihrem Google Cloud -Konto an. Wenn Sie mit Google Cloudnoch nicht vertraut sind, erstellen Sie ein Konto, um die Leistungsfähigkeit unserer Produkte in der Praxis sehen und bewerten zu können. Neukunden erhalten außerdem ein Guthaben von 300 $, um Arbeitslasten auszuführen, zu testen und bereitzustellen.
  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. Installieren Sie die Google Cloud CLI.

  7. Wenn Sie einen externen Identitätsanbieter (IdP) verwenden, müssen Sie sich zuerst mit Ihrer föderierten Identität in der gcloud CLI anmelden.

  8. Führen Sie den folgenden Befehl aus, um die gcloud CLI zu initialisieren:

    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. Installieren Sie die Google Cloud CLI.

  14. Wenn Sie einen externen Identitätsanbieter (IdP) verwenden, müssen Sie sich zuerst mit Ihrer föderierten Identität in der gcloud CLI anmelden.

  15. Führen Sie den folgenden Befehl aus, um die gcloud CLI zu initialisieren:

    gcloud init

Benutzerdefinierte Einschränkung erzwingen

In den folgenden Schritten wird gezeigt, wie Sie eine allgemeine Sicherheitsanforderung erzwingen: Alle neuen Managed Service for Apache Spark-Cluster müssen Kerberos aktiviert haben.

  1. Definieren Sie die benutzerdefinierte Einschränkung.

    1. Erstellen Sie eine YAML-Datei mit folgendem Inhalt:
    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.
    

    Ersetzen Sie ORGANIZATION_ID durch Ihre Organisations-ID.

  2. Legen Sie die benutzerdefinierte Einschränkung fest, um sie für Ihre Organisation verfügbar zu machen.

    gcloud org-policies set-custom-constraint CONSTRAINT_PATH
    

    Ersetzen Sie CONSTRAINT_PATH durch den Pfad zu Ihrer YAML-Datei mit Einschränkungen.

  3. Erstellen Sie eine Organisationsrichtlinie, die die Einschränkung erzwingt.

    1. Erstellen Sie eine weitere YAML-Datei mit folgendem Inhalt:
    name: projects/PROJECT_ID/policies/custom.dataprocKerberos
    spec:
      rules:
        -   enforce: true
    

    Ersetzen Sie PROJECT_ID durch die ID des Projekts, auf das die Richtlinie angewendet werden soll. Sie können diese Richtlinie auch auf Ordner- oder Organisationsebene anwenden.

  4. Wenden Sie die Richtlinie an:

    gcloud org-policies set-policy POLICY_PATH
    

    Ersetzen Sie POLICY_PATH durch den Pfad zur YAML-Richtliniendatei.

Nachdem Sie die Richtlinie angewendet haben, schlägt der Versuch fehl, einen Managed Service for Apache Spark-Cluster in der angegebenen Ressource ohne aktivierte Kerberos-Authentifizierung zu erstellen.

Anwendungsfälle für benutzerdefinierte Einschränkungen

Sie können benutzerdefinierte Einschränkungen erstellen, um eine Vielzahl von Richtlinien für Ihre Managed Service for Apache Spark-Flotte zu erzwingen. Das Anwenden von Flottenrichtlinien hilft bei der Kostenkontrolle, Standardisierung und Sicherheit.

Beispiel: Sie können bestimmte Maschinentypen für Clusterknoten vorschreiben oder öffentliche IP-Adressen für Clusterknoten verhindern.

Nächste Schritte