获取标签和GCE实例状态的最快方法? [英] Fastest way to fetch tags and status of GCE instances?
问题描述
当我使用GCE Linux实例(CPU负载> = 1.0)执行3D图形渲染时,describe
命令需要花费30秒钟以上的时间来执行.
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
运行50个此类实例并分别查询每个实例时,这将花费25分钟以上的时间.
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?
推荐答案
gcloud compute instances list
应该可以执行您想要的操作.为了获取有关标签和状态的信息,您需要使用--format
标志:
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']
请查看gcloud topic formats
和gcloud topic projections
的输出,以获取有关格式化的更多信息.
Take a look at the output of gcloud topic formats
and gcloud topic projections
for more information on formatting.
这篇关于获取标签和GCE实例状态的最快方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!