gpt4 book ai didi

google-app-engine - 连接 Google App Engine 和 Google Compute Engine

转载 作者:行者123 更新时间:2023-12-03 15:25:01 39 4
gpt4 key购买 nike

我在 Googl Compute Engine 和 Google App Engine 标准环境中的应用程序中创建了一个 VM 实例。我打算在 App Engine 中使用我的应用程序,在 Compute Engine 中使用我的数据库服务器。但是,我无法通过内部 IP 在两者之间进行连接。这可能吗?应用程序和数据库位于同一区域( us-east1 ),但 IP 连接不起作用,只能使用外部 IP。显然,防火墙的规则是正确的。

最佳答案

As of April 9, 2019, you can use the serverless VPC connector.



这将允许您的 App Engine 应用程序连接到 Google Cloud Platform 上 VPC 网络中的其他内部资源,例如 Compute Engine VM 实例、Cloud Memorystore 实例和任何其他资源 具有内部 IP 地址 .

要创建连接器:
$ gcloud services enable vpcaccess.googleapis.com
$ gcloud beta compute networks vpc-access connectors create CONNECTOR_NAME \
--network VPC_NETWORK --region REGION --range IP_RANGE
$ gcloud beta compute networks vpc-access connectors describe CONNECTOR_NAME --region REGION

注意:您可以在 Google Cloud Platform Console 中查看当前保留的 IP 范围。 .您可以 选择任何未使用的 CIDR/28 IP 用于连接器的范围,例如 10.8.0.0/28。
$ gcloud beta compute networks vpc-access connectors create my-vpc-connector \
--region=us-central1 --range=10.8.0.0/28
Create request issued for: [my-vpc-connector]
Waiting for operation [xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx] to complete...done.
Created connector [my-vpc-connector]

要将您的连接器连接到服务,请将其添加到您的服务 app.yaml 文件:
vpc_access_connector:
name: "projects/PROJECT_ID/locations/REGION/connectors/CONNECTOR_NAME"

部署服务:
$ gcloud beta app deploy

注意:要使用无服务器 VPC 访问,请确保您使用 gcloud beta 来部署您的服务。您可以通过运行 来访问 beta 命令。 gcloud 组件安装测试版 .

部署服务后,它可以向 Internal IP addresses 发送请求或 DNS Names为了访问您的 VPC Networks 中的资源.如果出现任何问题,请等待大约一小时或更长时间,让连接器在 GCP 全局网络中完全传播。

关于google-app-engine - 连接 Google App Engine 和 Google Compute Engine,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47308749/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com