2023-08-31 01:55:45 +03:00
|
|
|
{ config, cluster, depot, ... }:
|
2023-03-05 21:39:15 +02:00
|
|
|
|
|
|
|
let
|
2023-08-31 01:55:45 +03:00
|
|
|
inherit (depot.lib.meta) domain;
|
2023-03-05 21:39:15 +02:00
|
|
|
inherit (config.networking) hostName;
|
|
|
|
inherit (cluster.config) hostLinks;
|
|
|
|
cfg = cluster.config.services.consul;
|
|
|
|
|
|
|
|
hl = hostLinks.${hostName}.consul;
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2024-07-17 03:47:41 +03:00
|
|
|
links.consulAgent.protocol = "http";
|
|
|
|
|
2023-03-05 21:39:15 +02:00
|
|
|
services.consul = {
|
|
|
|
enable = true;
|
|
|
|
webUi = true;
|
2024-06-04 14:55:19 +03:00
|
|
|
package = depot.packages.consul;
|
2023-03-05 21:39:15 +02:00
|
|
|
extraConfig = {
|
2023-03-05 23:00:43 +02:00
|
|
|
datacenter = "eu-central";
|
2023-03-05 23:14:05 +02:00
|
|
|
domain = "sd-magic.${domain}.";
|
2023-03-06 22:52:29 +02:00
|
|
|
recursors = [ "127.0.0.1" cluster.config.links.dnsResolver.ipv4 ];
|
2023-03-05 21:39:15 +02:00
|
|
|
server = true;
|
|
|
|
node_name = config.networking.hostName;
|
|
|
|
bind_addr = hl.ipv4;
|
|
|
|
ports.serf_lan = hl.port;
|
2023-08-31 01:55:45 +03:00
|
|
|
retry_join = map (hostName: hostLinks.${hostName}.consul.tuple) (cfg.otherNodes.agent hostName);
|
2024-07-16 23:56:25 +03:00
|
|
|
bootstrap_expect = builtins.length cfg.nodes.agent;
|
2024-07-17 03:47:41 +03:00
|
|
|
addresses.http = config.links.consulAgent.ipv4;
|
|
|
|
ports.http = config.links.consulAgent.port;
|
2024-08-22 00:28:29 +03:00
|
|
|
acl = {
|
|
|
|
enabled = true;
|
|
|
|
default_policy = "deny";
|
|
|
|
};
|
2023-03-05 21:39:15 +02:00
|
|
|
};
|
|
|
|
};
|
2023-06-01 23:36:57 +03:00
|
|
|
|
|
|
|
services.grafana-agent.settings.integrations.consul_exporter = {
|
|
|
|
enabled = true;
|
|
|
|
instance = hostName;
|
2024-07-17 03:47:41 +03:00
|
|
|
server = config.links.consulAgent.url;
|
2023-06-01 23:36:57 +03:00
|
|
|
};
|
2023-03-05 21:39:15 +02:00
|
|
|
}
|