9cd3dd0134
Custom WireGuard mode doesn't support NAT-PMP port forwarding — peers can't connect inbound so most torrents stall. Switching to protonvpn provider with SERVER_FEATURES=p2p picks a port-forwarding-capable server and VPN_PORT_FORWARDING=on handles the NAT-PMP handshake. Up command updates qBittorrent listen port automatically when gluetun gets the port.
119 lines
3.9 KiB
YAML
119 lines
3.9 KiB
YAML
# gluetun + qBittorrent — all torrent traffic routed through ProtonVPN WireGuard
|
|
# gluetun runs as the VPN container; qBittorrent shares its network namespace (same pod)
|
|
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 rule del table 51820 2>/dev/null || true && ip route flush table 51820 2>/dev/null || true"]
|
|
securityContext:
|
|
privileged: true
|
|
containers:
|
|
# VPN container — must come first so network is up before qBittorrent starts
|
|
- 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
|
|
# Pick a US P2P server — P2P servers support port forwarding
|
|
- name: SERVER_COUNTRIES
|
|
value: "United States"
|
|
- name: SERVER_FEATURES
|
|
value: "p2p"
|
|
# Port forwarding via NAT-PMP — lets peers connect inbound, fixes slow/stalled downloads
|
|
- name: VPN_PORT_FORWARDING
|
|
value: "on"
|
|
# When gluetun gets a forwarded port, tell qBittorrent to listen on it
|
|
- name: VPN_PORT_FORWARDING_UP_COMMAND
|
|
value: "/bin/sh -c 'curl -s -c /tmp/pf.jar -X POST http://localhost:8080/api/v2/auth/login -d username=admin&password=adminadmin >/dev/null && curl -s -b /tmp/pf.jar -X POST http://localhost:8080/api/v2/app/setPreferences -d \"json={\\\"listen_port\\\":{{FORWARDED_PORT}}}\"'"
|
|
# 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"
|
|
- name: UPDATER_PERIOD
|
|
value: "24h"
|
|
ports:
|
|
- containerPort: 8888 # gluetun HTTP proxy (unused but required)
|
|
resources:
|
|
requests:
|
|
memory: 64Mi
|
|
cpu: 50m
|
|
limits:
|
|
memory: 128Mi
|
|
cpu: 200m
|
|
|
|
# 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
|