【问题标题】:VPC peering MongoDB Atlas with GCP Kubernetes enginVPC 与 GCP Kubernetes 引擎对等 MongoDB Atlas
【发布时间】:2021-12-30 12:33:48
【问题描述】:

我关注https://docs.atlas.mongodb.com/security-vpc-peering/ 并创建了 VPC 对等互连并检查了激活的双方(GCP 和 Atlas)。 并且我的 GCP VPC-native 已启用。

mongodb cidr 192.168.0.0/16

GCP pod ip 范围 10.4.0.0/16

我将 10.4.0.0/16 添加到 Atlas 白名单 并尝试通过其中一个 pod 中的私有连接字符串进行连接

mongo "mongodb+srv://id:pass0@dbname-pri.some.mongodb.net/dbname"

但它返回错误

*** You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP allowlist allows connections from your network.
Error: Could not find host matching read preference { mode: "nearest" }

nslookup 在 pod 中显示到 mongodb 集群

Server:         10.4.128.10
Address:        10.4.128.10#53

Name:   dbname-pri.some.mongodb.net
Address: 192.168.254.213

我刚刚将白名单 0.0.0.0/0 添加到 Atlas 中。但它返回相同的错误。肯定不是白名单的问题。

我应该设置防火墙还是其他?

【问题讨论】:

    标签: google-kubernetes-engine mongodb-atlas vpc-peering


    【解决方案1】:

    我找到了答案!

    我希望这对与我有同样问题的人有所帮助。

    解决方案

    The mongodb Atlas cluster is created AWS based. 
    this AWS based cluster cannot be connected with GCP via VPC peering.
    
    If you want to connect to GCP, you should make GCP based mongodb cluster.
    

    关键问题是。还有其他几点是,

    1. 应该使用带有“-pri”的私有连接字符串
    2. 应启用 GCP VPC-native
    3. 使用 CIDR GCP pod ip range(你可以显示这个 GCP kubernetes 主页)

    这会有帮助。

    【讨论】:

      猜你喜欢
      • 2021-12-20
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 2020-12-07
      • 2021-06-06
      • 1970-01-01
      • 2019-07-14
      • 2021-04-07
      相关资源
      最近更新 更多