【问题标题】:Bringing Google Cloud costs to zero (compute engine)将 Google Cloud 成本降至零(计算引擎)
【发布时间】:2020-12-04 14:38:31
【问题描述】:

在我的一个项目的计费部分,每天都会列出 Compute Engine - E2 实例核心 12 小时的费用。但是 Compute Engine 部分没有实例。该项目实际上只包含无法转移的特殊 Google Maps API 密钥。

我还尝试禁用 Compute Engine API。不幸的是,这失败并出现以下错误:挂钩调用/轮询导致服务“compute.googleapis.com”的操作失败:无法关闭服务,因为它仍有资源在使用] 服务失败 [compute.googleapis.com]

有什么想法吗?

【问题讨论】:

    标签: google-cloud-platform google-compute-engine gcloud


    【解决方案1】:

    基于错误消息:“无法关闭服务,因为它仍有资源在使用] 服务失败 [compute.googleapis.com]”

    这意味着Compute Engine API下有资源,所以,你可以运行gcloud command to list当前实例或运行gcloud command to viewAsset Inventory,我建议你在Chrome隐身打开你的GCP项目窗口并使用cloud shell

    列出实例

    gcloud compute instances list
    

    列出资产清单

    gcloud asset search-all-resources
    

    注意:默认情况下,资产清单 API 未启用,因此,在运行命令后,您将收到以下消息:

    user@cloudshell:~ (project-id)$ gcloud asset search-all-resources
    API [cloudasset.googleapis.com] not enabled on project [project-id].
     Would you like to enable and retry (this will take a few minutes)?
    (y/N)?
    

    请输入 y,以启用 API 并能够看到命令的输出。

    话虽如此,当您在屏幕上看到结果时,您将能够识别 Compute Engine API 及其所有组件下的资源,例如

    ---
    additionalAttributes:
      networkInterfaces:
      - network: https://www.googleapis.com/compute/v1/projects/project-id/global/networks/default
        networkIP: 1.18.0.5
    assetType: compute.googleapis.com/Instance
    displayName: linux-instance
    location: us-central1-a
    name: //compute.googleapis.com/projects/project-id/zones/us-central1-a/instances/linux-instance
    project: projects/12345678910
    ---
    additionalAttributes: {}
    assetType: compute.googleapis.com/Disk
    displayName: linux-instance
    location: us-central1-a
    name: //compute.googleapis.com/projects/project-id/zones/us-central1-a/disks/linux-instance
    project: projects/12345678910
    ---
    

    如您所见,上面两行描述了实例 'linux-instance' 及其组件(磁盘和 IP 地址),它们都在 API -> compute 下。 googleapis.com

    如果您需要进一步帮助,请将命令的输出发送到 TXT 文件并删除敏感信息,例如:项目 ID、外部 IP、内部 IP,并与我共享输出,以便我查看.

    或者,您可以像我一样通过将实例名称、项目 ID、项目编号和 IP 地址替换为假数据来清理命令的输出。

    请记住,由于这是一个计费问题,GCP billing team 愿意听取您的意见。

    【讨论】:

      【解决方案2】:

      好奇。

      有些服务需要 Compute Engine 资源,例如Kubernetes Engine,但我认为,如果使用,资源总是暴露出来的。

      显示此资源用户的一种方法可能是枚举项目的服务并观察可能正在消耗 VM 的服务的结果:

      gcloud services list --enabled --project=[[YOUR-PROJECT]]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-12-10
        • 1970-01-01
        • 2016-10-09
        • 1970-01-01
        • 2021-01-12
        • 2018-02-23
        • 2018-06-09
        相关资源
        最近更新 更多