cluster/services/patroni: switch to consul, remove etcd
This commit is contained in:
parent
9a1fa4e418
commit
39134f74c3
3 changed files with 2 additions and 50 deletions
|
@ -1,32 +1,14 @@
|
|||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.services.patroni;
|
||||
|
||||
renameToLink = mode: n: lib.nameValuePair "patroni-etcd-node-${mode}-${n}";
|
||||
|
||||
genLinks = mode: nodes: f: lib.mapAttrs' (renameToLink mode) (lib.genAttrs nodes f);
|
||||
|
||||
getMeshIp = name: config.vars.mesh.${name}.meshIp;
|
||||
|
||||
mkLink = name: {
|
||||
ipv4 = getMeshIp name;
|
||||
protocol = "http";
|
||||
};
|
||||
in
|
||||
{
|
||||
vars.patroni = {
|
||||
etcdNodes = lib.genAttrs cfg.nodes.etcd (name: config.links."patroni-etcd-node-peer-${name}");
|
||||
etcdNodesClient = lib.genAttrs cfg.nodes.etcd (name: config.links."patroni-etcd-node-client-${name}");
|
||||
passwords = {
|
||||
PATRONI_REPLICATION_PASSWORD = ./passwords/replication.age;
|
||||
PATRONI_SUPERUSER_PASSWORD = ./passwords/superuser.age;
|
||||
PATRONI_REWIND_PASSWORD = ./passwords/rewind.age;
|
||||
};
|
||||
};
|
||||
links = genLinks "client" cfg.nodes.etcd mkLink
|
||||
// genLinks "peer" cfg.nodes.etcd mkLink
|
||||
// {
|
||||
links = {
|
||||
patroni-pg-internal.ipv4 = "0.0.0.0";
|
||||
patroni-api.ipv4 = "0.0.0.0";
|
||||
patroni-pg-access.ipv4 = "127.0.0.1";
|
||||
|
@ -34,12 +16,10 @@ in
|
|||
services.patroni = {
|
||||
nodes = {
|
||||
worker = [ "VEGAS" "prophet" ];
|
||||
etcd = [ "checkmate" "VEGAS" "prophet" ];
|
||||
haproxy = [ "VEGAS" "prophet" ];
|
||||
};
|
||||
nixos = {
|
||||
worker = ./worker.nix;
|
||||
etcd = ./etcd.nix;
|
||||
haproxy = ./haproxy.nix;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
{ cluster, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (cluster.config) vars;
|
||||
|
||||
getEtcdUrl = name: vars.patroni.etcdNodes.${name}.url;
|
||||
|
||||
mkMember = n: "${n}=${getEtcdUrl n}";
|
||||
in
|
||||
|
||||
{
|
||||
services.etcd = {
|
||||
enable = true;
|
||||
dataDir = "/srv/storage/private/etcd";
|
||||
initialCluster = map mkMember cluster.config.services.patroni.nodes.etcd;
|
||||
listenPeerUrls = lib.singleton vars.patroni.etcdNodes.${vars.hostName}.url;
|
||||
listenClientUrls = lib.singleton vars.patroni.etcdNodesClient.${vars.hostName}.url;
|
||||
};
|
||||
systemd.services.etcd = {
|
||||
# run on any architecture
|
||||
environment.ETCD_UNSUPPORTED_ARCH = pkgs.go.GOARCH;
|
||||
serviceConfig = {
|
||||
TimeoutStartSec = "900s";
|
||||
RestartSec = "5s";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
}
|
|
@ -40,7 +40,7 @@ in
|
|||
raft = false;
|
||||
softwareWatchdog = true;
|
||||
settings = {
|
||||
etcd3.hosts = map (x: x.tuple) (lib.attrValues vars.patroni.etcdNodesClient);
|
||||
consul.host = "127.0.0.1:8500";
|
||||
bootstrap.dcs = {
|
||||
ttl = 30;
|
||||
loop_wait = 10;
|
||||
|
|
Loading…
Reference in a new issue