Use Nomad task socket from Traefik
This commit is contained in:
parent
634d63c26c
commit
85c626c96f
@ -114,6 +114,14 @@ job "traefik" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
env = {
|
||||||
|
TRAEFIK_PROVIDERS_NOMAD_ENDPOINT_TOKEN = "${NOMAD_TOKEN}"
|
||||||
|
}
|
||||||
|
|
||||||
|
identity {
|
||||||
|
env = true
|
||||||
|
}
|
||||||
|
|
||||||
template {
|
template {
|
||||||
# Avoid conflict with TOML lists [[ ]] and Go templates {{ }}
|
# Avoid conflict with TOML lists [[ ]] and Go templates {{ }}
|
||||||
left_delimiter = "<<"
|
left_delimiter = "<<"
|
||||||
@ -166,7 +174,7 @@ job "traefik" {
|
|||||||
exposedByDefault = false
|
exposedByDefault = false
|
||||||
defaultRule = "Host(`{{normalize .Name}}.<< with nomadVar "nomad/jobs" >><< .base_hostname >><< end >>`)"
|
defaultRule = "Host(`{{normalize .Name}}.<< with nomadVar "nomad/jobs" >><< .base_hostname >><< end >>`)"
|
||||||
[providers.nomad.endpoint]
|
[providers.nomad.endpoint]
|
||||||
address = "http://127.0.0.1:4646"
|
address = "unix:///secrets/api.sock"
|
||||||
EOH
|
EOH
|
||||||
destination = "${NOMAD_TASK_DIR}/config/traefik.toml"
|
destination = "${NOMAD_TASK_DIR}/config/traefik.toml"
|
||||||
}
|
}
|
||||||
|
@ -21,3 +21,16 @@ EOH
|
|||||||
job_id = resource.nomad_job.traefik.id
|
job_id = resource.nomad_job.traefik.id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "nomad_acl_policy" "traefik_query_jobs" {
|
||||||
|
name = "traefik-query-jobs"
|
||||||
|
description = "Allow traefik to query jobs"
|
||||||
|
rules_hcl = <<EOH
|
||||||
|
namespace "default" {
|
||||||
|
capabilities = ["list-jobs", "read-job"]
|
||||||
|
}
|
||||||
|
EOH
|
||||||
|
job_acl {
|
||||||
|
job_id = resource.nomad_job.traefik.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user