【问题标题】:Connecting a Google Cloud Run instance to MongoDB将 Google Cloud Run 实例连接到 MongoDB
【发布时间】:2020-11-20 12:51:51
【问题描述】:

我正在尝试将 Cloud Run 服务连接到 MongoDB Atlas 服务器,而无需将所有 IP 列入白名单,但我无法做到。 我已经尝试过this 教程,但它不适用于 mongo。我尝试了 SSH 隧道,但也没有用。

【问题讨论】:

  • 作为教程的作者,我可以说它是用于http/https代理的,所以预计它不适用于mongodb有线协议。

标签: python mongodb google-cloud-platform google-cloud-run mongodb-atlas


【解决方案1】:

目前,这是正确的教程。将来,您将能够使用 Cloud NAT 对 Cloud Run 传出流量进行 nat。我希望很快。 (Cloud Run 现在兼容无服务器 VPC 访问,因此您可以直接使用私有 IP 访问您的代理计算引擎,这样更安全!)

另一种解决方案是将MongoDB Atlas peering 与您的 VPC 结合使用。并且因为Cloud Run is now compliant with serverless VPC connector,您可以通过 VPC 私下访问您的 MongoDB Atlas。

注意:但它仅适用于付费 Mongo 实例

【讨论】:

    【解决方案2】:

    更新(2020 年 10 月):

    您现在可以使用 VPC 连接器并配置 Cloud NAT,为连接到外部端点(例如 MongoDB Atlas)的 Cloud Run 容器配置静态出口 IP。

    在此处阅读设置指南:https://cloud.google.com/run/docs/configuring/static-outbound-ip

    【讨论】:

      猜你喜欢
      • 2019-10-10
      • 2021-12-25
      • 2019-10-28
      • 2019-09-16
      • 2020-07-01
      • 1970-01-01
      • 2021-10-04
      • 2020-05-27
      • 1970-01-01
      相关资源
      最近更新 更多