Gerenciamento de frotas com políticas personalizadas da organização

É possível usar o serviço de políticas da organização com restrições personalizadas para aplicar configurações específicas nos clusters do Managed Service for Apache Spark da sua organização. Essa abordagem centralizada ajuda a garantir a conformidade, controlar custos e padronizar sua frota do Managed Service for Apache Spark.

Este guia mostra como criar e aplicar uma política personalizada da organização para clusters do Managed Service for Apache Spark. Para mais informações, consulte Introdução à política da organização.

Antes de começar

  1. Faça login na sua Google Cloud conta do. Se você começou a usar o Google Cloud, crie uma conta para avaliar o desempenho dos nossos produtos em situações reais. Clientes novos também recebem US $300 em créditos para executar, testar e implantar cargas de trabalho.
  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. Instale a Google Cloud CLI.

  7. Ao usar um provedor de identidade (IdP) externo, primeiro faça login na gcloud CLI com sua identidade federada.

  8. Para inicializar a CLI gcloud, execute o seguinte 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. Instale a Google Cloud CLI.

  14. Ao usar um provedor de identidade (IdP) externo, primeiro faça login na gcloud CLI com sua identidade federada.

  15. Para inicializar a CLI gcloud, execute o seguinte comando:

    gcloud init

Aplicar uma restrição personalizada

As etapas a seguir mostram como aplicar um requisito de segurança comum: garantir que todos os novos clusters do Managed Service for Apache Spark tenham o Kerberos ativado.

  1. Defina a restrição personalizada.

    1. Crie um arquivo YAML com o seguinte conteúdo:
    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.
    

    Substitua ORGANIZATION_ID pelo ID da organização.

  2. Defina a restrição personalizada para que ela fique disponível para sua organização.

    gcloud org-policies set-custom-constraint CONSTRAINT_PATH
    

    Substitua CONSTRAINT_PATH pelo caminho do arquivo de restrição YAML.

  3. Crie uma política da organização que aplique a restrição.

    1. Crie outro arquivo YAML com o seguinte conteúdo:
    name: projects/PROJECT_ID/policies/custom.dataprocKerberos
    spec:
      rules:
        -   enforce: true
    

    Substitua PROJECT_ID pelo ID do projeto a que a política será aplicada. Também é possível aplicar essa política no nível da pasta ou da organização.

  4. Aplique a política.

    gcloud org-policies set-policy POLICY_PATH
    

    Substitua POLICY_PATH pelo caminho do arquivo de política YAML.

Depois de aplicar a política, uma tentativa de criar um cluster do Managed Service for Apache Spark no recurso especificado sem o Kerberos ativado falha.

Casos de uso de restrições personalizadas

É possível criar restrições personalizadas para aplicar uma ampla variedade de políticas à sua frota do Managed Service for Apache Spark. A aplicação de políticas de frota ajuda no controle de custos, na padronização e na segurança.

Exemplo: é possível exigir tipos de máquinas específicos ou impedir endereços IP públicos em nós de cluster.

A seguir