I followed https://docs.atlas.mongodb.com/security-vpc-peering/ and created VPC peering and checked activated both side (GCP and Atlas). and My GCP VPC-native is enabled.
mongodb cidr 192.168.0.0/16
GCP pod ip range 10.4.0.0/16
I added 10.4.0.0/16 into Atlas white list and try to connect via private connection string in one of pods
mongo "mongodb+srv://id:[email protected]/dbname"
but it returns error
*** 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 in pod to mongodb cluster shows
Server: 10.4.128.10
Address: 10.4.128.10#53
Name: dbname-pri.some.mongodb.net
Address: 192.168.254.213
I just added whitelist 0.0.0.0/0 into Atlas. but it returns same errors. it may definitely not the problem of whitelist.
Should I setup firewall or something else?
I found an answer!
I hope this help to people suffering with same problems with me.
Solution
The key issue was that. and some other points are,
this would be help.