2022-02-16 17:56:18 +00:00
|
|
|
variable "base_hostname" {
|
|
|
|
type = string
|
|
|
|
description = "Base hostname to serve content from"
|
|
|
|
default = "dev.homelab"
|
|
|
|
}
|
|
|
|
|
2022-02-27 22:49:00 +00:00
|
|
|
variable "count" {
|
|
|
|
type = number
|
|
|
|
default = 2
|
|
|
|
}
|
|
|
|
|
2022-02-16 17:56:18 +00:00
|
|
|
job "whoami" {
|
|
|
|
region = "global"
|
|
|
|
datacenters = ["dc1"]
|
|
|
|
|
|
|
|
type = "service"
|
|
|
|
|
|
|
|
group "whoami" {
|
2022-02-27 22:49:00 +00:00
|
|
|
count = var.count
|
|
|
|
|
2022-02-16 17:56:18 +00:00
|
|
|
network {
|
|
|
|
mode = "bridge"
|
|
|
|
port "web" {
|
2022-02-17 22:03:42 +00:00
|
|
|
host_network = "loopback"
|
|
|
|
to = 80
|
2022-02-16 17:56:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
service {
|
|
|
|
port = "web"
|
|
|
|
|
|
|
|
connect {
|
2022-02-17 22:03:42 +00:00
|
|
|
sidecar_service {
|
|
|
|
proxy {
|
|
|
|
local_service_port = 80
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sidecar_task {
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 50
|
|
|
|
}
|
|
|
|
}
|
2022-02-16 17:56:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check {
|
|
|
|
type = "http"
|
|
|
|
path = "/health"
|
|
|
|
port = "web"
|
|
|
|
interval = "10s"
|
|
|
|
timeout = "10s"
|
|
|
|
}
|
|
|
|
|
|
|
|
tags = [
|
|
|
|
"traefik.enable=true",
|
|
|
|
"traefik.http.routers.whoami.entrypoints=web,websecure",
|
|
|
|
"traefik.http.routers.whoami.rule=Host(`whoami.${var.base_hostname}`)",
|
|
|
|
"traefik.http.routers.whoami.tls=true",
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
task "whoami" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
config {
|
|
|
|
image = "containous/whoami:latest"
|
|
|
|
ports = ["web"]
|
|
|
|
args = ["--port", "${NOMAD_PORT_web}"]
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
|
|
|
memory = 50
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|