Gcloud 无法获取资源:指定的 IP 地址未分配给项目或不属于指定范围



我正在尝试将 GCP 上的虚拟机从一个项目迁移到另一个项目。我成功了,直到传输静态IP地址为止。

我将其与旧 VM 分离,然后删除/释放它。我转到新项目并尝试使用以下命令创建新实例:

gcloud compute instances create <name> --address x.x.x.x

并得到错误:

ERROR: (gcloud.compute.addresses.create) Could not fetch resource:
- Invalid value for field 'resource.address': 'x.x.x.x'. Specified 
IP address is not allocated to the project or does n
ot belong to the specified scope.

我想也许我需要先保留 IP 地址,并尝试:

gcloud compute addresses create <name> --addresses 
x.x.x.x --region us-east1

由此,得到了基本相同的东西——

ERROR: (gcloud.compute.addresses.create) Could not fetch 
resource:- Invalid value for field 'resource.address': 'x.x.x.x'. 
Specified IP address is not allocated to the project or does n
ot belong to the specified scope.

我非常密切关注他们的文档: - https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address

如果它已经被另一个实例在其自动 IP 生成中声明,我认为错误消息将与此不同。我还使用另一个 gcloud 命令来查看我所有的 IP 保留,并确认它在旧项目中处于活动状态。

只能选择已保留并分配给项目的 IP 地址。您不能只选择任何 IP 地址。您需要保留新的 IP 地址并更新 DNS 服务器上的 DNS 资源记录。

使用 gcloud 命令,确保指定--subnet,即:

gcloud --project=project-id compute addresses create 
"address-name" 
--region=us-central1 
--subnet=default 
--addresses=X.X.X.X

然后,您可以指定适合默认子网的任何X.X.X.X

最新更新