diff --git a/core/traefik/traefik.nomad b/core/traefik/traefik.nomad index a48f273..32c4ac7 100644 --- a/core/traefik/traefik.nomad +++ b/core/traefik/traefik.nomad @@ -160,6 +160,12 @@ job "traefik" { [providers.consulCatalog.endpoint] address = "http://<< env "CONSUL_HTTP_ADDR" >>" +[providers.nomad] + exposedByDefault = false + defaultRule = "Host(`{{normalize .Name}}.<< keyOrDefault "global/base_hostname" "${var.base_hostname}" >>`)" + [providers.nomad.endpoint] + address = "http://127.0.0.1:4646/" + << if keyExists "traefik/acme/email" ->> [certificatesResolvers.letsEncrypt.acme] email = "<< key "traefik/acme/email" >>" diff --git a/services/whoami.nomad b/services/whoami.nomad index 46268b3..ac5a2a7 100644 --- a/services/whoami.nomad +++ b/services/whoami.nomad @@ -9,6 +9,49 @@ job "whoami" { type = "service" + group "whoami-nomad" { + count = var.count + + network { + mode = "bridge" + port "web" { + host_network = "wesher" + to = 80 + } + } + + service { + name = "whoami-nomad" + provider = "nomad" + port = "web" + + tags = [ + "traefik.enable=true", + "traefik.http.routers.whoami-nomad.entryPoints=websecure", + "traefik.http.routers.whoami-nomad.middlewares=basic-auth@file", + ] + } + + task "whoami" { + driver = "docker" + + meta = { + "diun.enable" = false + } + + config { + image = "containous/whoami:latest" + ports = ["web"] + args = ["--port", "${NOMAD_PORT_web}"] + } + + resources { + cpu = 50 + memory = 20 + } + } + } + group "whoami" { count = var.count