Hi I am using Nomad / Consul and Traefik stack.
I have provisiooned traefik stack using Nomad as service as seen below:
job "traefikv3" {
datacenters = ["dc1"]
type = "system"
group "traefik" {
count = 1
network {
port "http"{
static = 80
}
port "admin"{
static = 8081
}
}
service {
name = "traefik-http"
provider = "nomad"
port = "http"
}
task "server" {
driver = "docker"
config {
image = "registry.local/traefik:v2.9"
network_mode = "host"
ports = ["admin", "http"]
args = [
"--api.dashboard=true",
"--api.insecure=true", ### For Test only, please do not use that in production
"--entrypoints.web.address=:${NOMAD_PORT_http}",
"--entrypoints.traefik.address=:${NOMAD_PORT_admin}",
"--providers.consulcatalog=true",
"--providers.consulcatalog.exposedByDefault=false",
"--providers.consulcatalog.endpoint.address=http://<CONSUL ENDPOINT>:8500",
"--providers.consulcatalog.prefix=traefik",
"--providers.consulcatalog.defaultrule=Host(`traefik.local.com`)",
"--log.filePath=/var/log/traefik//traefik.log",
"--log.level=DEBUG"
]
}
}
}
}
I see that traefik running on all my Nomad agent hosts as seen below and I can browse on each
I now created service in Nomad with a definition as seen below
job "email-handler-api" {
datacenters = ["dc1"]
group "api" {
scaling {
min = 1
max = 10
enabled = true
}
spread {
attribute = "${node.unique.id}"
}
network {
port "http"{
to = 80
}
}
service {
name = "emailhandler-api"
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.routers.http.rule=Path(`/emailhandler-api`)",
]
check {
type = "http"
path = "/index.html"
interval = "10s"
timeout = "5s"
}
}
task "server" {
env {
PORT = "${NOMAD_PORT_http}"
NODE_IP = "${NOMAD_IP_http}"
ASPNETCORE_ENVIRONMENT = "dev"
HashiVaultRoleId_arch = "e94158b9-1709-3aeb-d08a-2c010871eecd"
}
driver = "docker"
config {
image = "registry.local/emailhandler.webapi:0.1.9"
ports = ["http"]
force_pull = true
}
}
}
}
I see in consul that service is healthy.
I can directly browse the endpoint from the nomad agent IP and randomly assigned. port by IP and service is working just fine
Traefik also shows that service is registered fine
I then created a host entry for treafik.local.com for one of the traefik hosts.
When I try to browse http://traefik.local.com/emailhandler-api/ I get 404
Can someone please assist me with this issue?
Thanks a lot