简体   繁体   English

从 GCP 中的所有项目获取所有虚拟机的列表

[英]Getting a list of all VMs from all Projects in GCP

I am new to GCP, and trying to get a list of all the VMs excluding GKEs from all the projects in a GCP organization.我是 GCP 的新手,并试图从 GCP 组织的所有项目中获取除 GKE 之外的所有 VM 的列表。 I wanted to check if anyone was able to do it using a script or a command, perhaps.也许我想检查是否有人能够使用脚本或命令来做到这一点。 Any help would be greatly appreciated.任何帮助将不胜感激。

I can get the list of VMs for a single project but not from all the projects recursively.我可以获取单个项目的 VM 列表,但不能递归地从所有项目中获取。 There are quite a few projects to get the list of VMs manually.有相当多的项目需要手动获取虚拟机列表。

Apologies.道歉。 I was able to run the query to filter out only VM instances and exclude GKE instances from all projects using the following query我能够运行查询以仅过滤掉 VM 实例并使用以下查询从所有项目中排除 GKE 实例

gcloud asset search-all-resources \
--scope='organizations/<Organization ID>' \
--query='NOT labels:goog-gke-node' \
--asset-types='compute.googleapis.com/Instance' \
--order-by='createTime'

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM