apiVersion: apps/v1 kind: Deployment metadata: name: jellyfin-server namespace: services spec: replicas: 1 # Recreate so the old pod fully terminates before the new one starts — # avoids NFS-lock races on the hostPath-backed PVC during rolling updates. strategy: type: Recreate selector: matchLabels: app: jellyfin-server template: metadata: labels: app: jellyfin-server spec: initContainers: - name: nfs-check-config image: busybox:stable command: - sh - -c - | test -f /mnt/.nfs-sentinel || ( echo "ERROR: NFS sentinel missing at /mnt/.nfs-sentinel" echo "refusing to start; node likely has NFS unmounted" echo "pod would otherwise bind-mount the local-XFS shadow" exit 1 ) volumeMounts: - name: jellyfin-config mountPath: /mnt readOnly: true # Self-heal the setup-wizard flag. Runs only after nfs-check-config has # proven /config is the real NFS directory (not a local-XFS shadow), so # we never rewrite config on the wrong volume. If the DB already exists # (server was set up) but IsStartupWizardCompleted flipped to false # (e.g. an interrupted wizard run or partial config restore), restore it # to true so a working instance never drops back into the setup wizard. # A genuine fresh install has no jellyfin.db yet, so its first-run wizard # is left untouched. - name: ensure-wizard-completed image: busybox:stable command: - sh - -c - | cfg=/config/config/system.xml if [ -f /config/data/jellyfin.db ] && \ grep -q "false" "$cfg" 2>/dev/null; then echo "existing jellyfin.db present but setup-wizard flag was false; restoring to true" sed -i 's#false#true#' "$cfg" else echo "no action: fresh install (no jellyfin.db) or wizard flag already true" fi volumeMounts: - name: jellyfin-config mountPath: /config - name: nfs-check-libraries image: busybox:stable command: - sh - -c - | test -f /mnt/.nfs-sentinel || ( echo "ERROR: NFS sentinel missing at /mnt/.nfs-sentinel" echo "refusing to start; node likely has NFS unmounted" echo "pod would otherwise bind-mount the local-XFS shadow" exit 1 ) volumeMounts: - name: jellyfin-libraries mountPath: /mnt readOnly: true - name: nfs-check-data image: busybox:stable command: - sh - -c - | test -f /mnt/.nfs-sentinel || ( echo "ERROR: NFS sentinel missing at /mnt/.nfs-sentinel" echo "refusing to start; node likely has NFS unmounted" echo "pod would otherwise bind-mount the local-XFS shadow" exit 1 ) volumeMounts: - name: jellyfin-data mountPath: /mnt readOnly: true containers: - name: jellyfin image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" ports: - containerPort: 8096 name: http resources: requests: cpu: 500m memory: 512Mi limits: cpu: 4000m memory: 4Gi livenessProbe: exec: command: ["test", "-f", "/config/.nfs-sentinel"] initialDelaySeconds: 60 periodSeconds: 30 failureThreshold: 3 timeoutSeconds: 5 volumeMounts: - name: jellyfin-config mountPath: /config - name: jellyfin-libraries mountPath: /media/libraries - name: jellyfin-data mountPath: /data volumes: - name: jellyfin-config persistentVolumeClaim: claimName: jellyfin-config-pvc - name: jellyfin-libraries persistentVolumeClaim: claimName: jellyfin-libraries-pvc - name: jellyfin-data persistentVolumeClaim: claimName: jellyfin-data-pvc --- apiVersion: v1 kind: Service metadata: labels: app: jellyfin-server name: jellyfin-server namespace: services spec: type: NodePort ports: - name: http port: 8096 protocol: TCP targetPort: 8096 nodePort: 30096 - name: https port: 8920 protocol: TCP targetPort: 8096 nodePort: 30920 selector: app: jellyfin-server