diff options
author | Alex Auvolat <alex@adnab.me> | 2022-02-26 21:31:58 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-02-26 21:31:58 +0100 |
commit | 41a65b803217d7a3ebdaa5029d58a5cac4ce63da (patch) | |
tree | 3853243fc3b3eb4999479ae5fb5d116f047b49d1 /app/telemetry/deploy/telemetry.hcl | |
parent | 7dcb4072dcced7a4d92ae2c356722ccb6bfd5e2b (diff) | |
download | nixcfg-41a65b803217d7a3ebdaa5029d58a5cac4ce63da.tar.gz nixcfg-41a65b803217d7a3ebdaa5029d58a5cac4ce63da.zip |
Allow grafana to move between nodes
Diffstat (limited to 'app/telemetry/deploy/telemetry.hcl')
-rw-r--r-- | app/telemetry/deploy/telemetry.hcl | 86 |
1 files changed, 78 insertions, 8 deletions
diff --git a/app/telemetry/deploy/telemetry.hcl b/app/telemetry/deploy/telemetry.hcl index c3edd4c..b394699 100644 --- a/app/telemetry/deploy/telemetry.hcl +++ b/app/telemetry/deploy/telemetry.hcl @@ -31,7 +31,7 @@ EOH } resources { - memory = 1500 + memory = 1000 cpu = 500 } @@ -62,18 +62,42 @@ EOH group "grafana" { count = 1 - constraint { - attribute = "${attr.unique.hostname}" - operator = "=" - value = "carcajou" - } - network { port "grafana" { static = 3333 } } + task "restore-db" { + lifecycle { + hook = "prestart" + sidecar = false + } + + driver = "docker" + config { + image = "litestream/litestream:0.3.7" + args = [ + "restore", "-config", "/etc/litestream.yml", "/ephemeral/grafana.db" + ] + volumes = [ + "../alloc/data:/ephemeral", + "secrets/litestream.yml:/etc/litestream.yml" + ] + } + user = "472" + + template { + data = file("../config/grafana-litestream.yml") + destination = "secrets/litestream.yml" + } + + resources { + memory = 200 + cpu = 1000 + } + } + task "grafana" { driver = "docker" config { @@ -81,7 +105,7 @@ EOH network_mode = "host" ports = [ "grafana" ] volumes = [ - "/mnt/ssd/telemetry/grafana:/var/lib/grafana", + "../alloc/data:/var/lib/grafana", "secrets/elastic.yaml:/etc/grafana/provisioning/datasources/elastic.yaml" ] } @@ -104,7 +128,53 @@ EOH memory = 500 cpu = 100 } + + service { + tags = [ + "grafana", + "tricot grafana.home.adnab.me", + ] + port = 3333 + address_mode = "driver" + name = "grafana" + check { + type = "tcp" + port = 3333 + address_mode = "driver" + interval = "60s" + timeout = "5s" + check_restart { + limit = 3 + grace = "90s" + ignore_warnings = false + } + } + } } + task "replicate-db" { + driver = "docker" + config { + image = "litestream/litestream:0.3.7" + args = [ + "replicate", "-config", "/etc/litestream.yml" + ] + volumes = [ + "../alloc/data:/ephemeral", + "secrets/litestream.yml:/etc/litestream.yml" + ] + } + user = "472" + + template { + data = file("../config/grafana-litestream.yml") + destination = "secrets/litestream.yml" + } + + resources { + memory = 200 + cpu = 100 + } + } } } |