Google Cloud 运行 for Anthos on GKE 的服务如何连接到不同组织的不同项目上的 Firestore?

How can A service of Google Cloud Run for Anthos on GKE connect to Firestore on different project of different organization?

我为 Anthos on GKE 创建了 Cloud 运行 服务。然后,我想让它连接到不同组织的项目中的 Firestore。它如何连接到 Firestore?

我在 OrganizationA 的 ProjectA 上为 Anthos on GKE 创建了 Cloud 运行 服务。 Cloud 运行 服务的编程语言是Java, google-cloud-firestore 库。

并且,我在 OrganizationB(无组织)的 ProjectB 上创建了一个 Firestore 数据库。

然后,尝试将云 运行 服务访问到 FirestoreDB,我收到了错误消息。

{"message":"Internal Server Error: com.google.api.gax.rpc.PermissionDeniedException: io.grpc.StatusRuntimeException: PERMISSION_DENIED: Missing or insufficient permissions."}

一切都取决于您的要求。根据此page,在项目 B 的 IAM 部分中使用 roles/datastore.userroles/datastore.viewer 授予服务帐户(单击添加并粘贴服务帐户的电子邮件)。

根据您的 GKE 部署,服务帐户可以是默认计算服务帐户 (<projectNumber>-compute@developer.gserviceaccount.com) 或其他,如果您自定义了集群/workload Identity