Administración de flotas con políticas de la organización personalizadas

Puedes usar el Servicio de políticas de la organización con restricciones personalizadas para aplicar configuraciones específicas en los clústeres de Managed Service for Apache Spark de tu organización. Este enfoque centralizado ayuda a garantizar el cumplimiento, controlar los costos y estandarizar tu flota de Managed Service for Apache Spark.

En esta guía, se muestra cómo crear y aplicar una política de la organización personalizada para los clústeres de Managed Service for Apache Spark. Para obtener más información, consulta Introducción a la política de la organización.

Antes de comenzar

  1. Accede a tu Google Cloud cuenta de. Si eres nuevo en Google Cloud, crea una cuenta para evaluar el rendimiento de nuestros productos en situaciones reales. Los clientes nuevos también obtienen $300 en créditos gratuitos para ejecutar, probar y, además, implementar cargas de trabajo.
  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. Instala Google Cloud CLI.

  7. Si usas un proveedor de identidad externo (IdP), primero debes acceder a la gcloud CLI con tu identidad federada.

  8. Para inicializar gcloud CLI, ejecuta el siguiente comando:

    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. Instala Google Cloud CLI.

  14. Si usas un proveedor de identidad externo (IdP), primero debes acceder a la gcloud CLI con tu identidad federada.

  15. Para inicializar gcloud CLI, ejecuta el siguiente comando:

    gcloud init

Aplica una restricción personalizada

En los siguientes pasos, se muestra cómo aplicar un requisito de seguridad común: garantizar que todos los clústeres nuevos de Managed Service for Apache Spark tengan habilitado Kerberos.

  1. Define la restricción personalizada.

    1. Crea un archivo YAML con el siguiente contenido:
    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.
    

    Reemplaza ORGANIZATION_ID por el ID de tu organización.

  2. Establece la restricción personalizada para que esté disponible para tu organización.

    gcloud org-policies set-custom-constraint CONSTRAINT_PATH
    

    Reemplaza CONSTRAINT_PATH por la ruta de acceso a tu archivo de restricción YAML.

  3. Crea una política de la organización que aplique la restricción.

    1. Crea otro archivo YAML con el siguiente contenido:
    name: projects/PROJECT_ID/policies/custom.dataprocKerberos
    spec:
      rules:
        -   enforce: true
    

    Reemplaza PROJECT_ID por el ID del proyecto al que se aplicará la política. También puedes aplicar esta política a nivel de la carpeta o de la organización.

  4. Aplicar la política.

    gcloud org-policies set-policy POLICY_PATH
    

    Reemplaza POLICY_PATH por la ruta de acceso al archivo de política YAML.

Después de aplicar la política, no se podrá crear un clúster de Managed Service for Apache Spark en el recurso especificado sin Kerberos habilitado.

Casos de uso de restricciones personalizadas

Puedes crear restricciones personalizadas para aplicar una amplia variedad de políticas para tu flota de Managed Service for Apache Spark. Aplicar políticas de flota ayuda con el control de costos, la estandarización y la seguridad.

Ejemplo: Puedes requerir tipos de máquinas específicos o evitar direcciones IP públicas en los nodos del clúster.

¿Qué sigue?