homelab/nomad-job/platform/grafana.nomad

84 lines
2.2 KiB
Plaintext
Raw Permalink Normal View History

2022-05-10 17:41:18 +00:00
job "grafana" {
datacenters = ["homelab"]
2022-12-10 16:10:32 +00:00
priority = 50
2022-05-10 17:41:18 +00:00
type = "service"
2024-02-21 18:03:31 +00:00
constraint {
attribute = "${node.class}"
operator = "set_contains"
value = "cluster"
}
2022-05-10 17:41:18 +00:00
meta {
2024-01-13 17:35:18 +00:00
forcedeploiement = 2
2022-05-10 17:41:18 +00:00
}
2024-05-10 13:50:45 +00:00
vault {
policies = ["grafana"]
}
2022-05-10 17:41:18 +00:00
group "grafana" {
network {
port "http" {
2022-10-29 08:40:01 +00:00
to = 3000
2022-05-10 17:41:18 +00:00
}
}
service {
name = "grafana"
port = "http"
2022-10-29 08:40:01 +00:00
tags = [
2022-05-23 19:44:34 +00:00
"homer.enable=true",
"homer.name=Grafana",
"homer.service=Monitoring",
2023-11-05 18:08:17 +00:00
"homer.logo=https://grafana.ducamps.eu/public/img/grafana_icon.svg",
2022-05-23 19:44:34 +00:00
"homer.target=_blank",
2023-11-05 18:08:17 +00:00
"homer.url=https://${NOMAD_JOB_NAME}.ducamps.eu",
2022-05-23 19:44:34 +00:00
2022-05-10 17:41:18 +00:00
"traefik.enable=true",
"traefik.http.routers.grafana.entryPoints=websecure",
2023-11-05 18:08:17 +00:00
"traefik.http.routers.grafana.rule=Host(`grafana.ducamps.eu`)",
"traefik.http.routers.grafana.tls.domains[0].sans=grafana.ducamps.eu",
2022-05-10 17:41:18 +00:00
"traefik.http.routers.grafana.tls.certresolver=myresolver",
2023-10-07 16:40:40 +00:00
"traefik.http.routers.grafana.entrypoints=web,websecure",
2022-05-10 17:41:18 +00:00
]
}
task "dashboard" {
2022-05-12 09:37:38 +00:00
driver = "docker"
config {
2024-03-17 17:58:24 +00:00
image = "docker.service.consul:5000/grafana/grafana"
2022-05-12 09:37:38 +00:00
ports = ["http"]
volumes = [
2024-05-10 13:50:45 +00:00
"local/grafana.ini:/etc/grafana/grafana.ini",
2024-03-17 17:58:24 +00:00
"/mnt/diskstation/nomad/grafana/lib:/var/lib/grafana"
2022-05-12 09:37:38 +00:00
]
}
2024-05-10 13:50:45 +00:00
template {
data = <<EOH
force_migration=true
[server]
root_url = https://grafana.ducamps.eu
[auth.generic_oauth]
enabled = true
name = Authelia
icon = signin
client_id = grafana
client_secret = {{ with secret "secrets/data/authelia/grafana"}} {{ .Data.data.password }} {{end}}
scopes = openid profile email groups
empty_scopes = false
auth_url = https://auth.ducamps.eu/api/oidc/authorization
token_url = https://auth.ducamps.eu/api/oidc/token
api_url = https://auth.ducamps.eu/api/oidc/userinfo
login_attribute_path = preferred_username
groups_attribute_path = groups
name_attribute_path = name
use_pkce = true
role_attribute_path=contains(groups[*], 'GrafanaAdmins') && 'Admin' || contains(groups[*], 'GrafanaUsers') && 'Viewer'
EOH
destination = "local/grafana.ini"
}
2022-05-12 09:37:38 +00:00
resources {
2023-11-14 16:45:52 +00:00
memory = 250
2022-05-12 09:37:38 +00:00
}
2022-05-10 17:41:18 +00:00
}
}
}