From ff7ec5e250c5a9783f29857364676159c20ce57b Mon Sep 17 00:00:00 2001 From: SmokyZone Date: Tue, 6 Oct 2026 16:44:15 +0200 Subject: [PATCH] Add Helm chart for the media stack Jellyfin (QuickSync), Sonarr, Radarr, Prowlarr, SABnzbd, Bazarr, Seerr and FlareSolverr in the media namespace. Shared hostPath /srv/media mounted at /data in every pod so imports are hardlinked; per-app config on local-path PVCs; LAN-only ingress via letsencrypt-dns-cloudflare. Co-Authored-By: Claude Opus 5.5 --- .gitignore | 1 + Chart.yaml | 17 ++++ README.md | 79 +++++++++++++++ templates/_helpers.tpl | 9 ++ templates/apps.yaml | 216 +++++++++++++++++++++++++++++++++++++++++ values.yaml | 162 +++++++++++++++++++++++++++++++ 6 files changed, 484 insertions(+) create mode 100644 .gitignore create mode 100644 Chart.yaml create mode 100644 README.md create mode 100644 templates/_helpers.tpl create mode 100644 templates/apps.yaml create mode 100644 values.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa1ec1e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.tgz diff --git a/Chart.yaml b/Chart.yaml new file mode 100644 index 0000000..292597f --- /dev/null +++ b/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v2 +name: media +description: Media stack (Jellyfin, Sonarr, Radarr, Prowlarr, SABnzbd, Bazarr, Seerr, FlareSolverr) on a single-node cluster +type: application +version: 0.1.0 +appVersion: "1.0.0" +home: https://git.smokyzone.de/SmokyZone/media-gitops +sources: + - https://git.smokyzone.de/SmokyZone/media-gitops +keywords: + - jellyfin + - sonarr + - radarr + - prowlarr + - sabnzbd +maintainers: + - name: SmokyZone diff --git a/README.md b/README.md new file mode 100644 index 0000000..804d11e --- /dev/null +++ b/README.md @@ -0,0 +1,79 @@ +# media-gitops + +Helm chart for the media stack on the single-node cluster (`loki`), deployed by ArgoCD +via the `apps-in-apps` repo into the namespace `media`. + +| App | Purpose | URL | +|---|---|---| +| Jellyfin | Media server (Intel QuickSync transcoding) | https://jellyfin.smokyzone.de:30444 | +| Seerr | Request UI (successor of Jellyseerr) | https://seerr.smokyzone.de:30444 | +| Sonarr | TV shows | https://sonarr.smokyzone.de:30444 | +| Radarr | Movies | https://radarr.smokyzone.de:30444 | +| Prowlarr | Indexer manager, syncs indexers to Sonarr/Radarr | https://prowlarr.smokyzone.de:30444 | +| SABnzbd | Usenet download client | https://sabnzbd.smokyzone.de:30444 | +| Bazarr | Subtitles | https://bazarr.smokyzone.de:30444 | +| FlareSolverr | Cloudflare challenge solver for Prowlarr (in-cluster only) | `http://flaresolverr:8191` | + +The hostnames resolve to the node's private IP (`192.168.2.218`) via Cloudflare DNS-only +records, so the UIs are only reachable from the LAN or through a VPN into the LAN. +Certificates come from `letsencrypt-dns-cloudflare` (DNS-01). + +## Storage layout + +All apps that handle files mount the node directory `/srv/media` at `/data`. Downloads +and library live on the same filesystem, so Sonarr/Radarr **hardlink** imports instead +of copying (no double disk usage): + +``` +/data +├── usenet +│ ├── incomplete # SABnzbd temporary folder +│ └── complete +│ ├── tv # SABnzbd category "tv" +│ └── movies # SABnzbd category "movies" +└── media + ├── tv # Sonarr root folder, Jellyfin library "Shows" + └── movies # Radarr root folder, Jellyfin library "Movies" +``` + +The directories are created by an init container (owner `1000:1000`). Config/databases +of each app live on their own `local-path` PVC (`-config`). + +## First-time setup + +Everything below is stored in the apps' config PVCs, not in git. In-cluster, the apps +talk to each other by service name (`http://:`). + +1. **SABnzbd** - run the wizard, enter your Usenet provider (server, port 563, SSL). + - *Config → Folders*: Temporary `/data/usenet/incomplete`, Completed `/data/usenet/complete`. + - *Config → Categories*: `tv` → folder `tv`, `movies` → folder `movies`. + - Copy the API key (*Config → General*). +2. **Sonarr / Radarr** - set up authentication (Forms login). + - *Settings → Media Management*: root folder `/data/media/tv` (Sonarr) or + `/data/media/movies` (Radarr); keep "Use Hardlinks instead of Copy" enabled. + - *Settings → Download Clients → SABnzbd*: host `sabnzbd`, port `8080`, API key, + category `tv` / `movies`. + - Copy the API key (*Settings → General*). +3. **Prowlarr** - add your Usenet indexer(s). + - *Settings → Indexers*: add a FlareSolverr proxy (`http://flaresolverr:8191`, tag + `flaresolverr`) only if an indexer needs it. + - *Settings → Apps*: add Sonarr (`http://sonarr:8989`) and Radarr (`http://radarr:7878`) + with their API keys; Prowlarr server `http://prowlarr:9696`. +4. **Jellyfin** - run the wizard, add libraries `/data/media/tv` (Shows) and + `/data/media/movies` (Movies). + - *Dashboard → Playback → Transcoding*: Hardware acceleration **Intel QuickSync (QSV)** + (or VAAPI, device `/dev/dri/renderD128`), enable hardware decoding for H264/HEVC. +5. **Bazarr** - connect Sonarr (`sonarr:8989`) and Radarr (`radarr:7878`) with their API + keys, add subtitle providers and languages. +6. **Seerr** - sign in with Jellyfin (`http://jellyfin:8096`), then add Sonarr and Radarr + (same hosts/API keys, root folders as above). + +SABnzbd only accepts whitelisted Host headers; an init container keeps `host_whitelist` +in `sabnzbd.ini` set to the ingress hostname and the in-cluster service names. + +## Notes + +- Jellyfin runs **privileged** to access `/dev/dri` (no GPU device plugin installed). +- Image tags are pinned; bump them in `values.yaml` to upgrade. +- The node disk is shared with the rest of the cluster. Watch free space + (`df -h /srv/media` on loki); to add a dedicated disk later, mount it at `/srv/media`. diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl new file mode 100644 index 0000000..d2bdbc0 --- /dev/null +++ b/templates/_helpers.tpl @@ -0,0 +1,9 @@ +{{- define "media.labels" -}} +app.kubernetes.io/part-of: media +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* Comma-separated hostnames SABnzbd must accept (ingress + in-cluster service names). */}} +{{- define "media.sabnzbdHosts" -}} +sabnzbd.{{ .Values.ingress.domain }}, sabnzbd, sabnzbd.{{ .Values.namespace }}, sabnzbd.{{ .Values.namespace }}.svc, sabnzbd.{{ .Values.namespace }}.svc.cluster.local +{{- end }} diff --git a/templates/apps.yaml b/templates/apps.yaml new file mode 100644 index 0000000..304cf4d --- /dev/null +++ b/templates/apps.yaml @@ -0,0 +1,216 @@ +{{- $root := . }} +{{- range $name, $app := .Values.apps }} +{{- if $app.enabled }} +{{- $linuxserver := ne (toString $app.linuxserver) "false" }} +{{- if $app.configPath }} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ $name }}-config + namespace: {{ $root.Values.namespace }} + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 4 }} +spec: + accessModes: + - ReadWriteOnce + {{- if $root.Values.storageClassName }} + storageClassName: {{ $root.Values.storageClassName }} + {{- end }} + resources: + requests: + storage: {{ $app.configSize | default "1Gi" }} +--- +{{- end }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $name }} + namespace: {{ $root.Values.namespace }} + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 4 }} +spec: + replicas: 1 + # RWO volumes + SQLite databases: never run two instances at once. + strategy: + type: Recreate + selector: + matchLabels: + app.kubernetes.io/name: {{ $name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 8 }} + spec: + {{- if or $app.media $app.sabnzbdHostWhitelist }} + initContainers: + {{- if $app.media }} + - name: media-dirs + image: {{ $root.Values.initImage }} + command: + - sh + - -ec + - | + chown {{ $root.Values.common.puid }}:{{ $root.Values.common.pgid }} {{ $root.Values.media.mountPath }} + {{- range $root.Values.media.dirs }} + mkdir -p {{ $root.Values.media.mountPath }}/{{ . }} + chown {{ $root.Values.common.puid }}:{{ $root.Values.common.pgid }} {{ $root.Values.media.mountPath }}/{{ . }} + {{- end }} + volumeMounts: + - name: media + mountPath: {{ $root.Values.media.mountPath }} + {{- end }} + {{- if $app.sabnzbdHostWhitelist }} + - name: sabnzbd-host-whitelist + image: {{ $root.Values.initImage }} + command: + - sh + - -ec + - | + f={{ $app.configPath }}/sabnzbd.ini + hosts="{{ include "media.sabnzbdHosts" $root }}" + if [ ! -f "$f" ]; then + printf '[misc]\nhost_whitelist = %s\n' "$hosts" > "$f" + chown {{ $root.Values.common.puid }}:{{ $root.Values.common.pgid }} "$f" + echo "seeded $f" + elif ! grep -q "^host_whitelist = $hosts\$" "$f"; then + sed -i "s/^host_whitelist = .*/host_whitelist = $hosts/" "$f" + echo "updated host_whitelist in $f" + fi + volumeMounts: + - name: config + mountPath: {{ $app.configPath }} + {{- end }} + {{- end }} + containers: + - name: {{ $name }} + image: {{ $app.image }} + imagePullPolicy: IfNotPresent + {{- if $app.gpu }} + securityContext: + privileged: true + {{- end }} + ports: + - name: http + containerPort: {{ $app.port }} + protocol: TCP + env: + - name: TZ + value: {{ $root.Values.common.tz | quote }} + {{- if $linuxserver }} + - name: PUID + value: {{ $root.Values.common.puid | quote }} + - name: PGID + value: {{ $root.Values.common.pgid | quote }} + {{- end }} + {{- range $app.env }} + - name: {{ .name }} + value: {{ .value | quote }} + {{- end }} + readinessProbe: + tcpSocket: + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + livenessProbe: + tcpSocket: + port: http + initialDelaySeconds: 60 + periodSeconds: 30 + failureThreshold: 5 + volumeMounts: + {{- if $app.configPath }} + - name: config + mountPath: {{ $app.configPath }} + {{- end }} + {{- if $app.media }} + - name: media + mountPath: {{ $root.Values.media.mountPath }} + {{- end }} + {{- if $app.gpu }} + - name: dri + mountPath: /dev/dri + {{- end }} + {{- with $app.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- if or $app.configPath $app.media $app.gpu }} + volumes: + {{- if $app.configPath }} + - name: config + persistentVolumeClaim: + claimName: {{ $name }}-config + {{- end }} + {{- if $app.media }} + - name: media + hostPath: + path: {{ $root.Values.media.hostPath }} + type: DirectoryOrCreate + {{- end }} + {{- if $app.gpu }} + - name: dri + hostPath: + path: /dev/dri + type: Directory + {{- end }} + {{- end }} +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ $name }} + namespace: {{ $root.Values.namespace }} + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 4 }} +spec: + type: ClusterIP + selector: + app.kubernetes.io/name: {{ $name }} + ports: + - name: http + port: {{ $app.port }} + targetPort: http + protocol: TCP +--- +{{- if $app.ingress }} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ $name }} + namespace: {{ $root.Values.namespace }} + labels: + app.kubernetes.io/name: {{ $name }} + {{- include "media.labels" $root | nindent 4 }} + annotations: + cert-manager.io/cluster-issuer: {{ $root.Values.ingress.clusterIssuer }} + {{- with $root.Values.ingress.annotations }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with $app.ingressAnnotations }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ $root.Values.ingress.className }} + tls: + - hosts: + - {{ $name }}.{{ $root.Values.ingress.domain }} + secretName: {{ $name }}-tls + rules: + - host: {{ $name }}.{{ $root.Values.ingress.domain }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ $name }} + port: + name: http +--- +{{- end }} +{{- end }} +{{- end }} diff --git a/values.yaml b/values.yaml new file mode 100644 index 0000000..9157bd0 --- /dev/null +++ b/values.yaml @@ -0,0 +1,162 @@ +## Values for the media chart. +## +## Every entry under `apps:` renders a Deployment + Service, and optionally a config PVC +## and an Ingress. All apps that set `media: true` share one hostPath directory on the +## node, mounted at the same path in every pod, so Sonarr/Radarr can hardlink finished +## downloads into the library instead of copying them. + +namespace: media + +# Passed to all linuxserver.io images (they drop privileges to this UID/GID). +common: + puid: 1000 + pgid: 1000 + tz: Europe/Berlin + +media: + # Directory on the node (loki). Created on first start if missing. + hostPath: /srv/media + # Same path inside every pod - required for hardlinks and for path mapping between + # SABnzbd and Sonarr/Radarr to just work. + mountPath: /data + # Created (and chowned to puid:pgid) by an init container. Parents must be listed + # before children. Non-recursive: existing files are never touched. + dirs: + - usenet + - usenet/incomplete + - usenet/complete + - usenet/complete/tv + - usenet/complete/movies + - media + - media/tv + - media/movies + +ingress: + className: nginx + # Each app with `ingress: true` gets .. The DNS records point at the + # node's private IP, so the UIs are only reachable from the LAN / via VPN. + domain: smokyzone.de + # ingress-nginx is NodePort-only; used to build external URLs (e.g. Jellyfin). + httpsPort: 30444 + # DNS-01 works for hostnames that only resolve to a private IP. + clusterIssuer: letsencrypt-dns-cloudflare + annotations: + nginx.ingress.kubernetes.io/proxy-body-size: 100m + +# StorageClass for the per-app config PVCs, empty = cluster default. +storageClassName: "" + +initImage: busybox:1.36 + +apps: + jellyfin: + enabled: true + image: lscr.io/linuxserver/jellyfin:12.2ubu2604-ls52 + port: 8096 + configPath: /config + configSize: 20Gi + media: true + ingress: true + # Mounts /dev/dri for Intel QuickSync (UHD 630). Needs a privileged container, + # because the device cgroup blocks /dev/dri for unprivileged pods without a GPU + # device plugin. + gpu: true + ingressAnnotations: + nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + nginx.ingress.kubernetes.io/proxy-buffering: "off" + env: + - name: JELLYFIN_PublishedServerUrl + value: https://jellyfin.smokyzone.de:30444 + resources: + requests: {cpu: 250m, memory: 512Mi} + limits: {cpu: "4", memory: 4Gi} + + sonarr: + enabled: true + image: lscr.io/linuxserver/sonarr:4.0.20.3014-ls326 + port: 8989 + configPath: /config + configSize: 5Gi + media: true + ingress: true + resources: + requests: {cpu: 100m, memory: 256Mi} + limits: {cpu: "1", memory: 1Gi} + + radarr: + enabled: true + image: lscr.io/linuxserver/radarr:6.4.4.10685-ls319 + port: 7878 + configPath: /config + configSize: 5Gi + media: true + ingress: true + resources: + requests: {cpu: 100m, memory: 256Mi} + limits: {cpu: "1", memory: 1Gi} + + prowlarr: + enabled: true + image: lscr.io/linuxserver/prowlarr:2.6.5.5623-ls162 + port: 9696 + configPath: /config + configSize: 2Gi + ingress: true + resources: + requests: {cpu: 50m, memory: 128Mi} + limits: {cpu: 500m, memory: 512Mi} + + sabnzbd: + enabled: true + image: lscr.io/linuxserver/sabnzbd:5.1.3-ls275 + port: 8080 + configPath: /config + configSize: 2Gi + media: true + ingress: true + # SABnzbd rejects requests whose Host header is not whitelisted. Seed/repair + # host_whitelist so the ingress hostname and the in-cluster service names work. + sabnzbdHostWhitelist: true + resources: + requests: {cpu: 100m, memory: 256Mi} + # Unpacking/repair is CPU heavy. + limits: {cpu: "3", memory: 2Gi} + + bazarr: + enabled: true + image: lscr.io/linuxserver/bazarr:v1.6.2-ls366 + port: 6767 + configPath: /config + configSize: 2Gi + media: true + ingress: true + resources: + requests: {cpu: 50m, memory: 128Mi} + limits: {cpu: 500m, memory: 512Mi} + + seerr: + enabled: true + # Successor of Jellyseerr/Overseerr. + image: ghcr.io/seerr-team/seerr:v3.5.0 + port: 5055 + configPath: /app/config + configSize: 1Gi + ingress: true + linuxserver: false + resources: + requests: {cpu: 50m, memory: 192Mi} + limits: {cpu: 500m, memory: 768Mi} + + flaresolverr: + enabled: true + image: ghcr.io/flaresolverr/flaresolverr:v3.5.2 + port: 8191 + # Stateless, only used by Prowlarr in-cluster (http://flaresolverr:8191). + linuxserver: false + env: + - name: LOG_LEVEL + value: info + resources: + requests: {cpu: 50m, memory: 256Mi} + limits: {cpu: "1", memory: 1Gi}