Files
infrastructure/servers/legion/k8s/media/fornax-workers.yaml
T
Will Anderson 69976ca172 Fix main qbt server selection; bump portforward-helper memory limit
- Main qbt: switch from pinned US-IL#149 (no PF) to SERVER_REGIONS=Illinois so
  gluetun picks any IL server with port forwarding enabled
- Fornax workers: portforward-helper 32Mi→96Mi to stop OOMKill
2026-04-11 10:03:52 -05:00

301 lines
10 KiB
YAML

# Fornax distributed torrent workers — each is a gluetun+qBittorrent pod on a different VPN server
# Worker TX#253: US-TX#253, NAT-PMP via gluetun native ProtonVPN port forwarding
# Worker TX#34: US-TX#34, NAT-PMP via gluetun native ProtonVPN port forwarding
# Both workers share the media-data PVC; each has its own config PVC and VPN credentials
# The Fornax coordinator proxy (TBD) routes work across these workers
# ── Worker TX#253 ─────────────────────────────────────────────────────────────
apiVersion: apps/v1
kind: Deployment
metadata:
name: fornax-worker-tx253
namespace: media
labels:
app: fornax-worker-tx253
fornax-role: worker
fornax-server: us-tx-253
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: fornax-worker-tx253
template:
metadata:
labels:
app: fornax-worker-tx253
fornax-role: worker
fornax-server: us-tx-253
spec:
initContainers:
- name: tun-setup
image: busybox:latest
command: ["sh", "-c", "mkdir -p /dev/net && [ -c /dev/net/tun ] || mknod /dev/net/tun c 10 200 && chmod 666 /dev/net/tun && sysctl -w net.ipv6.conf.all.disable_ipv6=1 || true && ip route flush table 51820 2>/dev/null || true && ip rule del priority 101 2>/dev/null || true && ip rule del table 51820 2>/dev/null || true"]
securityContext:
privileged: true
containers:
- name: gluetun
image: ghcr.io/qdm12/gluetun:latest
securityContext:
capabilities:
add: ["NET_ADMIN"]
env:
# Use protonvpn provider so gluetun handles NAT-PMP natively
- name: VPN_SERVICE_PROVIDER
value: "protonvpn"
- name: VPN_TYPE
value: "wireguard"
- name: WIREGUARD_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: fornax-worker-tx253-secrets
key: PROTONVPN_PRIVATE_KEY
# US-TX#179 — from gluetun's built-in ProtonVPN server list
- name: SERVER_NAMES
value: "US-TX#179"
# gluetun handles NAT-PMP internally, exposes port at :8000/v1/openvpn/portforwarded
- name: VPN_PORT_FORWARDING
value: "on"
- name: FIREWALL_OUTBOUND_SUBNETS
value: "10.42.0.0/16,10.43.0.0/16"
ports:
- containerPort: 8000 # gluetun control server
- containerPort: 8888 # gluetun HTTP proxy
resources:
requests:
memory: 128Mi
cpu: 50m
limits:
memory: 512Mi
cpu: 200m
# Port forwarding helper — polls gluetun's control API for the assigned port,
# then updates qBittorrent. No natpmpc needed; gluetun handles the NAT-PMP exchange.
- name: portforward-helper
image: alpine:latest
command:
- sh
- -c
- |
echo "Waiting for gluetun to assign a forwarded port..."
until apk add -q curl 2>/dev/null; do sleep 5; done
while true; do
RESP=$(curl -s http://localhost:8000/v1/openvpn/portforwarded 2>/dev/null)
PORT=$(echo "$RESP" | grep -oE '"port":[0-9]+' | grep -oE '[0-9]+$')
if [ -n "$PORT" ] && [ "$PORT" != "0" ]; then
echo "$(date): Forwarded port: $PORT — updating qBittorrent"
curl -s -c /tmp/qbt.txt -X POST http://localhost:8080/api/v2/auth/login \
-d "username=admin&password=adminadmin" >/dev/null 2>&1
curl -s -b /tmp/qbt.txt -X POST http://localhost:8080/api/v2/app/setPreferences \
-d "json={\"listen_port\":$PORT,\"random_port\":false}" >/dev/null 2>&1
echo "$(date): qBittorrent listen port set to $PORT"
else
echo "$(date): No port yet (gluetun response: $RESP)"
fi
sleep 45
done
resources:
requests:
memory: 32Mi
cpu: 10m
limits:
memory: 96Mi
cpu: 50m
- name: qbittorrent
image: lscr.io/linuxserver/qbittorrent:latest
env:
- name: PUID
value: "1000"
- name: PGID
value: "1000"
- name: TZ
value: "America/Chicago"
- name: WEBUI_PORT
value: "8080"
ports:
- containerPort: 8080
volumeMounts:
- name: config
mountPath: /config
- name: media
mountPath: /media
resources:
requests:
memory: 256Mi
cpu: 100m
limits:
memory: 1Gi
cpu: 500m
volumes:
- name: config
persistentVolumeClaim:
claimName: fornax-worker-tx253-config
- name: media
persistentVolumeClaim:
claimName: media-data
---
apiVersion: v1
kind: Service
metadata:
name: fornax-worker-tx253
namespace: media
labels:
app: fornax-worker-tx253
fornax-role: worker
spec:
selector:
app: fornax-worker-tx253
ports:
- name: webui
port: 8080
targetPort: 8080
type: ClusterIP
---
# ── Worker TX#34 ──────────────────────────────────────────────────────────────
apiVersion: apps/v1
kind: Deployment
metadata:
name: fornax-worker-tx34
namespace: media
labels:
app: fornax-worker-tx34
fornax-role: worker
fornax-server: us-tx-34
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: fornax-worker-tx34
template:
metadata:
labels:
app: fornax-worker-tx34
fornax-role: worker
fornax-server: us-tx-34
spec:
initContainers:
- name: tun-setup
image: busybox:latest
command: ["sh", "-c", "mkdir -p /dev/net && [ -c /dev/net/tun ] || mknod /dev/net/tun c 10 200 && chmod 666 /dev/net/tun && sysctl -w net.ipv6.conf.all.disable_ipv6=1 || true && ip route flush table 51820 2>/dev/null || true && ip rule del priority 101 2>/dev/null || true && ip rule del table 51820 2>/dev/null || true"]
securityContext:
privileged: true
containers:
- name: gluetun
image: ghcr.io/qdm12/gluetun:latest
securityContext:
capabilities:
add: ["NET_ADMIN"]
env:
- name: VPN_SERVICE_PROVIDER
value: "protonvpn"
- name: VPN_TYPE
value: "wireguard"
- name: WIREGUARD_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: fornax-worker-tx34-secrets
key: PROTONVPN_PRIVATE_KEY
# US-TX#220 — from gluetun's built-in ProtonVPN server list
- name: SERVER_NAMES
value: "US-TX#220"
- name: VPN_PORT_FORWARDING
value: "on"
- name: FIREWALL_OUTBOUND_SUBNETS
value: "10.42.0.0/16,10.43.0.0/16"
ports:
- containerPort: 8000
- containerPort: 8888
resources:
requests:
memory: 128Mi
cpu: 50m
limits:
memory: 512Mi
cpu: 200m
- name: portforward-helper
image: alpine:latest
command:
- sh
- -c
- |
echo "Waiting for gluetun to assign a forwarded port..."
until apk add -q curl 2>/dev/null; do sleep 5; done
while true; do
RESP=$(curl -s http://localhost:8000/v1/openvpn/portforwarded 2>/dev/null)
PORT=$(echo "$RESP" | grep -oE '"port":[0-9]+' | grep -oE '[0-9]+$')
if [ -n "$PORT" ] && [ "$PORT" != "0" ]; then
echo "$(date): Forwarded port: $PORT — updating qBittorrent"
curl -s -c /tmp/qbt.txt -X POST http://localhost:8080/api/v2/auth/login \
-d "username=admin&password=adminadmin" >/dev/null 2>&1
curl -s -b /tmp/qbt.txt -X POST http://localhost:8080/api/v2/app/setPreferences \
-d "json={\"listen_port\":$PORT,\"random_port\":false}" >/dev/null 2>&1
echo "$(date): qBittorrent listen port set to $PORT"
else
echo "$(date): No port yet (gluetun response: $RESP)"
fi
sleep 45
done
resources:
requests:
memory: 32Mi
cpu: 10m
limits:
memory: 96Mi
cpu: 50m
- name: qbittorrent
image: lscr.io/linuxserver/qbittorrent:latest
env:
- name: PUID
value: "1000"
- name: PGID
value: "1000"
- name: TZ
value: "America/Chicago"
- name: WEBUI_PORT
value: "8080"
ports:
- containerPort: 8080
volumeMounts:
- name: config
mountPath: /config
- name: media
mountPath: /media
resources:
requests:
memory: 256Mi
cpu: 100m
limits:
memory: 1Gi
cpu: 500m
volumes:
- name: config
persistentVolumeClaim:
claimName: fornax-worker-tx34-config
- name: media
persistentVolumeClaim:
claimName: media-data
---
apiVersion: v1
kind: Service
metadata:
name: fornax-worker-tx34
namespace: media
labels:
app: fornax-worker-tx34
fornax-role: worker
spec:
selector:
app: fornax-worker-tx34
ports:
- name: webui
port: 8080
targetPort: 8080
type: ClusterIP