apiVersion: apps/v1
kind: Deployment
metadata:
  name: shelfmark
  labels:
    app.kubernetes.io/controller: main
    app.kubernetes.io/instance: shelfmark
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: shelfmark
    helm.sh/chart: shelfmark-5.0.1
  namespace: shelfmark
spec:
  revisionHistoryLimit: 3
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app.kubernetes.io/controller: main
      app.kubernetes.io/name: shelfmark
      app.kubernetes.io/instance: shelfmark
  template:
    metadata:
      labels:
        app.kubernetes.io/controller: main
        app.kubernetes.io/instance: shelfmark
        app.kubernetes.io/name: shelfmark
    spec:
      enableServiceLinks: false
      serviceAccountName: shelfmark
      automountServiceAccountToken: false
      securityContext:
        fsGroup: 1000
        fsGroupChangePolicy: OnRootMismatch
      hostIPC: false
      hostNetwork: false
      hostPID: false
      dnsPolicy: ClusterFirst
      containers:
        - env:
            - name: FLASK_PORT
              value: "8084"
            - name: DOCKERMODE
              value: "true"
            - name: CALIBRE_WEB_URL
              value: https://grimmory.alexlebens.net
            - name: AUDIOBOOK_LIBRARY_URL
              value: https://audiobookshelf.alexlebens.net
            - name: SEARCH_MODE
              value: universal
            - name: METADATA_PROVIDER
              value: openlibrary
            - name: METADATA_PROVIDER_AUDIOBOOK
              value: openlibrary
            - name: BOOKS_OUTPUT_MODE
              value: booklore
            - name: BOOKLORE_HOST
              value: http://grimmory.grimmory:80
            - name: BOOKLORE_USERNAME
              valueFrom:
                secretKeyRef:
                  key: grimmory-user
                  name: shelfmark-grimmory-config
            - name: BOOKLORE_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: grimmory-password
                  name: shelfmark-grimmory-config
            - name: BOOKLORE_DESTINATION
              value: library
            - name: BOOKLORE_LIBRARY_ID
              value: "4"
            - name: BOOKLORE_PATH_ID
              value: "4"
            - name: DESTINATION_AUDIOBOOK
              value: /audiobooks
            - name: FILE_ORGANIZATION_AUDIOBOOK
              value: organize
            - name: TEMPLATE_AUDIOBOOK_ORGANIZE
              value: '{Author}/{Title}'
            - name: HARDLINK_TORRENTS_AUDIOBOOK
              value: "true"
            - name: CUSTOM_DNS
              value: cloudflare
            - name: USE_DOH
              value: "true"
            - name: PROWLARR_ENABLED
              value: "true"
            - name: PROWLARR_URL
              value: http://prowlarr.prowlarr:80
            - name: PROWLARR_API_KEY
              valueFrom:
                secretKeyRef:
                  key: prowlarr-key
                  name: shelfmark-prowlarr-config
            - name: ABB_ENABLED
              value: "true"
            - name: ABB_HOSTNAME
              value: audiobookbay.lu
            - name: PROWLARR_TORRENT_CLIENT
              value: qbittorrent
            - name: QBITTORRENT_URL
              value: http://qbittorrent.qbittorrent:8080
            - name: QBITTORRENT_CATEGORY
              value: shelfmark-books
            - name: QBITTORRENT_CATEGORY_AUDIOBOOK
              value: shelfmark-audiobooks
            - name: OPENLIBRARY_ENABLED
              value: "true"
            - name: USE_CF_BYPASS
              value: "true"
          image: ghcr.io/calibrain/shelfmark:v1.3.0@sha256:e891eda444b261da48a839db652034bce4e20ac09c167f14adf939dedf96b572
          livenessProbe:
            failureThreshold: 5
            httpGet:
              path: /api/health
              port: 8084
            initialDelaySeconds: 30
            periodSeconds: 30
            successThreshold: 1
            timeoutSeconds: 5
          name: main
          resources:
            requests:
              cpu: 10m
              memory: 140Mi
          volumeMounts:
            - mountPath: /audiobooks
              name: audiobooks
            - mountPath: /config
              name: config
            - mountPath: /mnt/store/Torrent
              name: downloads
            - mountPath: /ingest
              name: ingest
      volumes:
        - name: audiobooks
          persistentVolumeClaim:
            claimName: shelfmark-audiobooks-nfs-storage
        - name: config
          persistentVolumeClaim:
            claimName: shelfmark
        - name: downloads
          persistentVolumeClaim:
            claimName: shelfmark-downloads-nfs-storage
        - name: ingest
          persistentVolumeClaim:
            claimName: shelfmark-import-nfs-storage
