I’m using levant on nomad 1.1.6 and utilizing the fileContents
function to include an external YAML file.
job "traefik" {
region = "global"
datacenters = ["dc1"]
type = "system" # job will be deployed to each node
group "traefik" {
count = 1
task "traefik" {
driver = "docker"
config {
image = "traefik:v2.5"
network_mode = "host"
volumes = [
"local/traefik.yml:/etc/traefik/traefik.yml",
]
}
template {
# traefik configuration is loaded from external file
# https://learn.hashicorp.com/tutorials/nomad/dry-jobs-levant?in=nomad/templates
data = <<EOF
[[ fileContents "traefik.yml" ]]
EOF
destination = "local/traefik.yml"
}
resources {
cpu = 100
memory = 128
}
}
network {
port "http" {
static = 8080
}
port "api" {
static = 8081
}
}
service {
name = "traefik"
check {
name = "alive"
type = "tcp"
port = "http"
interval = "10s"
timeout = "2s"
}
}
}
}
The external YML file for configuring traefik contains a attribute reference ${attr.driver.docker.bridge_ip}
to connect to consul.
Consul is bound to 172.17.0.1:8500
but when deploying using levant deploy
traefik does not receive any services from consul-catalog provider.
Modifying the template to use the above static address, traefik works and services are available.
Node attributes show proper values:
driver.docker = 1
driver.docker.bridge_ip = 172.17.0.1
driver.docker.os_type = linux
driver.docker.runtimes = io.containerd.runc.v2,io.containerd.runtime.v1.linux,runc
driver.docker.version = 20.10.7
So my question is, ist this a levant issue, a nomad issue. How it is possible to use attributes in this place.
providers:
consulCatalog: # https://doc.traefik.io/traefik/providers/consul-catalog/#traefik-consul-catalog
prefix: traefik # the default
exposedByDefault: false # services need a traefik.enable=true tag
endpoint:
address: "${attr.driver.docker.bridge_ip}:8500" # IP address of docker0 interface
scheme: http
api:
dashboard: true
insecure: true # TODO Will it be available through https ?
entryPoints:
http:
address: ":8080"
traefik:
address: ":8081"
log:
level: DEBUG