Boot-time NodePort proxies on k8s-router (CT 106)

The Cloudflare tunnels terminate on the router’s WAN address (192.168.0.250). Because locally originated traffic does not traverse the PREROUTING chain, each tunnel target is served by a local socat listener which forwards to a Talos NodePort on 10.10.50.10.

The six units are managed in two places from one set of files:

Source of truthPurpose
files/systemd/k8s-*-proxy.serviceCanonical unit definitions (copied from the live container, descriptions/ordering corrected).
router-proxy.ymlApplies them to a running CT 106: installs socat, copies units, enables + starts them.
../router.tfStages the same files into the LXC entrypoint, so they are present and enabled after a recreate.

Port map

UnitListens on routerForwards toUsed by
k8s-forgejo-proxy.service30000/tcp10.10.50.10:30000Forgejo NodePort
k8s-nextcloud-proxy.service30030/tcp10.10.50.10:30030Nextcloud NodePort
k8s-euro-office-proxy.service8888/tcp10.10.50.10:30080Euro-Office via Traefik
k8s-nginx-demo-proxy.service30002/tcp10.10.50.10:30002nginx-demo NodePort
k8s-argocd-proxy.service30004/tcp10.10.50.10:30004Argo CD NodePort
k8s-bureaublad-proxy.service30012/tcp10.10.50.10:30012bureaublad NodePort

All units have WantedBy=multi-user.target and are ordered After=network-online.target k8s-router.service, so they start only once the static network and NAT/DHCP bootstrap are done. The playbook creates the symlinks in /etc/systemd/system/multi-user.target.wants/; the router.tf entrypoint creates the same symlinks at container creation.

Note: older notes (routing-nodeports.md, argocd-cloudflare-tunnel.md) describe forwarding port 80 for Argo CD and port 30020 for Nextcloud. The live units use 30004 and 30030 respectively — the table above is authoritative.

Prerequisites

hosts.yml targets 192.168.0.250 as root. Unlike CT 105, the Ubuntu LXC template does not seed the control node’s SSH key, so authorize it once:

ssh-copy-id root@192.168.0.250

If the key is elsewhere, pass it explicitly:

ansible-playbook router-proxy.yml --private-key ~/.ssh/id_ed25519

Usage

cd ansible2
ansible-playbook router-proxy.yml

The playbook is idempotent: unit files are only rewritten when they differ, systemd daemon-reload/restarter runs only on change, and the final tasks assert that every proxy is active and listening. To change a mapping, edit the unit in files/systemd/, update the port in router-proxy.yml (used by the listener check) and re-run the playbook. The same edit automatically flows into the next tofu apply that recreates CT 106.

Verification

ssh root@192.168.0.250 \
  'systemctl list-unit-files "k8s-*proxy.service"; systemctl is-active k8s-*proxy.service; ss -ltnp | grep socat'

Expected: all six units enabled and active (running), with listeners on 30000, 30030, 8888, 30002, 30004 and 30012.

Origin check (replace the port as needed):

curl -sS -o /dev/null -w '%{http_code}\n' http://192.168.0.250:30000/

Recreating CT 106

initialization.entrypoint is only executed when the container is created. After changing files/systemd/*.service, recreate the router to apply the bootstrap copies:

cd ..
tofu apply -refresh=false -auto-approve \
  -replace=proxmox_virtual_environment_container.router \
  -target=proxmox_virtual_environment_container.router

Then re-run ansible-playbook router-proxy.yml to reconcile a container that was changed manually. See ../router_changes.md for the router bootstrap background.