apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: plex
    app.kubernetes.io/version: 1.24.3
  name: plex
  namespace: multimedia
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app.kubernetes.io/name: plex
  serviceName: plex
  template:
    metadata:
      labels:
        app.kubernetes.io/name: plex
        app.kubernetes.io/version: 1.24.3
    spec:
      containers:
      - env:
        - name: TZ
          value: Europe/Berlin
        - name: PUID
          value: "1000"
        - name: PGID
          value: "1000"
        - name: ALLOWED_NETWORKS
          value: 192.168.2.0/24,10.42.0.0/16
        - name: ADVERTISE_IP
          value: http://192.168.2.98:32400/
        - name: NVIDIA_DRIVER_CAPABILITIES
          value: all
        envFrom:
        - secretRef:
            name: plex-claim
        image: plexinc/pms-docker:1.24.3.5033-757abe6b4
        name: plex
        ports:
        - containerPort: 32400
          name: plex
        readinessProbe:
          httpGet:
            path: /identity
            port: 32400
          initialDelaySeconds: 15
          timeoutSeconds: 5
        resources:
          limits:
            nvidia.com/gpu: 1
          requests:
            cpu: 2
            memory: 2500Mi
        volumeMounts:
        - mountPath: /config
          name: plex-db
        - mountPath: /transcode
          name: transcode
        - mountPath: /backup
          name: backups
        - mountPath: /data/movies
          name: movies
        - mountPath: /data/tv
          name: tv
      hostname: nas
      nodeSelector:
        kubernetes.io/arch: amd64
        storage.infra/main: "true"
      restartPolicy: Always
      tolerations: []
      volumes:
      - name: movies
        persistentVolumeClaim:
          claimName: movies
      - name: tv
        persistentVolumeClaim:
          claimName: tv
      - name: plex-db
        persistentVolumeClaim:
          claimName: plex-db
      - name: backups
        persistentVolumeClaim:
          claimName: plex-backups
      - emptyDir: {}
        name: transcode
