Files
infra/2-nomad-config/traefik.nomad

105 lines
1.8 KiB
HCL

job "traefik" {
group "traefik" {
network {
port "http" {
static = 80
}
port "api" {
static = 8081
}
}
service {
name = "traefik"
tags = [
"traefik.enable=true",
"traefik.http.routers.traefik.rule=Host(`traefik.othrayte.one`)",
"traefik.http.routers.traefik.service=traefik",
"traefik.http.services.traefik.loadbalancer.server.port=8081",
]
check {
name = "alive"
type = "tcp"
port = "http"
interval = "10s"
timeout = "2s"
}
}
task "traefik" {
driver = "docker"
config {
image = "traefik:v3.3"
network_mode = "host"
volumes = [
"local/traefik.yml:/etc/traefik/traefik.yml",
"local/configs/:/etc/traefik/configs/",
]
}
template {
data = <<EOF
entryPoints:
http:
address: ":80"
traefik:
address: ":8081"
api:
dashboard: true
insecure: true
providers:
file:
directory: "/etc/traefik/configs/"
consulCatalog:
prefix: "traefik"
exposedByDefault: false
defaultRule: {{"Host(`{{ .Name }}.othrayte.one`)"}}
endpoint:
address: "127.0.0.1:8500"
scheme: "http"
EOF
destination = "local/traefik.yml"
}
template {
data = <<EOF
http:
routers:
nomadui:
rule: "Host(`nomad.othrayte.one`)"
service: nomadui
consului:
rule: "Host(`consul.othrayte.one`)"
service: consului
services:
nomadui:
loadBalancer:
servers:
- url: "http://127.0.0.1:4646"
consului:
loadBalancer:
servers:
- url: "http://127.0.0.1:8500"
EOF
destination = "local/configs/nomad.yml"
}
resources {
cpu = 100
memory = 128
}
}
}
}