cluster/services/monitoring: grafana: use distributed service
This commit is contained in:
parent
6635ea516d
commit
f423f868c5
1 changed files with 6 additions and 26 deletions
|
@ -82,31 +82,12 @@ in
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
grafana = {
|
grafana = {
|
||||||
enable = false;
|
distributed = {
|
||||||
serviceConfig.EnvironmentFile = config.age.secrets.grafana-secrets.path;
|
enable = true;
|
||||||
};
|
registerService = "grafana";
|
||||||
grafana-ha = let
|
};
|
||||||
base = config.systemd.services.grafana;
|
serviceConfig = {
|
||||||
inherit (config.services) consul;
|
EnvironmentFile = config.age.secrets.grafana-secrets.path;
|
||||||
svc = config.consul.services.grafana;
|
|
||||||
run = pkgs.writeShellScript "grafana-ha-start" ''
|
|
||||||
trap '${svc.commands.deregister}' EXIT
|
|
||||||
${svc.commands.register}
|
|
||||||
${base.serviceConfig.ExecStart}
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
inherit (base) wantedBy;
|
|
||||||
description = "Grafana | High Availability";
|
|
||||||
aliases = [ "grafana.service" ];
|
|
||||||
|
|
||||||
after = base.after ++ [ "consul.service" ];
|
|
||||||
requires = [ "consul.service" ];
|
|
||||||
|
|
||||||
serviceConfig = base.serviceConfig // {
|
|
||||||
ExecStart = "${consul.package}/bin/consul lock --shell=false services/grafana ${run}";
|
|
||||||
ExecStopPost = "${svc.commands.deregister}";
|
|
||||||
# consul uses AF_NETLINK to determine interface addresses, even when just registering a service
|
|
||||||
RestrictAddressFamilies = base.serviceConfig.RestrictAddressFamilies ++ [ "AF_NETLINK" ];
|
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
RestartSec = "10s";
|
RestartSec = "10s";
|
||||||
};
|
};
|
||||||
|
@ -128,7 +109,6 @@ in
|
||||||
|
|
||||||
consul.services.grafana = {
|
consul.services.grafana = {
|
||||||
mode = "manual";
|
mode = "manual";
|
||||||
unit = "grafana-ha";
|
|
||||||
definition = rec {
|
definition = rec {
|
||||||
name = "grafana";
|
name = "grafana";
|
||||||
address = depot.reflection.interfaces.primary.addrPublic;
|
address = depot.reflection.interfaces.primary.addrPublic;
|
||||||
|
|
Loading…
Reference in a new issue