we run into a issue with our service and consul setup and are not sure, if we will be able to solve this in our infrastructure.
Situation is, that we have consul running as our service discovery and DNS system.
We register our services including MongoDB in consul and are able to resole the services by the service names to get the working servers and backends behind.
The problem is, that consul resolves services like this:
host -t SRV mongos-instance-appRouter.service.eu1.consul mongos-instance-appRouter.service.eu1.consul has SRV record 1 1 27017 mongodb16.eu1.sprd.net.node.eu1.consul. mongos-instance-appRouter.service.eu1.consul has SRV record 1 1 27017 mongodb17.eu1.sprd.net.node.eu1.consul.
Everything is right so far, but the mongodb driver forces that when using the “mongodb+srv” protocol, that it allows using the resolved host names only, if the “parent domain” of the service is the very same like the one of the resolved hosts.
In our case, where
the parent domains differs:
“service.eu1.consul” vs. “node.eu1.consul” and with this, the mongo driver do not allow to connect …
mongo mongodb+srv://dev:password@mongos-instance-appRouter.service.eu1.consul/?ssl=false FailedToParse: Hostname mongodb16.eu1.sprd.net.node.eu1.consul. is not within the domain service.eu1.consul
MongoDB also stated this in the docu:
(check under the “Important” note there)
Has anybody a Idea or hint, if and how we could make this work?
Thanks in advance …