如何 link 一个 google 云虚拟机到实例调度?

How to link a google cloud vm to an instance schedule?

我想每天在特定时间 运行 我的 google 云服务器。我为此设置了一个实例计划,但是当我尝试 link 我的虚拟机到计划时,它给了我以下错误:

Compute Engine System service account service-390738840624@compute-system.iam.gserviceaccount.com needs to have [compute.instances.start] permissions applied in order to perform this operation.

有人知道怎么解决吗?

服务帐号service-390738840624@compute-system.iam.gserviceaccount.com没有权限为compute.instances.start[=26的角色=].

以下 IAM 角色具有所需的权限:

  • roles/compute.instanceAdmin
  • roles/compute.instanceAdmin.v1

以下命令将第一个角色添加到服务帐户:

将 $PROJECT_ID 替换为您的项目 ID(不是项目名称)。

gcloud projects add-iam-policy-binding $PROJECT_ID \
--member serviceAccount:service-390738840624@compute-system.iam.gserviceaccount.com \
--role roles/compute.instanceAdmin

您的帐户,您是 运行 命令的帐户,必须具有 grant/modify 服务帐户上的 IAM 角色的权限。如果您没有正确的权限,则需要让项目所有者或编辑为您执行此操作。

为了完成任务,GCP 要求您授予服务帐户 “service-390738840624@compute-system.iam.gserviceaccount.com” 使用权限 “compute.instances.start” 但服务帐户没有执行任务的正确权限。

When you set up an instance to run as a service account, you determine the level of access the service account has by the IAM roles that you grant to the service account. If the service account has no IAM roles, then no API methods can be run by the service account on that instance.

要授予、更改和撤销对单个服务帐户的访问权限,请参阅this guide

请注意,要管理对服务帐户的访问权限,您需要一个包含以下权限的角色:

  • *iam.serviceAccounts.get
  • iam.serviceAccounts.list
  • iam.serviceAccounts.getIamPolicy
  • iam.serviceAccounts.setIamPolicy*

如果您想知道您的帐户包含哪些权限,请参考this guide

如果您没有适当的权限来授予权限,请咨询您的系统管理员。

要了解有关计算引擎角色和权限的更多信息,请follow this link

如果您想了解更多关于服务帐户的信息,请follow this link

要了解更多关于使用 Google 调度程序调度计算实例的过程,请 follow this link

CLI 答案有效,但如果您不使用终端,这里是直接在平台上执行的步骤:

  1. 转到 IAM
  2. 屏幕右侧select“包括Google-provided角色授权”
  3. 查找包含文本“compute-system.iam.gserviceaccount.com”的主体
  4. 编辑(右边有小笔)
  5. 从显示的弹出窗口中 select“+添加另一个角色”,select 角色“计算实例管理员”(可以在括号中显示 beta 或 v1)

这解决了我的问题