Docker¶
Some services run outside Kubernetes, as Docker Compose stacks on the TrueNAS host. Some must keep working when the cluster is down or being rebuilt (the registry mirror, S3 for database recovery, PXE boot). Others are simply NAS-local (BGP, hardware exporters).
How stacks are deployed¶
doco-cd runs on the NAS as the
00-doco-cd stack and is configured by
docker/nas/.doco-cd.yaml:
- deploys on every push to
mainthrough a GitHub webhook (see Webhook), and pollsbykaj/home-opsmainevery hour as a fallback - auto-discovers stacks one directory deep under
docker/nas/ - deletes stacks whose directory disappears
- resolves
op://secrets from 1Password and passes them to compose as${VAR}(see Secrets)
Each stack is docker/nas/NN-<app>/docker-compose.yaml. The NN- prefix only
sets the order.
Don't rename stack directories
doco-cd names each compose project after its directory, overriding any
top-level name:. Renaming or renumbering a stack directory makes it
delete the old stack and create a new one. Named volumes are prefixed
with the project name (02-traefik_data) unless they set an explicit
name:, so the new project gets new volume objects. For anonymous and
Docker-managed named volumes that means starting empty. Bind-backed
volumes (driver_opts with o: bind) point at the same host path, so
their data survives. Keep directory names stable.
To redeploy without a push, for example after a failed deploy:
The recipe calls POST /v1/api/poll/run on https://doco-cd.bykaj.app
(doco-cd behind Traefik) with the API key from 1Password (op://Homelab/doco-cd/API_SECRET). doco-cd reads its
keys from the api_keys file in its config directory (API_KEYS_FILE), where this key has the write role: enough to
trigger polls and read runs, not to delete projects. It waits for the run
and fails if the run doesn't succeed. Only changed stacks are redeployed.
doco-cd deploys its own stack like any other (see 00-doco-cd),
so a merged change to its compose file, including a Renovate image bump,
updates doco-cd itself. just docker restart-doco-cd restarts the running
container (via Ansible) without applying anything. Changes to
docker/nas/.doco-cd.yaml take effect on the next run: doco-cd reads it from
the repo every time.
Webhook¶
GitHub sends push events for bykaj/home-ops to
https://doco-cd-webhook.bykaj.io/v1/webhook. The NAS is LAN-only, so the
request goes through the cluster: Cloudflare Tunnel → envoy-external → an
Envoy Gateway Backend in the network namespace that points at doco-cd
behind Traefik on the NAS (https://doco-cd.bykaj.app, verified against the
system CAs). The HTTPRoute rewrites the Host header to doco-cd.bykaj.app,
because Traefik routes on it, and only matches /v1/webhook and /v1/health
(exact paths), so doco-cd's REST API stays off the internet. See
kubernetes/apps/network/doco-cd-webhook/.
doco-cd checks each request's HMAC-SHA256 signature against
WEBHOOK_SECRET_FILE (~/.config/doco-cd/webhook_secret on the NAS). The
GitHub webhook must use the same secret, with content type
application/json and only the push event.
GitHub sends push events for every branch, not just main. .doco-cd.yaml
sets webhook_filter: ^refs/heads/main$ so doco-cd skips the others, and
reference: refs/heads/main so deploys always run from main. Without them,
pushing a PR branch (Renovate's included) would deploy it to the NAS before
it is merged.
Gatus checks https://doco-cd-webhook.bykaj.io/v1/health from the cluster,
through the same public path GitHub uses. It doesn't probe /v1/webhook,
because every request there (even a GET) shows up as a failed job in
doco-cd's run history. /v1/health only returns {"content":"healthy"}.
Ingress and DNS¶
Traefik (02-traefik) is the reverse proxy for every
stack on the shared apps network. It terminates TLS for *.bykaj.app and
*.bykaj.io with Let's Encrypt certificates (Cloudflare DNS-01) and also
forwards plain TCP on 8080 (web-alt). UDP protocols that reply from a new
port, such as TFTP, can't go through Traefik's UDP proxy and publish their port
directly instead.
A stack opts in with labels:
labels:
dexd.enabled: "true" # create a DNS record in UniFi
traefik.enable: "true"
traefik.http.routers.myapp.rule: Host(`myapp.bykaj.app`)
traefik.http.services.myapp.loadbalancer.server.port: "8080"
dexd (03-dexd) watches Docker labels and
writes a CNAME to the UDM for each Host() rule, pointing at docker.bykaj.app
(a static A record for 10.73.2.100). NAS services are LAN-only. See
DNS → NAS records.
Stacks¶
00-doco-cd¶
doco-cd itself, with SELF_UPDATE_ENABLED=true. When a deploy changes this
stack, doco-cd replaces its own container. It uses the applier strategy,
because container_name rules out a zero-downtime scale_out: a throwaway copy of doco-cd recreates the container,
waits for it to become healthy, and restores the previous container if it
doesn't. Webhook requests may get a 503 until the new container is healthy,
and the hourly poll catches up. A self-update that fails isn't retried until
the next commit. See Self-Updating.
The data volume (doco-cd_data, the repo cache and the handover journal) is
external, so it survives any change to the stack. The secrets doco-cd needs to
start at all (1Password service account token, API and webhook secrets) can't
come from doco-cd. just bootstrap docker nas writes them to ~/.config/doco-cd/,
creates the volume and the shared apps network, and starts this stack only if
no doco-cd container from the 00-doco-cd project is running. After that,
doco-cd manages it.
doco-cd publishes no ports. Its API and webhook are only reachable through
Traefik at doco-cd.bykaj.app, so just docker sync-stacks and the webhook
both depend on 02-traefik. If Traefik is down, the hourly poll still deploys
fixes to it; follow along with sudo docker logs doco-cd on the NAS.
01-frr¶
FRR in host network mode. It peers with the UDM as
ASN 64515 from 10.73.1.10 (also its router ID) and announces the Traefik
address 10.73.2.100/32. See
BGP & Load Balancing.
02-traefik¶
Reverse proxy and TLS termination for the other stacks, doco-cd included.
It joins the apps network as external: just bootstrap docker nas creates it, so
doco-cd can attach to it before Traefik is deployed.
03-dexd¶
DNS records in UniFi for labelled containers.
04-exporters¶
node-exporter and smartctl-exporter for NAS host and disk metrics, scraped
by the cluster's Prometheus.
05-garage¶
Garage S3-compatible object storage at
s3.bykaj.io, with garage-ui for
management (OIDC login). CNPG stores WAL archives and base backups here.
06-bootimus¶
Bootimus PXE/netboot server (TFTP +
HTTP), with its admin UI at bootimus.bykaj.app. It is used to boot Talos
installers on bare metal. iPXE HTTP on 8080 goes through Traefik; TFTP publishes
10.73.2.100:69/udp straight from the container. UniFi DHCP on the Home and
Cluster networks points clients at 10.73.2.100 with filename ipxe.efi.
Proxmox VE¶
Bootimus has no Proxmox profile: it boots the extracted kernel and initrd with
Debian live parameters, and the Proxmox installer then stops because it can't
find its ISO. The fix is to embed the ISO in the initrd as proxmox.iso, as
Proxmox's own PXE setup does. Bootimus's initrd override can't be used for this
on UEFI: it appends initrd as an iPXE argument rather than a name, so
initrd=initrd fails with iPXE error 0x7f04828e. Replace the extracted
initrd in place instead, padding the original to a 4-byte boundary so the
kernel finds the appended archive:
sudo sh -c 'cd /mnt/vault/Applications/bootimus/data/isos/<image> \
&& { [ -f initrd.orig ] || cp -p initrd initrd.orig; } \
&& pad=$(( (4 - $(stat -c%s initrd.orig) % 4) % 4 )) \
&& ln -sf ../<image>.iso proxmox.iso \
&& { cat initrd.orig; head -c $pad /dev/zero; echo proxmox.iso | cpio -L -H newc -o; } > initrd.new \
&& mv -f initrd.new initrd && rm -f proxmox.iso \
&& chown --reference=. initrd initrd.orig'
In the image's properties, leave Initrd File on Auto-detected and set Boot Parameters to:
proxmox-tui-mode starts the terminal installer; the graphical one picks a
resolution the JetKVM can't show in full. The client needs more than about
4 GB of RAM, since the whole ISO is loaded into memory.
Warning
Re-extracting or replacing the ISO in Bootimus restores the original
initrd, so repeat these steps for every new Proxmox ISO.
07-zot¶
Zot OCI registry at registry.bykaj.app, acting as
an on-demand pull-through cache for Docker Hub (/docker-hub), GHCR (/ghcr),
Quay (/quay) and registry.k8s.io (/k8s). Talos nodes use it as their
registry mirror, falling back to upstream when it is unavailable.
Prometheus scrapes its metrics at https://registry.bykaj.app/metrics
(the zot ScrapeConfig in kube-prometheus-stack). accessControl.metrics
allows anonymous reads, and the hostname only resolves on the LAN.
Note
config.json is a single-file bind mount. After doco-cd redeploys a config
change, restart the container (sudo docker restart zot) for it to take
effect.
08-filen-cli¶
Filen CLI serving the
Filen drive over WebDAV at webdav.bykaj.io (basic auth). A TrueNAS Cloud Sync
task pushes the Paperless documents to it (see
Document sync).
The CLI logs in with an auth config instead of email and password, so the
account's two-factor authentication doesn't block it. Create one with
filen export-auth-config on a machine where the CLI is logged in, and store
the file's contents (one line, no trailing newline) in the
FILEN_AUTH_CONFIG field of the filen-cli 1Password item. Changing
the Filen password invalidates it.
The CLI downloads its managed rclone and keeps its VFS cache (up to 5 GiB) and
logs in /mnt/vault/Applications/filen-cli/data.
Adding a stack¶
Follow the
add-docker-app
skill for proxy, network and secret conventions. Validate locally with:
Warnings about unset ${VAR}s are expected; doco-cd provides those at deploy
time.