Added D53 and Diplonat

This commit is contained in:
Zuma 2026-01-09 16:45:28 +01:00
parent b99659f23e
commit 9ad682ae87
6 changed files with 119 additions and 2 deletions

45
apps/core/d53.hcl Normal file
View file

@ -0,0 +1,45 @@
job "d53" {
datacenters = ["mayel-house", "gribse-house", "zuma-house"]
type = "service"
priority = 90
group "D53" {
count = 1
task "d53" {
driver = "docker"
config {
image = "git.shenanigans.cc/zuma/d53:41e79af-dirty"
network_mode = "host"
readonly_rootfs = true
}
resources {
cpu = 100
memory = 100
}
restart {
interval = "3m"
attempts = 10
delay = "15s"
mode = "delay"
}
template {
data = <<EOH
D53_CONSUL_HOST=http://localhost:8500
D53_PROVIDERS=chokbar.bzh:porkbun
D53_PORKBUN_API_KEY={{ key "secrets/d53/porkbun_api_key" }}
D53_PORKBUN_SECRET_API_KEY={{ key "secrets/d53/porkbun_secret_api_key" }}
D53_ALLOWED_DOMAINS=chokbar.bzh
RUST_LOG=d53=debug
EOH
destination = "secrets/env"
env = true
}
}
}
}

52
apps/core/diplonat.hcl Normal file
View file

@ -0,0 +1,52 @@
job "diplonat" {
datacenters = ["zuma-house", "mayel-house", "gribse-house"]
type = "system"
priority = 90
update {
max_parallel = 2
stagger = "1m"
}
group "diplonat" {
task "diplonat" {
driver = "docker"
config {
image = "git.shenanigans.cc/zuma/diplonat:filouterie"
network_mode = "host"
readonly_rootfs = true
privileged = true
}
restart {
interval = "5m"
attempts = 10
delay = "15s"
mode = "delay"
}
template {
data = <<EOH
DIPLONAT_REFRESH_TIME=60
DIPLONAT_EXPIRATION_TIME=300
DIPLONAT_DISABLE_IGD=true
DIPLONAT_STUN_SERVER=stun.l.google.com:19302
DIPLONAT_CONSUL_NODE_NAME={{ env "attr.unique.hostname" }}
DIPLONAT_CONSUL_URL=http://consul.service.filouterie.consul:8500
DIPLONAT_CONSUL_TLS_SKIP_VERIFY=true
RUST_LOG=debug
RUST_BACKTRACE=1
EOH
destination = "secrets/env"
env = true
}
resources {
memory = 100
memory_max = 200
}
}
}
}

View file

@ -71,7 +71,9 @@ EOH
name = "tricot-http" name = "tricot-http"
port = "http_port" port = "http_port"
tags = [ tags = [
"${meta.site}" "${meta.site}",
"d53-a global.site.chokbar.bzh",
"d53-a ${meta.site}.site.chokbar.bzh",
] ]
address_mode = "host" address_mode = "host"
} }

View file

@ -24,7 +24,8 @@ job "searxng" {
service { service {
tags = [ tags = [
"tricot search.chokbar.bzh" "tricot search.chokbar.bzh",
"d53-cname search.chokbar.bzh"
] ]
name = "searxng" name = "searxng"
port = "http_port" port = "http_port"

View file

@ -46,6 +46,11 @@ with lib;
type = str; type = str;
description = "Wireguard endpoint on the public internet"; description = "Wireguard endpoint on the public internet";
}; };
cnameTarget = mkOption {
type = str;
description = "CNAME target for DNS updater to forward service to right site";
};
}; };
}); });
}; };
@ -60,18 +65,21 @@ with lib;
pubkey = "/TJVF6aLEvqngjd8Gq3QkH5esEQSIL+ryz/uKdJaZEQ="; pubkey = "/TJVF6aLEvqngjd8Gq3QkH5esEQSIL+ryz/uKdJaZEQ=";
address = "10.0.1.1"; address = "10.0.1.1";
endpoint = "92.179.73.254:19720"; endpoint = "92.179.73.254:19720";
cnameTarget = "mayel-house.site.chokbar.bzh";
}; };
"riri" = { "riri" = {
siteName = "gribse-house"; siteName = "gribse-house";
pubkey = "lUUTv85m7vtIKY7+s//AWL5r/epjXSBZNJCrgjRfQj0="; pubkey = "lUUTv85m7vtIKY7+s//AWL5r/epjXSBZNJCrgjRfQj0=";
address = "10.0.2.1"; address = "10.0.2.1";
endpoint = "176.159.248.209:19720"; endpoint = "176.159.248.209:19720";
cnameTarget = "gribse-house.site.chokbar.bzh";
}; };
"loulou" = { "loulou" = {
siteName = "zuma-house"; siteName = "zuma-house";
pubkey = "J/liQaChv4ZBjwlLmobM0NA/Wwgl8nDcQEcGdsC5Exc="; pubkey = "J/liQaChv4ZBjwlLmobM0NA/Wwgl8nDcQEcGdsC5Exc=";
address = "10.0.3.1"; address = "10.0.3.1";
endpoint = "82.67.117.71:19720"; endpoint = "82.67.117.71:19720";
cnameTarget = "zuma-house.site.chokbar.bzh";
}; };
}; };
} }

View file

@ -194,6 +194,7 @@ with pkgs.lib;
extraConfig = { extraConfig = {
node_meta = { node_meta = {
site = clusterNodeCfg.siteName; site = clusterNodeCfg.siteName;
cname_target = clusterNodeCfg.cnameTarget;
}; };
server = true; server = true;
bootstrap = false; bootstrap = false;
@ -295,11 +296,19 @@ with pkgs.lib;
]; ];
extraCommands = '' extraCommands = ''
# Allow UDP packets comming from port 1900 from a local address,
# these are necessary for UPnP/IGD
iptables -A INPUT -s 192.168.0.0/16 -p udp --sport 1900 -j ACCEPT
# Allow docker containers to access all ports
iptables -A INPUT -s 172.17.0.0/16 -j ACCEPT
# Allow other nodes on VPN to access all ports # Allow other nodes on VPN to access all ports
iptables -A INPUT -s ${cfg.clusterPrefix} -j ACCEPT iptables -A INPUT -s ${cfg.clusterPrefix} -j ACCEPT
''; '';
extraStopCommands = '' extraStopCommands = ''
iptables -D INPUT -s 192.168.0.0/16 -p udp --sport 1900 -j ACCEPT
iptables -D INPUT -s 172.17.0.0/16 -j ACCEPT
iptables -D INPUT -s ${cfg.clusterPrefix} -j ACCEPT iptables -D INPUT -s ${cfg.clusterPrefix} -j ACCEPT
''; '';
}; };