Hi, this is a newbie question. I’m trying to deploy a web app, so I need to deploy several services like database, workers, redis, the app and some others.
I don’t know how to communicate with them. I come from kubernetes and docker-compose where you can just connect to “db” and it was automatically resolved.
I think I have three options:
- Create env files or export env templates from consul and read them in the app.
- Use a dns server like dnsmasq where nomad and consul runs.
- Use traefik?
I’ve tried 1 & 2. For 1, I don’t think is the best way. Do I need to reload the app if the job changes to another node?
I’m trying to figure out how to do it with (2). I have dnsmasq and I have configured this:
# Enable forward lookup of the 'consul' domain: server=/consul/127.0.0.1#8600
In the node I can run
dig db.service.consul and it’s resolved successfully, but on the task (I’m using the docker driver) it doesn’t work. The dns servers in
resolve.conf aren’t the ones expected.
And about (3), I don’t know if it’s possible or it’s an acceptable way of doing it.