Gestione del parco risorse con policy dell'organizzazione personalizzate
Puoi utilizzare il servizio Policy dell'organizzazione con vincoli personalizzati per applicare configurazioni specifiche nei cluster Managed Service per Apache Spark della tua organizzazione. Questo approccio centralizzato contribuisce a garantire la conformità, controllare i costi e standardizzare il parco risorse Managed Service per Apache Spark.
Questa guida mostra come creare e applicare una policy dell'organizzazione personalizzata per i cluster Managed Service per Apache Spark. Per saperne di più, consulta la pagina Introduzione alla policy dell'organizzazione.
Prima di iniziare
- Accedi al tuo Google Cloud account. Se non conosci Google Cloud, crea un account per valutare le prestazioni dei nostri prodotti in scenari reali. I nuovi clienti ricevono anche 300 $di crediti senza costi per l'esecuzione, il test e il deployment dei workload.
-
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.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. 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.
-
-
Installa Google Cloud CLI.
-
Se utilizzi un provider di identità (IdP) esterno, devi prima accedere a gcloud CLI con la tua identità federata.
-
Per inizializzare gcloud CLI, esegui questo comando:
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.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. 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.
-
-
Installa Google Cloud CLI.
-
Se utilizzi un provider di identità (IdP) esterno, devi prima accedere a gcloud CLI con la tua identità federata.
-
Per inizializzare gcloud CLI, esegui questo comando:
gcloud init
Applica un vincolo personalizzato
I passaggi seguenti mostrano come applicare un requisito di sicurezza comune: assicurarsi che tutti i nuovi cluster Managed Service per Apache Spark abbiano Kerberos abilitato.
Definisci il vincolo personalizzato.
- Crea un file YAML con i seguenti contenuti:
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.Sostituisci
ORGANIZATION_IDcon l'ID della tua organizzazione.Imposta il vincolo personalizzato in modo che sia disponibile per la tua organizzazione.
gcloud org-policies set-custom-constraint CONSTRAINT_PATHSostituisci
CONSTRAINT_PATHcon il percorso del file YAML del vincolo.Crea una policy dell'organizzazione che applichi il vincolo.
- Crea un altro file YAML con i seguenti contenuti:
name: projects/PROJECT_ID/policies/custom.dataprocKerberos spec: rules: - enforce: trueSostituisci
PROJECT_IDcon l'ID del progetto a cui applicare la policy. Puoi applicare questa policy anche a livello di cartella o organizzazione.Applica la policy.
gcloud org-policies set-policy POLICY_PATHSostituisci
POLICY_PATHcon il percorso del file YAML della policy.
Dopo aver applicato la policy, un tentativo di creare un cluster Managed Service per Apache Spark nella risorsa specificata senza Kerberos abilitato non riesce.
Casi d'uso per i vincoli personalizzati
Puoi creare vincoli personalizzati per applicare un'ampia gamma di policy per il tuo parco risorse Managed Service per Apache Spark. L'applicazione delle policy del parco risorse contribuisce al controllo dei costi, alla standardizzazione e alla sicurezza.
Esempio: puoi richiedere tipi di macchine specifici o impedire gli indirizzi IP pubblici sui nodi del cluster.
Passaggi successivi
- Leggi l'introduzione alla policy dell'organizzazione.
- Scopri di più sui vincoli personalizzati.