How do i change name of default cluster connection, to use my DNS?

I have many clusters in MongoDB Cloud Atlas and many applications conected in this clusters.

When a need to reorganize ou change a application between the clusters, i need to change the URI in the applications. This is a lot of work, enter in git, change URI in configmaps and deploy de application to see the new database.

Example: mongodb+srv://user:pass@old.mongodb.net. Needs change to mongodb+srv://user:pass@new.mongodb.net. Here I used an example name that is provided when creating a cluster.

Have a way to use my own DNS in this URI to access the cluster?

Example: mongodb+srv://user:pass@cluster01.mydomain.com. In this way when i need to change my application database, i only need to change DNS and not the complete URI in applications.

I already see this documentation connection-string-uri-format, but i could’nt make it work

  1. I think that what you need is something like zookeeper.

  2. But nothing stops you from having one Atlas instance that contains the configuration of your applications.

For the above 2 you will need an application launcher that get the current URI for your application and then starts the application with the given configuration.

It surely could be done with DNS but as the solution above you would also need an application launcher. In this case, it would read TXT or CNAME records to get the URI.

But once you understand SRV records, may be, just may be, you could maintain your own SRV. After all SRV records simply supply a list of A records which are nodes of the cluster. For example, using your cluster01.mydomain.com, you could create an SRV record such as

_mongodb._tcp.cluster01.mydomain.com. 60 IN SRV 0 0 27017 cluster0-shard-00-00-jxeqq.mongodb.net.
_mongodb._tcp.cluster01.mydomain.com. 60 IN SRV 0 0 27017 cluster0-shard-00-01-jxeqq.mongodb.net.
_mongodb._tcp.cluster01.mydomain.com. 60 IN SRV 0 0 27017 cluster0-shard-00-02-jxeqq.mongodb.net.

which correspond the real cluster cluster0-jxeqq.mongodb.net used in the courses. After all an SRV simply supplies a list of hosts for a given service.

Before SRV records a PTR record could be used but I never experience PTR with SRV.