Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43c54f18b8 | ||
|
|
16e7ea8645 | ||
|
|
27f4dc3cfe |
@@ -32,7 +32,7 @@ De HTPC omgeving omvat onder andere de volgende diensten:
|
|||||||
| **Lidarr** | `8686` | Automatisch beheer en downloaden van muziek |
|
| **Lidarr** | `8686` | Automatisch beheer en downloaden van muziek |
|
||||||
| **Bazarr** | `6767` | Ondertitelbeheer en synchronisatie |
|
| **Bazarr** | `6767` | Ondertitelbeheer en synchronisatie |
|
||||||
| **Jackett / Prowlarr** | `9117` / `9696` | Torrent- en usenet indexer proxy |
|
| **Jackett / Prowlarr** | `9117` / `9696` | Torrent- en usenet indexer proxy |
|
||||||
| **SABnzbd / Torrent** | `8080` / `8085` | Downloadclients voor media-acquisitie |
|
| **SABnzbd / Transmission** | `8080` / `9091` | Downloadclients voor media-acquisitie (BitTorrent peer-poort `53662`) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -60,3 +60,10 @@ Voor het migreren van de standalone `radarr.service` op `10.2.0.4` naar de Kuber
|
|||||||
- **Dataopslag**: PersistentVolumeClaim `radarr-config` (10Gi, `local-path` op `/datadisk/infra/pv`).
|
- **Dataopslag**: PersistentVolumeClaim `radarr-config` (10Gi, `local-path` op `/datadisk/infra/pv`).
|
||||||
- **Mediaopslag**: HostPath `/datadisk` gemount op `/datadisk` (voor films in `/datadisk/htpc/Films` en downloads in `/datadisk/upload`).
|
- **Mediaopslag**: HostPath `/datadisk` gemount op `/datadisk` (voor films in `/datadisk/htpc/Films` en downloads in `/datadisk/upload`).
|
||||||
- **Netwerk & Ingress**: Luistert op poort `7878` (zowel via ClusterIP als HostPort `7878` op `10.2.0.4`), waardoor de bestaande Apache reverse proxy rule (`ProxyPass /radarr http://127.0.0.1:7878/radarr`) naadloos blijft functioneren.
|
- **Netwerk & Ingress**: Luistert op poort `7878` (zowel via ClusterIP als HostPort `7878` op `10.2.0.4`), waardoor de bestaande Apache reverse proxy rule (`ProxyPass /radarr http://127.0.0.1:7878/radarr`) naadloos blijft functioneren.
|
||||||
|
|
||||||
|
### Transmission
|
||||||
|
De BitTorrent daemon (`transmission`) draait als pod in de `htpc` namespace:
|
||||||
|
|
||||||
|
- **Dataopslag**: PersistentVolumeClaim `transmission-config` (10Gi, `local-path` op `/datadisk/infra/pv`), gemigreerd vanuit `/var/www/.config/transmission-daemon` met behoud van alle torrents, resume-bestanden en instellingen.
|
||||||
|
- **Mediaopslag**: HostPath `/datadisk` en `/mnt/mp3` zodat `/datadisk/upload/finished` en `/datadisk/upload/incomplete` identiek zijn voor Transmission, Radarr, Sonarr en Lidarr.
|
||||||
|
- **Netwerk**: Web UI / RPC op poort `9091` (ClusterIP + HostPort `9091`) en BitTorrent peer-poort `53662` (TCP & UDP, ClusterIP + HostPort `53662`).
|
||||||
|
|||||||
Executable
+55
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# ==============================================================================
|
||||||
|
# Opruimen van oude standalone Transmission installatie op vmserver (10.2.0.4)
|
||||||
|
# ==============================================================================
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CLUSTER_HOST="10.2.0.4"
|
||||||
|
SSH_USER="bart"
|
||||||
|
|
||||||
|
COLOR_GREEN="\033[0;32m"
|
||||||
|
COLOR_YELLOW="\033[1;33m"
|
||||||
|
COLOR_RED="\033[0;31m"
|
||||||
|
COLOR_BLUE="\033[0;34m"
|
||||||
|
COLOR_RESET="\033[0m"
|
||||||
|
|
||||||
|
log_info() { echo -e "${COLOR_GREEN}[INFO]${COLOR_RESET} $1"; }
|
||||||
|
log_step() { echo -e "\n${COLOR_BLUE}==>${COLOR_RESET} ${COLOR_GREEN}$1${COLOR_RESET}"; }
|
||||||
|
log_warn() { echo -e "${COLOR_YELLOW}[WARN]${COLOR_RESET} $1"; }
|
||||||
|
|
||||||
|
echo "========================================================================"
|
||||||
|
echo " OPRUIMEN OUDE STANDALONE TRANSMISSION OP $CLUSTER_HOST"
|
||||||
|
echo "========================================================================"
|
||||||
|
echo "Dit stopt en verwijdert de oude standalone bestanden op $CLUSTER_HOST:"
|
||||||
|
echo " - /etc/systemd/system/transmission-daemon.service"
|
||||||
|
echo " - /var/www/.config/transmission-daemon"
|
||||||
|
echo " - /etc/transmission-daemon & /var/lib/transmission-daemon"
|
||||||
|
echo "Er is al een reservekopie gemaakt in /storage/backups/transmission_complete_backup_2026-10-18.tar.gz"
|
||||||
|
echo "========================================================================"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
read -p "Weet je zeker dat je de oude Transmission bestanden wilt verwijderen? (j/N): " -r CONFIRM
|
||||||
|
if [[ ! "$CONFIRM" =~ ^[jJyY]$ ]]; then
|
||||||
|
log_info "Opruimen geannuleerd."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_step "Verwijderen van systemd service en configuratiebestanden op ${CLUSTER_HOST}..."
|
||||||
|
ssh -t "${SSH_USER}@${CLUSTER_HOST}" "
|
||||||
|
echo '--> Stoppen en uitschakelen van transmission-daemon.service...'
|
||||||
|
sudo systemctl stop transmission-daemon 2>/dev/null || true
|
||||||
|
sudo systemctl disable transmission-daemon 2>/dev/null || true
|
||||||
|
sudo rm -f /etc/systemd/system/transmission-daemon.service
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl reset-failed 2>/dev/null || true
|
||||||
|
|
||||||
|
echo '--> Verwijderen van /var/www/.config/transmission-daemon...'
|
||||||
|
sudo rm -rf /var/www/.config/transmission-daemon
|
||||||
|
|
||||||
|
echo '--> Opslagruimte controleren...'
|
||||||
|
df -h / /storage
|
||||||
|
"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
log_info "De oude standalone Transmission is succesvol en volledig opgeruimd!"
|
||||||
|
echo "Alle verkeer naar poort 9091 en 53662 loopt nu direct via de Kubernetes pod."
|
||||||
@@ -8,5 +8,6 @@ resources:
|
|||||||
- radarr
|
- radarr
|
||||||
- sonarr
|
- sonarr
|
||||||
- lidarr
|
- lidarr
|
||||||
|
- transmission
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
apiVersion: batch/v1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: transmission-cleanup
|
||||||
|
namespace: htpc
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: transmission-cleanup
|
||||||
|
app.kubernetes.io/part-of: htpc
|
||||||
|
spec:
|
||||||
|
schedule: "*/15 * * * *"
|
||||||
|
concurrencyPolicy: Forbid
|
||||||
|
successfulJobsHistoryLimit: 1
|
||||||
|
failedJobsHistoryLimit: 2
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: transmission-cleanup
|
||||||
|
app.kubernetes.io/part-of: htpc
|
||||||
|
spec:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: vmserver
|
||||||
|
restartPolicy: OnFailure
|
||||||
|
containers:
|
||||||
|
- name: cleanup
|
||||||
|
image: lscr.io/linuxserver/transmission:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -euo pipefail
|
||||||
|
RPC_URL="http://transmission.htpc.svc.cluster.local:9091/transmission/rpc"
|
||||||
|
MAX_IDLE_SECONDS=43200 # 12 uur
|
||||||
|
|
||||||
|
SESSION=$(curl -s "$RPC_URL" | sed -n 's/.*X-Transmission-Session-Id: \([^<]*\).*/\1/p')
|
||||||
|
if [ -z "$SESSION" ]; then
|
||||||
|
echo "Kon geen X-Transmission-Session-Id ophalen."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
NOW=$(date +%s)
|
||||||
|
RESPONSE=$(curl -s -H "X-Transmission-Session-Id: $SESSION" \
|
||||||
|
-d '{"method":"torrent-get","arguments":{"fields":["id","name","activityDate","addedDate","rateDownload","rateUpload","percentDone","status"]}}' \
|
||||||
|
"$RPC_URL")
|
||||||
|
|
||||||
|
STALE_JSON=$(echo "$RESPONSE" | jq -c --argjson now "$NOW" --argjson max_idle "$MAX_IDLE_SECONDS" '
|
||||||
|
[
|
||||||
|
.arguments.torrents[]
|
||||||
|
| (. as $t | (if $t.activityDate > $t.addedDate then $t.activityDate else $t.addedDate end)) as $last_active
|
||||||
|
| select($last_active > 0 and (($now - $last_active) > $max_idle) and (.rateDownload == 0) and (.rateUpload == 0))
|
||||||
|
| {id: .id, name: .name, idle_hours: ((($now - $last_active) / 3600 * 10 | floor) / 10)}
|
||||||
|
]
|
||||||
|
')
|
||||||
|
|
||||||
|
COUNT=$(echo "$STALE_JSON" | jq 'length')
|
||||||
|
if [ "$COUNT" -eq 0 ]; then
|
||||||
|
echo "Geen torrents gevonden die langer dan 12 uur inactief zijn."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Verwijderen van $COUNT inactieve torrents (>12u) inclusief lokale data:"
|
||||||
|
echo "$STALE_JSON" | jq -r '.[] | " - [\(.id)] \(.name) (\(.idle_hours)u inactief)"'
|
||||||
|
|
||||||
|
IDS=$(echo "$STALE_JSON" | jq -c '[.[].id]')
|
||||||
|
REMOVE_PAYLOAD=$(jq -nc --argjson ids "$IDS" '{"method":"torrent-remove","arguments":{"ids":$ids,"delete-local-data":true}}')
|
||||||
|
|
||||||
|
RESULT=$(curl -s -H "X-Transmission-Session-Id: $SESSION" -d "$REMOVE_PAYLOAD" "$RPC_URL")
|
||||||
|
echo "RPC resultaat: $RESULT"
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: transmission
|
||||||
|
namespace: htpc
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: transmission
|
||||||
|
app.kubernetes.io/part-of: htpc
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: transmission
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: transmission
|
||||||
|
app.kubernetes.io/name: transmission
|
||||||
|
app.kubernetes.io/part-of: htpc
|
||||||
|
spec:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: vmserver
|
||||||
|
initContainers:
|
||||||
|
- name: migrate-config
|
||||||
|
image: lscr.io/linuxserver/transmission:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [ ! -d /config/torrents ] && [ -d /host-config/torrents ]; then
|
||||||
|
echo "Migrating transmission config from host..."
|
||||||
|
cp -a /host-config/torrents /config/
|
||||||
|
cp -a /host-config/resume /config/
|
||||||
|
[ -d /host-config/blocklists ] && cp -a /host-config/blocklists /config/
|
||||||
|
for f in settings.json stats.json dht.dat bandwidth-groups.json; do
|
||||||
|
[ -f "/host-config/$f" ] && cp -a "/host-config/$f" /config/
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
if [ -f /config/settings.json ]; then
|
||||||
|
sed -i 's/"rpc-authentication-required": true/"rpc-authentication-required": false/g' /config/settings.json
|
||||||
|
sed -i 's/"rpc-whitelist-enabled": true/"rpc-whitelist-enabled": false/g' /config/settings.json
|
||||||
|
sed -i 's/"rpc-host-whitelist-enabled": true/"rpc-host-whitelist-enabled": false/g' /config/settings.json
|
||||||
|
fi
|
||||||
|
chown -R 33:33 /config
|
||||||
|
volumeMounts:
|
||||||
|
- name: config
|
||||||
|
mountPath: /config
|
||||||
|
- name: host-config
|
||||||
|
mountPath: /host-config
|
||||||
|
readOnly: true
|
||||||
|
containers:
|
||||||
|
- name: transmission
|
||||||
|
image: lscr.io/linuxserver/transmission:latest
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
env:
|
||||||
|
- name: PUID
|
||||||
|
value: "33"
|
||||||
|
- name: PGID
|
||||||
|
value: "33"
|
||||||
|
- name: TZ
|
||||||
|
value: "Europe/Amsterdam"
|
||||||
|
- name: UMASK
|
||||||
|
value: "0002"
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: transmission-secret
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 9091
|
||||||
|
hostPort: 9091
|
||||||
|
protocol: TCP
|
||||||
|
- name: peer-tcp
|
||||||
|
containerPort: 53662
|
||||||
|
hostPort: 53662
|
||||||
|
protocol: TCP
|
||||||
|
- name: peer-udp
|
||||||
|
containerPort: 53662
|
||||||
|
hostPort: 53662
|
||||||
|
protocol: UDP
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 256Mi
|
||||||
|
limits:
|
||||||
|
cpu: 2000m
|
||||||
|
memory: 4Gi
|
||||||
|
volumeMounts:
|
||||||
|
- name: config
|
||||||
|
mountPath: /config
|
||||||
|
- name: datadisk
|
||||||
|
mountPath: /datadisk
|
||||||
|
- name: mnt-mp3
|
||||||
|
mountPath: /mnt/mp3
|
||||||
|
livenessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 9091
|
||||||
|
initialDelaySeconds: 60
|
||||||
|
periodSeconds: 20
|
||||||
|
timeoutSeconds: 5
|
||||||
|
readinessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: 9091
|
||||||
|
initialDelaySeconds: 15
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 5
|
||||||
|
volumes:
|
||||||
|
- name: config
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: transmission-config
|
||||||
|
- name: host-config
|
||||||
|
hostPath:
|
||||||
|
path: /var/www/.config/transmission-daemon
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
- name: datadisk
|
||||||
|
hostPath:
|
||||||
|
path: /datadisk
|
||||||
|
type: Directory
|
||||||
|
- name: mnt-mp3
|
||||||
|
hostPath:
|
||||||
|
path: /mnt/mp3
|
||||||
|
type: Directory
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- secret.yaml
|
||||||
|
- pvc.yaml
|
||||||
|
- service.yaml
|
||||||
|
- deployment.yaml
|
||||||
|
- cronjob.yaml
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: transmission-config
|
||||||
|
namespace: htpc
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: transmission
|
||||||
|
app.kubernetes.io/part-of: htpc
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
storageClassName: local-path
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: transmission-secret
|
||||||
|
namespace: htpc
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: transmission
|
||||||
|
app.kubernetes.io/part-of: htpc
|
||||||
|
type: Opaque
|
||||||
|
stringData:
|
||||||
|
PEERPORT: "53662"
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: transmission
|
||||||
|
namespace: htpc
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/name: transmission
|
||||||
|
app.kubernetes.io/part-of: htpc
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
ports:
|
||||||
|
- port: 9091
|
||||||
|
targetPort: 9091
|
||||||
|
protocol: TCP
|
||||||
|
name: http
|
||||||
|
- port: 53662
|
||||||
|
targetPort: 53662
|
||||||
|
protocol: TCP
|
||||||
|
name: peer-tcp
|
||||||
|
- port: 53662
|
||||||
|
targetPort: 53662
|
||||||
|
protocol: UDP
|
||||||
|
name: peer-udp
|
||||||
|
selector:
|
||||||
|
app: transmission
|
||||||
Reference in New Issue
Block a user