apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: qbit-manage
  namespace: download
spec:
  interval: 5m
  chart:
    spec:
      chart: app-template
      version: 1.3.x
      sourceRef:
        kind: HelmRepository
        name: bjws-charts
        namespace: flux-system

  values:
    initContainers:
      # this init container copies the read only config from the configmap volume, into
      # an emptydir volume mount that the pod can write to.
      copy-config:
        image: alpine:3.19
        command:
        - /bin/sh
        - -c
        - "ls /tmp/config-ro
          && cp -r /tmp/config-ro/. /tmp/config/
          && chmod 777 /tmp/config/config.yml
          && ls /tmp/config"
        volumeMounts:
        - name: config-ro
          mountPath: /tmp/config-ro
        - name: config
          mountPath: /tmp/config

    image:
      repository: bobokun/qbit_manage
      tag: "v4.1.1"

    env:
      QBT_STARTUP_DELAY: 45 # seconds
      QBT_SCHEDULE: 720 # 720min = 12hr

    service:
      main:
        enabled: false

    persistence:
      storage:
        enabled: true
        type: hostPath
        hostPath: /mnt/MainPool/Media/Torrents
        mountPath: /storage/Torrents

      config:
        enabled: true
        type: emptyDir
        defaultMode: 777
        mountPath: /config

      config-ro:
        enabled: true
        type: custom
        mountPath: /config-ro
        volumeSpec:
          configMap:
            name: qbit-manage
            items:
            - key: "config.yml"
              path: "config.yml"

    podSecurityContext:
      runAsNonRoot: true
      runAsUser: 10000
      runAsGroup: 10000
      fsGroup: 10000
      fsGroupChangePolicy: OnRootMismatch