具有網路對等互連的 Google Cloud App Engine

具有網路對等互連的 Google Cloud App Engine

我正在嘗試透過對等連接將 App Engine 應用程式連接到 MongoDB Cloud。

我的 GCP 中的所有服務都使用名為「main」的非預設網路。我已經與 terraform 設定了對等連線:

resource "google_compute_network_peering" "mongodb_peering" {
  name         = "mongodb-peering"
  network      = google_compute_network.main.self_link
  peer_network = "projects/${mongo-cloud-project}/global/networks/${mongo-cloud-network}"
}

它按預期工作。

據推測 App Engine 使用預設 VPC 網路。

當我嘗試在預設網路上建立第二個連線時,由於範圍重疊而出現錯誤。因此,我剛剛刪除了與主網路的對等互連,並使用預設網路設定了一個新的對等互連。

App Engine 應用程式仍然無法透過對等連接連接到 mongodb。

應用.yaml:

runtime: nodejs12

instance_class: F4

handlers:
  - url: /.*
    secure: always
    redirect_http_response_code: 301
    script: auto

automatic_scaling:
  max_instances: 2
  max_concurrent_requests: 80

inbound_services:
  - warmup

答案1

在您的情況下,您不能有 2 個或更多使用相同重疊 IP 範圍的 VPC 對等互連。這會造成混亂,因為將以相同的優先權建立路由。

正如 @jabbson 指出的,該應用程式預設不使用您的任何網路。所以你需要建立無伺服器 VPC 存取連接器連接您的 VPC。

相關內容