当您使用 Managed Service for Apache Spark 创建集群并在集群上运行作业时,该服务会在项目中设置必要的 Managed Service for Apache Spark 角色和权限,以访问和使用完成这些任务所需的 Google Cloud 资源。但是,如果您要完成跨项目工作(例如,访问另一个项目中的数据),则需要设置必要的角色和权限以访问跨项目资源。
为了帮助您成功完成跨项目工作,本文档列出了使用 Managed Service for Apache Spark 的不同主账号,以及可提供这些主账号访问和使用 Google Cloud 资源所需权限的角色。
有三个主账号(身份)可以访问和使用 Managed Service for Apache Spark:
- 用户身份
- 控制平面身份
数据平面身份

Dataproc API 用户(用户身份)
示例:username@example.com
这是调用 Managed Service for Apache Spark 以创建集群、提交作业以及向服务发出其他请求的用户。如果通过 API 客户端或其他Google Cloud 服务(例如 Compute Engine、Cloud Run functions 或 Managed Service for Apache Airflow)调用 Managed Service for Apache Spark,则用户通常是个人,但也可以是服务账号。
相关角色
备注
- Dataproc API 提交的作业在 Linux 上以
root身份运行。 Managed Service for Apache Spark 集群继承项目范围的 Compute Engine SSH 元数据,除非您在创建集群时通过设置
--metadata=block-project-ssh-keys=true明确阻止了该数据(请参阅集群元数据)。系统会为每个项目级层的 SSH 用户创建 HDFS 用户目录。这些 HDFS 目录是在集群部署时创建的,而新的(部署后)SSH 用户在现有集群上不会获得 HDFS 目录。
Managed Service for Apache Spark 服务代理(控制平面身份)
示例:service-project-number@dataproc-accounts.
Managed Service for Apache Spark Service Agent 服务账号用于在创建 Managed Service for Apache Spark 集群的项目中的资源上执行一组广泛的系统操作,包括:
- 创建 Compute Engine 资源,包括虚拟机实例、实例组和实例模板
get和list操作,用来确认资源(例如映像、防火墙、Managed Service for Apache Spark 初始化操作和 Cloud Storage 存储分区)的配置- 自动创建 Managed Service for Apache Spark 暂存和临时存储桶(如果用户未指定暂存或临时存储桶)
- 将集群配置元数据写入暂存存储分区
- 访问宿主项目中的 VPC 网络
相关角色
Managed Service for Apache Spark 虚拟机服务账号(数据平面身份)
示例:project-number-compute@
您的应用代码在 Managed Service for Apache Spark 虚拟机上以虚拟机服务账号身份运行。用户作业会被授予此服务账号的角色(及其关联权限)。
虚拟机服务账号执行以下操作:
- 与 Managed Service for Apache Spark 控制平面通信。
- 在 Managed Service for Apache Spark 暂存和临时存储分区中读取和写入数据。
- 根据 Managed Service for Apache Spark 作业的需要,在 Cloud Storage、BigQuery、Cloud Logging 和其他 Google Cloud 资源中读取和写入数据。
相关角色