Fastest way to fetch tags and status of GCE instances?

旧城冷巷雨未停 提交于 2019-12-12 03:28:29

问题


When I perform 3D graphics rendering using GCE Linux instances (CPU load >= 1.0), the describe command takes more than 30 seconds to execute.

gcloud compute instances describe render-1

When running 50 such instances and querying each one individually, this takes more than 25 minutes.

Is there a faster way to fetch this data?


回答1:


gcloud compute instances list should do what you want. In order to get information on tags and status, you'll want to use the --format flag:

$ gcloud compute instances list --format=json
[...]
$ gcloud compute instances list --format='table(name,status,tags.list())'
NAME                              STATUS      TAGS
instance-name                     RUNNING     fingerprint=AAAAAAAAAAA=
instance-2-name                   RUNNING     fingerprint=AAAAAAAAAAA=,items=[u'http-server', u'https-server']

Take a look at the output of gcloud topic formats and gcloud topic projections for more information on formatting.



来源:https://stackoverflow.com/questions/37047089/fastest-way-to-fetch-tags-and-status-of-gce-instances

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!