---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sabnzbd
  namespace: media
  labels:
    app: sabnzbd
  annotations:
    reloader.stakater.com/auto: "true"
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sabnzbd
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: sabnzbd
    spec:
      containers:
        - name: sabnzbd
          image: lscr.io/linuxserver/sabnzbd:3.4.2-ls51
          env:
            - name: TZ
              value: Europe/Zurich
            - name: PGID
              value: "2000"
            - name: PUID
              value: "2000"
            - name: DOCKER_MODS
              value: containeroo/docker-mods:sabnzbd-nzbnotify|containeroo/docker-mods:sabnzbd-mkvtoolnix
          ports:
            - name: http
              containerPort: 8080
          startupProbe:
            exec:
              command:
                - bash
                - -c
                - /app/sabnzbd/startup
            initialDelaySeconds: 30
            failureThreshold: 30
            timeoutSeconds: 10
            periodSeconds: 3
          livenessProbe:
            tcpSocket:
              port: http
            failureThreshold: 2
            timeoutSeconds: 5
            periodSeconds: 30
          volumeMounts:
            - name: data
              mountPath: /config
            - name: incomplete-downloads
              mountPath: /incomplete-downloads
            - name: downloads
              mountPath: /downloads
            - name: tv
              mountPath: /tv
            - name: merge-subtitles
              mountPath: /app/sabnzbd/scripts/merge_subtitles.sh
              subPath: merge_subtitles.sh
            - name: startup
              mountPath: /app/sabnzbd/startup
              subPath: startup
      restartPolicy: Always
      automountServiceAccountToken: false
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: sabnzbd-data
        - name: incomplete-downloads
          hostPath:
            path: /mnt/sabnzbd/incomplete
            type: Directory
        - name: downloads
          hostPath:
            path: /mnt/sabnzbd/complete
            type: Directory
        - name: tv
          hostPath:
            path: /mnt/sabnzbd/tv
            type: Directory
        - name: merge-subtitles
          configMap:
            name: merge-subtitles
            defaultMode: 0755
        - name: startup
          configMap:
            name: sabnzbd-startup
            defaultMode: 0755
