我想为我的 App Engine 实例设置静态出站 IP 地址,因此我浏览了 this 文档。我已执行所有步骤,但无法看到 Cloud NAT 中针对我在步骤 5 中指定的 IP 地址记录的任何流量(保留静态 IP 地址)。我意识到本文档适用于 App Engine 标准环境,并且我在 App Engine Flex 环境中部署了应用程序的实例。本文档是否也适用于 App Engine Flex 环境?如果没有,我应该如何为我的 App Engine Flex 实例设置出站静态 IP 地址?
gcloud compute networks subnets create my_subnet \
--range=10.123.0.32/28 \
--network=default \
--region=us-east1
# Go to the GCP dashboard, look for subnets in your VPC,
# select this subnet and set Private Google Access to ON.
# idk if --enable-private-ip-google-access does the same thing, it might.
gcloud compute routers create my_router \
--network=default \
--region=us-east1
gcloud compute addresses create my_ip_name \
--region=us-east1
gcloud compute routers nats create my_nat \
--router=my_router \
--region=us-east1 \
--nat-custom-subnet-ip-ranges=my_subnet \
--nat-external-ip-pool=my_ip_name
将此网络配置放入具有该出站 IP 的服务的 app.yaml 中:
network:
name: default
subnetwork_name: my_subnet
instance_ip_mode: internal
替换您需要的任何内容,例如 my_subnet、my_ip_name、my_router、区域、网络和子网网络范围。 如果您将其保留为 CIDR /28,则可以在 VPC 连接器中使用该子网,但我认为这不适用于 App Engine Flex。 您链接的文档适用于 App Engine Standard,这是不同的。我不记得在任何地方看到过这个解决方案的记录。