Gestion du parc avec des règles d'administration personnalisées
Vous pouvez utiliser le service de règles d'administration avec des contraintes personnalisées pour appliquer des configurations spécifiques dans les clusters Managed Service for Apache Spark de votre organisation. Cette approche centralisée permet d'assurer la conformité, de contrôler les coûts et de standardiser votre parc Managed Service for Apache Spark.
Ce guide explique comment créer et appliquer une règle d'administration personnalisée pour les clusters Managed Service for Apache Spark. Pour en savoir plus, consultez la présentation des règles d'administration.
Avant de commencer
- Connectez-vous à votre Google Cloud compte. Si vous débutez sur Google Cloud, créez un compte pour évaluer les performances de nos produits en conditions réelles. Les nouveaux clients bénéficient également de 300 $de crédits sans frais pour exécuter, tester et déployer des charges de travail.
-
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.
-
-
Installez la Google Cloud CLI.
-
Si vous utilisez un fournisseur d'identité (IdP) externe, vous devez d'abord vous connecter à la gcloud CLI avec votre identité fédérée.
-
Pour initialiser la gcloud CLI, exécutez la commande suivante :
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.
-
-
Installez la Google Cloud CLI.
-
Si vous utilisez un fournisseur d'identité (IdP) externe, vous devez d'abord vous connecter à la gcloud CLI avec votre identité fédérée.
-
Pour initialiser la gcloud CLI, exécutez la commande suivante :
gcloud init
Appliquer une contrainte personnalisée
Les étapes suivantes vous montrent comment appliquer une exigence de sécurité courante : s'assurer que Kerberos est activé pour tous les nouveaux clusters Managed Service for Apache Spark.
Définissez la contrainte personnalisée.
- Créez un fichier YAML avec le contenu suivant :
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.Remplacez
ORGANIZATION_IDpar l'ID de votre organisation.Définissez la contrainte personnalisée pour la rendre disponible à votre organisation.
gcloud org-policies set-custom-constraint CONSTRAINT_PATHRemplacez
CONSTRAINT_PATHpar le chemin d'accès à votre fichier de contraintes YAML.Créez une règle d'administration qui applique la contrainte.
- Créez un autre fichier YAML avec le contenu suivant :
name: projects/PROJECT_ID/policies/custom.dataprocKerberos spec: rules: - enforce: trueRemplacez
PROJECT_IDpar l'ID du projet auquel appliquer la règle. Vous pouvez également appliquer cette règle au niveau d'un dossier ou d' organisation.Appliquez la règle.
gcloud org-policies set-policy POLICY_PATHRemplacez
POLICY_PATHpar le chemin d'accès au fichier de règles YAML.
Une fois la règle appliquée, toute tentative de création d'un cluster Managed Service for Apache Spark dans la ressource spécifiée sans Kerberos activé échoue.
Cas d'utilisation des contraintes personnalisées
Vous pouvez créer des contraintes personnalisées pour appliquer un large éventail de règles à votre parc Managed Service for Apache Spark. L'application de règles de parc permet de contrôler les coûts, de standardiser et de sécuriser.
Exemple : Vous pouvez exiger des types de machines spécifiques ou empêcher les adresses IP publiques sur les nœuds de cluster.
Étape suivante
- Lisez la présentation des règles d'administration.
- En savoir plus sur les contraintes personnalisées.