variable "datacenters" { description = "List of datacenters to deploy to" type = list(string) default = ["dc1"] } variable "traefik_version" { description = "Traefik Docker image tag" type = string default = "v3.0" } variable "http_port" { description = "Port for HTTP traffic" type = number default = 80 } variable "https_port" { description = "Port for HTTPS traffic" type = number default = 443 } variable "api_port" { description = "Port for Traefik API/Dashboard" type = number default = 8081 } variable "nomad_address" { description = "Nomad HTTP address for service discovery" type = string default = "http://127.0.0.1:4646" } variable "enable_dashboard" { description = "Enable the Traefik dashboard" type = bool default = true } variable "log_level" { description = "Traefik log level (DEBUG, INFO, WARN, ERROR)" type = string default = "INFO" } variable "service_provider" { description = "Service discovery provider (nomad or consul)" type = string default = "nomad" } job "traefik" { type = "system" datacenters = var.datacenters group "traefik" { network { mode = "host" port "http" { static = var.http_port } port "https" { static = var.https_port } port "api" { static = var.api_port } } service { name = "traefik" port = "http" provider = var.service_provider tags = [ "traefik", "lb", ] check { type = "http" port = "api" path = "/ping" interval = "10s" timeout = "2s" } } task "traefik" { driver = "docker" config { image = "traefik:${var.traefik_version}" network_mode = "host" volumes = [ "local/traefik.yaml:/etc/traefik/traefik.yaml", ] } template { data = <<-EOF api: dashboard: {{ env "NOMAD_META_enable_dashboard" }} insecure: true ping: entryPoint: "api" log: level: {{ env "NOMAD_META_log_level" }} entryPoints: http: address: ":{{ env "NOMAD_PORT_http" }}" https: address: ":{{ env "NOMAD_PORT_https" }}" api: address: ":{{ env "NOMAD_PORT_api" }}" providers: nomad: prefix: "traefik" exposedByDefault: false endpoint: address: "{{ env "NOMAD_META_nomad_address" }}" EOF destination = "local/traefik.yaml" } meta { enable_dashboard = var.enable_dashboard log_level = var.log_level nomad_address = var.nomad_address } resources { cpu = 200 memory = 256 } } } }