设置共享 VPC 访问权限

授予所需角色

Cloud Workstations Service Agent 允许 Cloud Workstations 在您的项目上执行服务职责。当您在项目中激活 Cloud Workstations 服务时,系统会自动创建服务代理。如需使 Cloud Workstations 能够使用您的共享 VPC 网络和子网,请向项目的 Cloud Workstations 服务代理授予共享 VPC 子网的 Compute Engine Network User 角色 (roles/compute.networkUser)。

  1. 如需检索项目的 Cloud Workstations 服务代理,请使用以下命令:

    gcloud beta services identity create \
        --service=workstations.googleapis.com \
        --project=WORKSTATIONS_PROJECT_ID
    

    WORKSTATIONS_PROJECT_ID 替换为要在其中创建工作站集群的项目的 ID。

    Cloud Workstations Service Agent 采用以下格式:
    service-$WORKSTATIONS_PROJECT_NUMBER@gcp-sa-workstations.iam.gserviceaccount.com

  2. 向 Cloud Workstations 服务代理授予共享 VPC 子网的 Compute Engine Network User 角色 (roles/compute.networkUser)。

使用共享 VPC 创建工作站集群

在 Google Cloud 控制台中创建工作站集群时,指定共享 VPC 网络和子网。只有在通过控制台与用户共享子网的情况下,才能执行此步骤。如需了解详情,请参阅预配共享 VPC

如需了解有关共享 VPC 访问权限的一般信息,请参阅共享 VPC

创建工作站集群时,Cloud Workstations 会将该集群与特定子网相关联,并且所有工作站都放置在该子网中。如需启用 VPC 流日志,请确保为相应子网开启日志记录。如需了解详情,请参阅为现有子网启用 VPC 流日志

后续步骤