如何在 GCP 中解析 "The external IP address 'IP_ADDRESS_NAME' was not found in region"
How to resolve "The external IP address 'IP_ADDRESS_NAME' was not found in region" in GCP
关于 Whosebug 的第一个问题。随时询问是否需要更多上下文,在此先感谢您。
我正在设置一个 Google Compute Engine 托管实例组,它有两个要求:
- 简单的 HTTPS 配置。因此使用带有负载均衡器的托管实例组。
- 用于第三方IP白名单的静态IP。
我知道静态 IP 使其无法水平扩展,但在这种情况下无关紧要。
我面临的问题是无法将静态 IP 地址应用于实例组,因为 GCE 声明在该区域中找不到该名称。问题是,静态 IP 地址区域是 europe-west4,托管组区域是 europe-west4a,所以它应该能够找到它,对吗?
所以我的问题是,为什么这不起作用?
我试过使实例组基于区域而不是基于区域,但这会产生同样的错误。
命令行抛出错误:
# [START create_template]
gcloud compute instance-templates create ${TEMPLATE} \
--image-family=${IMAGE_FAMILY} \
--image-project=${IMAGE_PROJECT} \
--machine-type=${MACHINE_TYPE} \
--scopes=${SCOPES} \
--metadata-from-file startup-script=${STARTUP_SCRIPT} \
--tags ${TAGS}\
--metadata BUCKET=${BUCKET} \
--address=${STATIC_IP_ADDRESS_NAME}
# [END create_template]
# Create the managed instance group.
# [START create_group]
gcloud compute instance-groups managed create ${GROUP} \
--base-instance-name ${GROUP} \
--size 1 \
--template ${TEMPLATE} \
--zone europe-west4-a
# [END create_group]
预期的输出是创建一个具有静态出口 IP 地址的计算引擎。
我收到以下错误。
ERROR: (gcloud.compute.instance-groups.managed.create) Could not fetch resource:
- Invalid value for field 'resource.instanceTemplate': 'https://www.googleapis.com/compute/v1/projects/companyproject-test/global/instanceTemplates/service-name-group-tmpl'. Unable to create an instance from instanceTemplate service-name-group-tmpl in zone europe-west4-a:
Invalid value for field 'instance.networkInterfaces[0].accessConfigs[0].natIP': The specified external IP address 'STATIC_IP_ADDRESS_NAME' was not found in region 'europe-west4'
在静态外部 IP 地址的文档中,他们声明该区域或区域的资源可以使用静态 IP 地址。请参阅文档中的“Static external IP addresses”。
此外,声明将地址添加到单个实例模板的文档是可能的。 Link
通过使用以下命令将静态 IP 地址分配给组中的单个实例解决了该问题:
# Retrieve the single instance name and save it in a variable
instance=`gcloud compute instance-groups managed list-instances name-group --zone=europe-west4-a --format="value(instance.basename())"`
# Remove the existing external NAT of the instance
gcloud compute instances delete-access-config $instance \
--access-config-name "External NAT" \
--zone=$ZONE
# Add the new external NAT that has the static address
gcloud compute instances add-access-config $instance \
--access-config-name "External NAT" \
--address $IP_ADDRESS \
--zone=$ZONE
关于 Whosebug 的第一个问题。随时询问是否需要更多上下文,在此先感谢您。
我正在设置一个 Google Compute Engine 托管实例组,它有两个要求:
- 简单的 HTTPS 配置。因此使用带有负载均衡器的托管实例组。
- 用于第三方IP白名单的静态IP。
我知道静态 IP 使其无法水平扩展,但在这种情况下无关紧要。
我面临的问题是无法将静态 IP 地址应用于实例组,因为 GCE 声明在该区域中找不到该名称。问题是,静态 IP 地址区域是 europe-west4,托管组区域是 europe-west4a,所以它应该能够找到它,对吗?
所以我的问题是,为什么这不起作用?
我试过使实例组基于区域而不是基于区域,但这会产生同样的错误。
命令行抛出错误:
# [START create_template]
gcloud compute instance-templates create ${TEMPLATE} \
--image-family=${IMAGE_FAMILY} \
--image-project=${IMAGE_PROJECT} \
--machine-type=${MACHINE_TYPE} \
--scopes=${SCOPES} \
--metadata-from-file startup-script=${STARTUP_SCRIPT} \
--tags ${TAGS}\
--metadata BUCKET=${BUCKET} \
--address=${STATIC_IP_ADDRESS_NAME}
# [END create_template]
# Create the managed instance group.
# [START create_group]
gcloud compute instance-groups managed create ${GROUP} \
--base-instance-name ${GROUP} \
--size 1 \
--template ${TEMPLATE} \
--zone europe-west4-a
# [END create_group]
预期的输出是创建一个具有静态出口 IP 地址的计算引擎。
我收到以下错误。
ERROR: (gcloud.compute.instance-groups.managed.create) Could not fetch resource:
- Invalid value for field 'resource.instanceTemplate': 'https://www.googleapis.com/compute/v1/projects/companyproject-test/global/instanceTemplates/service-name-group-tmpl'. Unable to create an instance from instanceTemplate service-name-group-tmpl in zone europe-west4-a:
Invalid value for field 'instance.networkInterfaces[0].accessConfigs[0].natIP': The specified external IP address 'STATIC_IP_ADDRESS_NAME' was not found in region 'europe-west4'
在静态外部 IP 地址的文档中,他们声明该区域或区域的资源可以使用静态 IP 地址。请参阅文档中的“Static external IP addresses”。
此外,声明将地址添加到单个实例模板的文档是可能的。 Link
通过使用以下命令将静态 IP 地址分配给组中的单个实例解决了该问题:
# Retrieve the single instance name and save it in a variable
instance=`gcloud compute instance-groups managed list-instances name-group --zone=europe-west4-a --format="value(instance.basename())"`
# Remove the existing external NAT of the instance
gcloud compute instances delete-access-config $instance \
--access-config-name "External NAT" \
--zone=$ZONE
# Add the new external NAT that has the static address
gcloud compute instances add-access-config $instance \
--access-config-name "External NAT" \
--address $IP_ADDRESS \
--zone=$ZONE