如何在 Google 云 Shell 中更新配置的默认计算区域和区域 - CLI

How to Update Default Compute Zone and Region of Configurations in Google Cloud Shell - CLI

我通过 gcloud init 命令创建了多个 configurations。它没有给我设置默认计算区域或默认计算区域的选项。

当我运行、gcloud config configurations list时,默认zone和region都是空的

gcloud config configurations ... 仅提供以下命令。 (无更新命令)

初始化配置时不能设置默认区域和可用区吗?如果不是,我该如何更新 gcloud 配置的某些字段?例如:COMPUTE_DEFAULT_ZONECOMPUTE_DEFAULT_REGION

有一个名为 gcloud config set 的关联 gcloud 命令,用于 set/update 当前活动配置中的属性。这意味着您可以创建配置、激活它,然后执行 gcloud config set 命令来更改设置。查看文档,compute regioncompute zone 都被记录为分别设置默认区域和默认区域。

就像 Kolban 提到的,如果您查看设置的配置,您会发现:

gcloud config set compute/zone [YOUR ZONE NAME HERE]

示例:(gcloud 配置集 compute/zone asia-east1-b)

另外,我也喜欢同时设置区域

gcloud config set compute/region [YOUR REGION NAME HERE]

示例:(gcloud 配置集 compute/region asia-east1)