mongodb / mongodb-atlas-kubernetes

MongoDB Atlas Kubernetes Operator - Manage your MongoDB Atlas clusters from Kubernetes
http://www.mongodb.com/cloud/atlas
Apache License 2.0
152 stars 78 forks source link

AtlasDBUser secret is missing a private connection string for a VPC-peered GCP or Azure #347

Closed denist-huma closed 1 year ago

denist-huma commented 2 years ago

What did you do to encounter the bug? Steps to reproduce the behavior:

Cannot connect from a VPC-peered GKE to Atlas using standard connection string given by AKO Atlas KO gives a standard connection string.

$ kubectl run -i -t mongosh --image=bitnami/mongodb -- bash
^[OPIf you don't see a command prompt, try pressing enter.
I have no name!@mongosh:/$ mongo "mongodb+srv://my-cluster.l2l7u.gcp.mongodb.net" --username demo-user
MongoDB shell version v4.4.10
Enter password: 
connecting to: mongodb://my-cluster-shard-00-00.l2l7u.gcp.mongodb.net:27017,my-cluster-shard-00-01.l2l7u.gcp.mongodb.net:27017,my-cluster-shard-00-02.l2l7u.gcp.mongodb.net:27017/?###
{"t":{"$date":"2021-11-23T13:02:54.327Z"},"s":"I",  "c":"NETWORK",  "id":4333208, "ctx":"ReplicaSetMonitor-TaskExecutor","msg":"RSM host selection timeout","attr":{"replicaSet":"atlas-###-shard-0","error":"FailedToSatisfyReadPreference: Could not find host matching read preference { mode: \"nearest\" } for set atlas-###-shard-0"}}

*** You have failed to connect to a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

Error: connect failed to replica set atlas-###-shard-0/my-cluster-shard-00-00.l2l7u.gcp.mongodb.net:27017,my-cluster-shard-00-01.l2l7u.gcp.mongodb.net:27017,my-cluster-shard-00-02.l2l7u.gcp.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1

What did you expect? A clear and concise description of what you expected to happen.

I expect to have a private string also present in a secret. I can add -pri to "mongodb+srv://my-cluster-pri.l2l7u.gcp.mongodb.net/pp_dev" and do check. The private string connection is successful.

I have no name!@mongosh:/$ mongo "mongodb+srv://my-cluster-pri.l2l7u.gcp.mongodb.net/pp_dev" --username demo-user 
MongoDB shell version v4.4.10
Enter password: 
connecting to: mongodb://my-cluster-shard-00-00-pri.l2l7u.gcp.mongodb.net:27017,my-cluster-shard-00-01-pri.l2l7u.gcp.mongodb.net:27017,my-cluster-shard-00-02-pri.l2l7u.gcp.mongodb.net:27017/pp_dev?###
Implicit session: session { "id" : UUID("###") }
MongoDB server version: 4.2.17
WARNING: shell and server versions do not match
MongoDB Enterprise atlas-###-shard-0:PRIMARY>

Clusters with peered networks have a Private IP for Peering connection string. This string resolves to IP addresses available to:

Peered networks in Azure or GCP AWS peered clusters with a custom DNS service.

Private Connection Strings Private connection strings follow this format:

mongodb://xyx456-shard-00-00-pri.ab123.mongodb.net:27017 mongodb+srv://xyx456-pri.ab123.mongodb.net

What happened instead? A clear and concise description of what happened instead

Screenshots If applicable, add screenshots to help explain your problem.

Operator Information

Kubernetes Cluster Information

Additional context Add any other context about the problem here.

If possible, please include:

jhill072 commented 2 years ago

Would image version 0.7.0 provide what you are looking for? It includes this PR which adds the private connection string returned from the Atlas API as another key in the generated secret: https://github.com/mongodb/mongodb-atlas-kubernetes/pull/344

denist-huma commented 2 years ago

@jhill072 thanks for th PR! yes it is related to my request! it is very good that you ping me because I don't see it in changes while I was updating to the 0.7.0. Also I don't find it documented.

github-actions[bot] commented 1 year ago

This issue has gone 30 days without any activity and meets the project’s definition of 'stale'. This will be auto-closed if there is no new activity over the next 60 days. If the issue is still relevant and active, you can simply comment with a 'bump' to keep it open. Thanks for keeping our repository healthy!