This will not work with consul though since the mongodb container only talks over localhost to the injected envoy proxy.
But then I have todo someting like this:
I am forced to use different ports since the address is 127.0.0.1 to go via the envoy proxy. This means the other replicas will need to bind to weird mongo ports like 27018 and 27019.
It would be nice if instead of 127.0.01 you could use some kind of dns name like the picture above.
I would like to have something like this:
Then the mongo-1 upstream could be
But there are port collisions and stuff here I get that, not sure if there is a good solution for this.
What I do now is basically bind my different mongos to ports like 27018 and 27019 but I would like to avoid this if possible.
Now this is still a bit of an ugly solution. I would rather have had a statefulset but consul doesn’t seem to be able to route traffic to individual pods in a stateful set nicely. Or at least I have not gotten that to work. I commented on this issue on github.