从 Google Cloud 删除默认网络

从 Google Cloud 删除默认网络

尝试使用以下命令从 Google 云项目中删除默认网络时: gcloud compute networks delete default

返回以下错误:

`ERROR: (gcloud.compute.networks.delete) Could not fetch resource:
 - The network resource 'projects/<PROJECT-NAME>/global/networks/default' 
is already being used by 'projects/<PROJECT-NAME>/global/addresses/google- 
managed-services-default'`

如何解决此问题?

答案1

我也遇到了这个问题:

$ gcloud compute addresses list
NAME                                 ADDRESS/RANGE  TYPE      PURPOSE      NETWORK      REGION  SUBNET  STATUS
google-managed-services-test  10.21.96.0/20  INTERNAL  VPC_PEERING  test                  RESERVED

但是 CLI 在删除时会选择错误的区域:

$ gcloud compute addresses delete google-managed-services-test
The following addresses will be deleted:
 - [google-managed-services-test] in [us-central1]

Do you want to continue (Y/n)?  Y

ERROR: (gcloud.compute.addresses.delete) Could not fetch resource:
 - The resource 'projects/magic-test/regions/us-central1/addresses/google-managed-services-test' was not found

解决方案是将--global标志添加到delete命令中:

$ gcloud compute addresses delete --global google-managed-services-test
The following global addresses will be deleted:
 - [google-managed-services-test]

Do you want to continue (Y/n)?  Y

Deleted [https://www.googleapis.com/compute/v1/projects/magic-test/global/addresses/google-managed-services-test].

答案2

我的错误 gcloud compute addresses list暴露了资源并gcloud compute addresses delete google-managed-services-default删除了它

相关内容