dns games for buzz

This commit is contained in:
ari committed 2026-09-21 16:19:43 -04:00
1 parent dd6d071c34
commit 8ef626a16b
4 files changed
+174 -12

No files matched your search

+5 -3
View File
@@ -14,8 +14,10 @@ hosts/
├── fwbook/ # fwbook-specific shell scripts
│ ├── functions.sh # ZSH functions sourced at shell startup
│ └── functions.nu # NuShell helpers (k8s namespace/secret listing, secret decoding)
└── fw1/
└── gs.sh # gamescope/Steam launch wrapper (VRR, HDR, mangoapp overlay)
├── fw1/
│ └── gs.sh # gamescope/Steam launch wrapper (VRR, HDR, mangoapp overlay)
└── hl-minipc1/
└── buzz-manage.sh # Buzz stack management CLI (wired as `buzz-manage`)
```
## Managed Hosts
@@ -27,7 +29,7 @@ hosts/
| `hl-fws1.nix` | hl-fws1 | Framework 11th Intel — K3s server node |
| `hl-bigbox1.nix` | hl-bigbox1 | AI/compute server (NVIDIA + AMD) |
| `hl-bigbox2.nix` | hl-bigbox2 | NFS storage server |
| `hl-minipc1.nix` | hl-minipc1 | Core infra: Gitea, nix-serve, registry, Buzz (podman) |
| `hl-minipc1.nix` | hl-minipc1 | Core infra: Gitea, nix-serve, registry, Buzz (docker, `buzz-manage` CLI) |
| `hl-minipc2.nix` | hl-minipc2 | Container/media server |
| `hl-minipc3.nix` | hl-minipc3 | K3s worker node |
| `hl-pi1.nix` | hl-pi1 | Raspberry Pi CM4 (aarch64) — headless server, SSH only. Also buildable as a bootable SD image via the `hl-pi1-sd-image` nixosConfiguration (`skyg build-pi-sd-image`) |
+29 -9
View File
@@ -1,4 +1,4 @@
{ config, ... }:
{ config, pkgs, ... }:
let
ports = {
nixServe = 5000;
@@ -35,9 +35,8 @@ let
buzz = {
domain = "buzz.app.internal";
port = 3000;
# Caddy's macvlan IP — buzz.app.internal resolves here; the relay is internal-only.
ip = "10.0.101.3";
# Caddy TLS terminator — buzz.app.internal points here (443/80).
caddyIp = "10.0.101.5";
bucket = "buzz-media";
images = {
relay = "ghcr.io/block/buzz:main";
@@ -59,6 +58,13 @@ let
device = ":/mnt/SmallG/buzz/${subpath}";
};
};
# Buzz management CLI — upstream deploy/compose/run.sh ported to this
# deployment; the logic lives in scripts/hl-minipc1/buzz-manage.sh.
buzz-manage = pkgs.writeShellScriptBin "buzz-manage" ''
export BUZZ_ENV_FILE="${config.age.secrets.buzz-env.path}"
export BUZZ_COMPOSE_BIN="${pkgs.docker-compose}/bin/docker-compose"
${builtins.readFile ./scripts/hl-minipc1/buzz-manage.sh}
'';
in
{
skyg.user.enable = true;
@@ -286,10 +292,7 @@ in
minio.condition = "service_healthy";
minio-init.condition = "service_completed_successfully";
};
networks = {
internal = { };
lan = { ipv4_address = buzz.ip; };
};
networks = [ "internal" ];
environmentFiles = [ config.age.secrets.buzz-env.path ];
environment = {
BUZZ_BIND_ADDR = "0.0.0.0:${toString buzz.port}";
@@ -323,12 +326,14 @@ in
# TLS terminator — owns buzz.app.internal (443/80), proxies to the relay
# over the internal network. Cert minted by `skyg ca issue` (lab CA).
# Also proxies plain :3000 (Hermes guest can't trust the CA yet), :8080
# health and :9102 metrics so everything stays on 10.0.101.3.
caddy = {
image = buzz.images.caddy;
extraConfig.depends_on.relay.condition = "service_healthy";
networks = {
internal = { };
lan = { ipv4_address = buzz.caddyIp; };
lan = { ipv4_address = buzz.ip; };
};
dns.names = [ buzz.domain ];
files."/etc/caddy/Caddyfile" = ''
@@ -337,9 +342,21 @@ in
encode zstd gzip
reverse_proxy relay:${toString buzz.port}
}
:${toString buzz.port} {
reverse_proxy relay:${toString buzz.port}
}
:8080 {
reverse_proxy relay:8080
}
:9102 {
reverse_proxy relay:9102
}
'';
volumes = [
"${../../configs/pki/buzz.app.internal.crt}:/etc/caddy/tls/cert.pem:ro"
"${../configs/pki/buzz.app.internal.crt}:/etc/caddy/tls/cert.pem:ro"
"${config.age.secrets.buzz-tls-key.path}:/etc/caddy/tls/key.pem:ro"
];
};
@@ -428,6 +445,9 @@ in
};
};
# Buzz management CLI.
environment.systemPackages = [ buzz-manage ];
# Certbot TLS service
skyg.server.dns.certbot = {
enable = false;
+140
View File
@@ -0,0 +1,140 @@
#!/usr/bin/env bash
# Buzz stack management — mirrors upstream block/buzz deploy/compose/run.sh,
# adapted to the container-services deployment: systemd unit instead of raw
# compose up/down, staged compose.yml, agenix env instead of a local .env.
#
# Expects these to be exported by the Nix wrapper before this file's content runs:
# BUZZ_ENV_FILE - agenix path of the buzz env file
# BUZZ_COMPOSE_BIN - store path of docker-compose
set -euo pipefail
# Fallbacks so the file also runs directly from the repo for debugging.
BUZZ_ENV_FILE="${BUZZ_ENV_FILE:-/run/agenix/buzz-env}"
BUZZ_COMPOSE_BIN="${BUZZ_COMPOSE_BIN:-docker-compose}"
STATE_DIR="/var/lib/container-services/buzz"
COMPOSE_FILE="$STATE_DIR/compose.yml"
UNIT="container-services-buzz.service"
UPDATE_UNIT="container-services-buzz-update.service"
compose() {
if [ ! -f "$COMPOSE_FILE" ]; then
echo "$COMPOSE_FILE is not staged yet; run 'buzz-manage start' once" >&2
exit 1
fi
"$BUZZ_COMPOSE_BIN" -p buzz -f "$COMPOSE_FILE" "$@"
}
require_env() {
if [ ! -f "$BUZZ_ENV_FILE" ]; then
cat >&2 <<MSG
Missing buzz env file: $BUZZ_ENV_FILE
It is decrypted by agenix at boot; check agenix.service if it is absent.
MSG
exit 1
fi
if grep -Eq '^[[:space:]]*[A-Za-z_][A-Za-z0-9_]*=.*CHANGE_ME' "$BUZZ_ENV_FILE"; then
cat >&2 <<'MSG'
buzz-env still contains CHANGE_ME placeholders.
Generate stable secrets first; these values must not rotate on restart.
MSG
exit 1
fi
}
backup_hint() {
cat <<'MSG'
Back up these before upgrades and on a regular schedule:
- secrets/buzz-env.age (relay private key, DB/Redis/S3 secrets, HMAC secret)
- secrets/buzz-tls-key.age and configs/pki/buzz.app.internal.crt (lab CA TLS)
- Postgres data on tnas1:/mnt/SmallG/buzz/postgres (prefer pg_dump or a quiesced snapshot)
- MinIO/S3 data on tnas1:/mnt/SmallG/buzz/s3 (bucket: buzz-media)
- git objects on tnas1:/mnt/SmallG/buzz/git (BUZZ_GIT_REPO_PATH=/data/git)
- Redis data on tnas1:/mnt/SmallG/buzz/redis
Keep Postgres + object/git state snapshots from the same maintenance window.
MSG
}
case "${1:-help}" in
start|up)
require_env
systemctl start "$UNIT"
;;
stop|down)
systemctl stop "$UNIT"
;;
restart)
require_env
compose up -d --wait --force-recreate relay
;;
pull)
require_env
compose pull
;;
upgrade)
require_env
# Same pull + recreate path the auto-update timer uses.
systemctl start "$UPDATE_UNIT"
echo "pull output: journalctl -u $UPDATE_UNIT"
backup_hint
;;
logs)
shift || true
compose logs -f "${@:-relay}"
;;
status|ps)
systemctl --no-pager status "$UNIT" || true
compose ps
;;
config)
require_env
compose config
;;
backup-hint)
backup_hint
;;
add-member)
compose exec relay /usr/local/bin/buzz-admin add-member --pubkey "${2:?Usage: buzz-manage add-member <npub-or-hex> [--role member|admin]}" "${@:3}"
;;
remove-member)
compose exec relay /usr/local/bin/buzz-admin remove-member --pubkey "${2:?Usage: buzz-manage remove-member <npub-or-hex> [--role member|admin]}" "${@:3}"
;;
list-members)
compose exec relay /usr/local/bin/buzz-admin list-members
;;
help|-h|--help)
cat <<'MSG'
Usage: buzz-manage <command>
Commands:
start Start the stack (container-services-buzz.service)
stop Stop containers without deleting volumes
restart Recreate the relay after env/image changes
pull Pull configured images
upgrade Pull and restart via the update unit, then print backup reminders
logs [svc] Follow logs (default: relay)
status Show systemd unit and compose service status
config Render merged compose config
backup-hint Print the production backup checklist
add-member <npub-or-hex> [--role member|admin]
Add a relay member (default role: member)
remove-member <npub-or-hex> [--role member|admin]
Remove a relay member
list-members List all relay members
Note: when adding multiple members in a loop, add `sleep 1` between
invocations to avoid same-second timestamp collisions in the kind:13534
roster event. Do not use parallel adds (e.g. xargs -P).
Run as root (or via sudo): the env file and docker socket are root-only.
MSG
;;
*)
echo "Unknown command: $1" >&2
echo "Run 'buzz-manage help'" >&2
exit 1
;;
esac
Binary file not shown.