I have two Nomad jobs running in a Nomad cluster. One job needs to connect to the other job using the service address. This is because the target job is using whatever dynamic address/port that Nomad assigns to it.
The target job has a “service” defined: service-name-of-target-job
Nomad assigns the service and address similar to this: 10.254.0.37:64441
The source job tries to connect to the target service address using the Consul DNS address: service-name-of-target-job.service.consul
. However, the connection times out.
Doing a curl from the source job I see this:
curl -v "http://service-name-of-target-job.service.consul/"
* Trying 10.254.0.37:80...
As we can see, Consul DNS is only providing the IP address and not the dynamic port that is assigned, thus the source job is trying the default port 80, which is incorrect.
Is there a way to get the Consul DNS to provide the port as well as the IP? Or will I need to force the target job to use a static port?