I seem to be able to follow all the steps and everything almost seems to work.
I’m able to run the demo web app and traefik jobs with nomad.
The demo web app doesn’t seem to have any problem registering with consul (see the screen shot below), but the traefik job can’t seem to connect to consul. I keep getting the folllowing error.
time="2020-12-31T16:25:02Z" level=info msg="Configuration loaded from file: /etc/traefik/traefik.toml"
time="2020-12-31T16:25:17Z" level=error msg="error get consul catalog data, Get \"http://127.0.0.1:8500/v1/catalog/services\": dial tcp 127.0.0.1:8500: connect: connection refused" providerName=consulcatalog
time="2020-12-31T16:25:17Z" level=error msg="Provider connection error Get \"http://127.0.0.1:8500/v1/catalog/services\": dial tcp 127.0.0.1:8500: connect: connection refused, retrying in 676.526777ms" providerName=consulcatalog
time="2020-12-31T16:25:32Z" level=error msg="error get consul catalog data, Get \"http://127.0.0.1:8500/v1/catalog/services\": dial tcp 127.0.0.1:8500: connect: connection refused" providerName=consulcatalog
time="2020-12-31T16:25:32Z" level=error msg="Provider connection error Get \"http://127.0.0.1:8500/v1/catalog/services\": dial tcp 127.0.0.1:8500: connect: connection refused, retrying in 502.970353ms" providerName=consulcatalog
time="2020-12-31T16:25:48Z" level=error msg="error get consul catalog data, Get \"http://127.0.0.1:8500/v1/catalog/services\": dial tcp 127.0.0.1:8500: connect: connection refused" providerName=consulcatalog
time="2020-12-31T16:25:48Z" level=error msg="Provider connection error Get \"http://127.0.0.1:8500/v1/catalog/services\": dial tcp 127.0.0.1:8500: connect: connection refused, retrying in 573.428123ms" providerName=consulcatalog
I believe there are a couple of issues why this is not working. The first is that Docker’s host networking mode only works on Linux, and is not available on macOS or Windows.
The host networking driver only works on Linux hosts, and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.
Second, I assume you’re running this on a recent version of Nomad (0.12.x or higher). The job file will not work as written on recent versions because the network block can no longer be placed under job -> group -> task -> resources (see Nomad 0.12: Task Network Resource deprecation).
The job file needs to be modified to move the network stanza to job -> group -> network. Correspondingly the service definition needs to be moved from under task to job -> group -> service in order for the service’s port label reference to be valid.
Here’s a modified job file for Traefik that I have verified works on Linux.
Definitely helps. Thanks so much. At least I know I wasn’t doing something obviously wrong.
Just to be clear, at present even if I “update” the job file, following the current tutorial on my mac won’t work because the network mode = “host” is not supported on mac? And I should just wait until someone has a chance to update the tutorial for a mac workaround?
Meanwhile, I have access to a Redhat instance, so I’ll try to follow the tutorial again on that system.
Yes, even if you update the job file it will not work on macOS since Docker’s host networking mode is not supported on that platform. The tutorial could be updated to deploy Traefik as an exec task in Nomad which should overcome this limitation.
You should have more success trying this on that Linux instance.