cce8c0a0d4
US-TX#253 and US-TX#34 aren't in gluetun's built-in list. Switching to: - Main qbt: US-IL#149 (was US-IL#267) - Fornax TX253: US-TX#179 - Fornax TX34: US-TX#220 Private keys are per-account and work with any ProtonVPN WireGuard server.
148 lines
5.1 KiB
YAML
148 lines
5.1 KiB
YAML
# gluetun + qBittorrent — all torrent traffic routed through ProtonVPN WireGuard
|
|
# gluetun runs as the VPN container; qBittorrent shares its network namespace (same pod)
|
|
# Port forwarding via gluetun's native ProtonVPN support (VPN_PORT_FORWARDING=on)
|
|
# — gluetun handles NAT-PMP internally, exposes port at :8000/v1/openvpn/portforwarded
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: qbittorrent
|
|
namespace: media
|
|
labels:
|
|
app: qbittorrent
|
|
spec:
|
|
replicas: 1
|
|
strategy:
|
|
type: Recreate
|
|
selector:
|
|
matchLabels:
|
|
app: qbittorrent
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app: qbittorrent
|
|
spec:
|
|
initContainers:
|
|
# Ensure /dev/net/tun exists on the node
|
|
- 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:
|
|
# VPN container — protonvpn provider with native port forwarding support
|
|
- 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: media-secrets
|
|
key: PROTONVPN_PRIVATE_KEY
|
|
# US-IL#149 — from gluetun's built-in ProtonVPN server list
|
|
- name: SERVER_NAMES
|
|
value: "US-IL#149"
|
|
# gluetun handles NAT-PMP exchange natively for protonvpn provider
|
|
- name: VPN_PORT_FORWARDING
|
|
value: "on"
|
|
# Allow cluster-internal traffic to bypass VPN (for Radarr/Sonarr → qBittorrent API)
|
|
- 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 port forwarding to initialize..."
|
|
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: 16Mi
|
|
cpu: 10m
|
|
limits:
|
|
memory: 32Mi
|
|
cpu: 50m
|
|
|
|
# qBittorrent — shares gluetun's network namespace, all traffic through VPN
|
|
- 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: qbittorrent-config
|
|
- name: media
|
|
persistentVolumeClaim:
|
|
claimName: media-data
|
|
---
|
|
apiVersion: v1
|
|
kind: Service
|
|
metadata:
|
|
name: qbittorrent
|
|
namespace: media
|
|
spec:
|
|
selector:
|
|
app: qbittorrent
|
|
ports:
|
|
- name: webui
|
|
port: 8080
|
|
targetPort: 8080
|
|
type: ClusterIP
|