简体   繁体   English

创建新计算实例时 GCP 中的权限错误,但服务帐户确实具有权限

[英]Permission error in GCP when creating a new compute instance but service account does have permissions

I am running a cloudbuild.yaml job in Google Cloud Platform that builds, pushes and tags a Docker Image and then it creates a Compute Engine instance to run that image via gcr.io/cloud-builders/gcloud.create-with-container .我在 Google Cloud Platform 中运行cloudbuild.yaml作业,它构建、推送和标记 Docker 映像,然后它创建一个 Compute Engine 实例以通过gcr.io/cloud-builders/gcloud.create-with-container运行该映像。 I also specify a service account to be used in this step:我还指定了要在此步骤中使用的服务帐户:

- id: "Create Compute Engine instance"
  name: gcr.io/cloud-builders/gcloud
  args: [
    'compute',
    'instances',
    'create-with-container',
    '${INSTANCE_NAME}',
    '--container-image',
    'eu.gcr.io/${PROJECT_ID}/${PROJECT_ID}-${REPO_NAME}',
    '--zone',
    '${ZONE}',
    '--service-account',
    '${SERVICE_ACCOUNT},
    '--machine-type',
    'n2-standard-4'
    ]

However I am getting an error:但是我收到一个错误:

Already have image (with digest): gcr.io/cloud-builders/gcloud
ERROR: (gcloud.compute.instances.create-with-container) Could not fetch resource:
 - Required 'compute.instances.create' permission for 'projects/...'

The service account in use does have the permissions for that as it has been assigned "role": "roles/compute.instanceAdmin.v1" , which includes compute.instances.* as per documentation .正在使用的服务帐户确实具有权限,因为它已被分配"role": "roles/compute.instanceAdmin.v1" ,其中包括根据文档计算compute.instances.*

Anyone has experienced this or a similar situation and can give a hint on how to proceed?任何人都经历过这种或类似的情况,并且可以提示如何进行? Am I missing something obvious?我错过了一些明显的东西吗? I have tried using other service accounts, including the project default compute account and get the same error.我尝试使用其他服务帐户,包括项目默认计算帐户并得到相同的错误。 One thing to note is I do not specify a service account for Docker steps (gcr.io/cloud-builders/docker).需要注意的一点是,我没有为 Docker 步骤 (gcr.io/cloud-builders/docker) 指定服务帐户。

Make sure that you are not misinterpreting service accounts.确保您没有误解服务帐户。 There is a special service account used by Cloud Build. Cloud Build 使用了一个特殊的服务帐号。 There is also the service account to "be used" by the VM/instance you are creating.您正在创建的虚拟机/实例还可以“使用”服务帐户。

The "compute.instances.create" permission should be granted to the special Cloud Build account, not to the account for the instance. “compute.instances.create”权限应授予特殊 Cloud Build 帐户,而不是实例帐户。

The Cloud Build account has a name like 123123123@cloudbuild.gserviceaccount.com. Cloud Build 帐户的名称类似于 123123123@cloudbuild.gserviceaccount.com。

In the Cloud Console go to Cloud Build -> Settings -> Service Accounts and check if correct permissions are granted.在 Cloud Console 中,转到 Cloud Build -> Settings -> Service Accounts 并检查是否授予了正确的权限。

云控制台

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用gcloud和具有“所有者”权限的服务帐户推送Docker映像时出现“ 500 Internal Server Error” - “500 Internal Server Error” when pushing docker images using gcloud and a service account with “Owner” permission 混杂模式下的 GCP 计算实例网卡 - GCP Compute Instance NIC in Promiscuous Mode AWS / ECS - 创建新服务时发生命名空间错误 - AWS / ECS - Namespace error when creating new service Jenkins - gcp 实例 - 找不到 gcloud-service-account-secret-key.json - Jenkins - gcp instance - cant find gcloud-service-account-secret-key.json 使用 docker 容器创建 lambda function (AWS) 时出现问题:Z04A7DA3C5B15CAD85DA1EEBB2 没有访问权限 - Problem when creating a lambda function (AWS) using docker container: Lambda does not have permission to access the ECR image 如何将 GCP IAM 角色添加到服务帐号 - How to add GCP IAM roles to Service Account Docker - 错误:无法从非 TTY 设备执行交互式登录(GCP 服务帐户) - Docker - Error: Cannot perform an interactive login from a non TTY device (GCP Service Account) 仅在需要时实例 - GCP - Instance only when needed - GCP 有没有办法为部署在 GCP 计算实例中的 docker 容器设置“--rm”选项? - Is there a way to set the "--rm" option for a docker container deployed in a GCP compute instance? 使用GCP部署docker私有镜像到计算引擎实例 - Deploy docker private image to compute engine instance by using GCP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM