1
  1. I have a marathon app running which runs postgres. [viz. db-instance]
  2. I also have another application running on marathon which needs to connect to the first app using a database URL in the jdbc properties file. [viz app-instance]

Both of them are dockarized. When marathon spins out the "db-instance" it starts on different slave node in the cluster.

So how do i specify the jdbc url in the "app-instance" so that it is able to connect to the "db-instance"

Santanu
  • 25
  • 1
  • 7

1 Answers1

1

You could use Mesos DNS for this. This way you will be able to specify not just the host:port in your app-instance to connect to db-instance but via name. Each application launched via Marathon will get a name like db-instance.marathon.mesos and this way you won't need to bother with the IP address but will be able to specify db connection string like db-instance.marathon.mesos:port.

Hope this helps.

serejja
  • 22,901
  • 6
  • 64
  • 72
  • have you tested this? AFAIU the client needs to know and understand SRV records to be able to get host and port for the db container – Gertjan Assies Oct 14 '16 at 14:50
  • Yes I was using mesos-dns and a similar thing, https://github.com/CiscoCloud/mesos-consul. The client doesn't need to know and understand SRV records as long as you set these services up as your primary DNS servers. You may read how to do this here https://mesosphere.github.io/mesos-dns/docs/ – serejja Oct 15 '16 at 13:47
  • still you need to 'hardcode' the port in your example which is undesirable – Gertjan Assies Oct 17 '16 at 09:12
  • Agree, but at that time we didn't find any better solution. Not sure if one exists now – serejja Oct 17 '16 at 09:16