etcd: deploy etcd cluster on zookeeper hosts via locations.nix #1021
No files matched your search
@@ -30,6 +30,11 @@ in
|
|||||||
blackmagic-cam-importer = "phoenix.st.${config.ogygia.domain}";
|
blackmagic-cam-importer = "phoenix.st.${config.ogygia.domain}";
|
||||||
couchdb = "warlock.cx.${config.ogygia.domain}";
|
couchdb = "warlock.cx.${config.ogygia.domain}";
|
||||||
downloads = "phoenix.st.${config.ogygia.domain}";
|
downloads = "phoenix.st.${config.ogygia.domain}";
|
||||||
|
etcd = [
|
||||||
|
"boron.cx.${config.ogygia.domain}"
|
||||||
|
"li.pop.${config.ogygia.domain}"
|
||||||
|
"warlock.cx.${config.ogygia.domain}"
|
||||||
|
];
|
||||||
firefly-iii = "warlock.cx.${config.ogygia.domain}";
|
firefly-iii = "warlock.cx.${config.ogygia.domain}";
|
||||||
firefly-iii-data-importer = "warlock.cx.${config.ogygia.domain}";
|
firefly-iii-data-importer = "warlock.cx.${config.ogygia.domain}";
|
||||||
frigate = "phoenix.st.${config.ogygia.domain}";
|
frigate = "phoenix.st.${config.ogygia.domain}";
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
./blackmagic-cam-importer
|
./blackmagic-cam-importer
|
||||||
./couchdb
|
./couchdb
|
||||||
./downloads
|
./downloads
|
||||||
|
./etcd.nix
|
||||||
./firefly-iii
|
./firefly-iii
|
||||||
./frigate.nix
|
./frigate.nix
|
||||||
./git.nix
|
./git.nix
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
{ config, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.custom.services.etcd;
|
||||||
|
locations = config.custom.locations.locations;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.custom.services.etcd = {
|
||||||
|
enable = lib.mkEnableOption "etcd";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable (
|
||||||
|
let
|
||||||
|
# Get the list of etcd hosts from locations.nix
|
||||||
|
etcdHosts = locations.services.etcd;
|
||||||
|
|
||||||
|
# Function to lookup FQDN in DNS config (same pattern as zookeeper.nix)
|
||||||
|
lookupFqdn = fqdn:
|
||||||
|
lib.attrsets.attrByPath
|
||||||
|
(lib.reverseList (lib.splitString "." fqdn))
|
||||||
|
null
|
||||||
|
config.custom.dns.authoritative.ipv4;
|
||||||
|
|
||||||
|
# Get this host's nebula IP
|
||||||
|
thisNebulaIp = config.custom.dns.nebula.ipv4;
|
||||||
|
|
||||||
|
# Generate initial cluster list
|
||||||
|
initialCluster = map
|
||||||
|
(hostname:
|
||||||
|
let nebulaIp = lookupFqdn hostname;
|
||||||
|
in "${hostname}=http://${nebulaIp}:2380")
|
||||||
|
etcdHosts;
|
||||||
|
|
||||||
|
# Check if this host is in the cluster
|
||||||
|
isClusterMember = builtins.elem config.networking.fqdn etcdHosts;
|
||||||
|
in
|
||||||
|
lib.mkIf isClusterMember {
|
||||||
|
services.etcd = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
name = config.networking.fqdn;
|
||||||
|
listenClientUrls = [ "http://${thisNebulaIp}:2379" ];
|
||||||
|
listenPeerUrls = [ "http://${thisNebulaIp}:2380" ];
|
||||||
|
initialCluster = initialCluster;
|
||||||
|
initialAdvertisePeerUrls = [ "http://${thisNebulaIp}:2380" ];
|
||||||
|
|
||||||
|
dataDir = lib.mkIf config.custom.impermanence.enable
|
||||||
|
"${config.custom.impermanence.base}/system/var/lib/etcd";
|
||||||
|
};
|
||||||
|
|
||||||
|
# Add data directory to impermanence if not using the services.etcd.dataDir override
|
||||||
|
custom.impermanence.extraDirs = lib.mkIf (!config.custom.impermanence.enable) [ ];
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user