I’ve got a replica set running in a kubernetes cluster and am trying to connect to it using a custom DNS name.
nslookup succeeds in resolving the name, as does telnet, ping
root@rabbitmq-1:/# nslookup mongodb-0.private.dev.wellpepper.com
Server: 10.0.0.10
Address: 10.0.0.10#53
Name: mongodb-0.default.svc.cluster.local
Address: 10.0.240.63
Connecting using the original name works:
root@rabbitmq-1:/# mongo mongodb-0.default.svc.cluster.local
MongoDB shell version v4.0.22
connecting to: mongodb://mongodb-0.default.svc.cluster.local:27017/test?gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("b5c470fa-f52a-4103-88ba-3ec1be769a6b") }
MongoDB server version: 3.6.21
WARNING: shell and server versions do not match
MainRepSet:PRIMARY>
However, connecting with the rewritten name does not:
root@rabbitmq-1:/# mongo mongodb-0.private.dev.wellpepper.com
MongoDB shell version v4.0.22
connecting to: mongodb://mongodb-0.private.dev.wellpepper.com:27017/test?gssapiServiceName=mongodb
2021-02-04T20:16:54.944+0000 E QUERY [js] Error: couldn't connect to server mongodb-0.private.dev.wellpepper.com:27017, connection attempt failed: HostNotFound: Could not find address
for mongodb-0.private.dev.wellpepper.com:27017: SocketException: Host not found (authoritative) :
connect@src/mongo/shell/mongo.js:356:17
Any troubleshooting hints?