【问题标题】:Can I run gcloud compute instances get-guest-attributes command with only providing "ProjectName" (or) "zoneName" without compute instance name我可以运行 gcloud compute instances get-guest-attributes 命令,只提供“ProjectName”(或)“zoneName”而不提供计算实例名称
【发布时间】:2020-07-28 02:03:50
【问题描述】:

在我的 GCP 项目中,我有 100 个计算实例,我正在使用 gcloud compute instances get-guest-attributes 命令从每个计算实例中提取“访客属性”。

在这个过程中,我必须调用 gcloud 命令 100 次,并且我正在使用脚本来运行 100 次。但该命令仍然会运行 100 次。

有没有办法根据“ProjectName”(或)“ZoneName”提取所有“Guest Attributes”。因此,通过一个命令,我将能够获取该项目的所有计算实例详细信息。我在 GCP 帮助中找不到任何内容。

【问题讨论】:

    标签: google-cloud-platform gcloud


    【解决方案1】:

    查看documentation 的访客属性,API 调用需要“实例”字段。 如果您使用的是配置管理,则可以通过从实例中访问元数据来检索信息:

    curl http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes/namespace/ -H "Metadata-Flavor: Google"
    

    您选择要查询的命名空间的位置。它仍然会在每个实例中运行。

    【讨论】:

      猜你喜欢
      • 2019-08-17
      • 2016-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-07
      • 2021-11-20
      • 1970-01-01
      相关资源
      最近更新 更多