---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: jellyfin
  labels:
    app.kubernetes.io/name: jellyfin
    app.kubernetes.io/component: jellyfin
spec:
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/name: jellyfin
      app.kubernetes.io/component: jellyfin
  template:
    metadata:
      labels:
        app.kubernetes.io/name: jellyfin
        app.kubernetes.io/component: jellyfin
    spec:
      containers:
      - env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: spec.nodeName
        - name: POD_NAME
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.name
        - name: POD_NAMESPACE
          valueFrom:
            fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
        image: docker.io/jellyfin/jellyfin:10.8.12
        imagePullPolicy: IfNotPresent
        name: jellyfin
        readinessProbe:
          httpGet:
            path: /health
            port: 8096
        ports:
        - containerPort: 8096
          protocol: TCP
        volumeMounts:
        - mountPath: /data/media/shows
          name: shows
        - mountPath: /data/media/movies
          name: movies
        - mountPath: /data/media
          name: media
          readOnly: False
        - mountPath: /config
          name: jellyfin-config
        - mountPath: /cache
          name: jellyfin-cache
        resources:
          requests:
            amd.com/gpu: 1
            memory: 2Gi
            cpu: 100m
          limits:
            amd.com/gpu: 1
            memory: 3.5Gi
            cpu: "4"
      restartPolicy: Always
      volumes:
      - name: movies
        persistentVolumeClaim:
          claimName: jellyfin-movies
      - name: shows
        persistentVolumeClaim:
          claimName: jellyfin-shows
      - name: media
        persistentVolumeClaim:
          claimName: media
      - name: jellyfin-config
        persistentVolumeClaim:
          claimName: jellyfin-config
      - name: jellyfin-cache
        emptyDir:
          sizeLimit: 500Mi
