Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud platform 如何使用gcloud cli获取操作系统类型_Google Cloud Platform_Gcloud - Fatal编程技术网

Google cloud platform 如何使用gcloud cli获取操作系统类型

Google cloud platform 如何使用gcloud cli获取操作系统类型,google-cloud-platform,gcloud,Google Cloud Platform,Gcloud,我的gcp项目中运行了几个实例 因此,我需要迭代每个实例并获取操作系统版本,如果操作系统版本与某个值匹配,我需要执行另一个gcloud命令来获取已安装的库 因此,我使用此命令迭代每个实例: $(gcloud compute instances list --format="value(name)") // which gives the output as below name: temp-1 --- name: temp-2 --- name: test1 我还需要去

我的
gcp
项目中运行了几个实例

因此,我需要迭代每个实例并获取操作系统版本,如果操作系统版本与某个值匹配,我需要执行另一个
gcloud
命令来获取已安装的库

因此,我使用此命令迭代每个实例:

$(gcloud compute instances list --format="value(name)")

// which gives the output as below

name: temp-1
---
name: temp-2
---
name: test1
我还需要去掉
名称:

  • 我需要使用
    /etc/os-release

  • 有没有可能在每台服务器(temp-1、temp-2、test1)中使用ssh(不使用真正的ssh-ing)并执行
    awk-F='/^NAME/{print$2}'/etc/os release
    命令,并将结果返回到命令行?

    我看到了几种方法。您可以使用以下任一命令:

    $ gcloud compute ssh --zone us-central1-a instance-1 --command "uname -a"
    Linux instance-1 4.19.0-11-cloud-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64 GNU/Linux
    
    $ gcloud compute ssh --zone us-central1-a instance-1 -- uname -a
    Linux instance-1 4.19.0-11-cloud-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64 GNU/Linux
    Connection to n.n.n.n closed.
    
    或者,在规模上,您可以使用VM Manager产品: