---
# yaml-language-server: $schema=https://raw.githubusercontent.com/bjw-s/helm-charts/main/charts/other/app-template/schemas/helmrelease-helm-v2beta2.schema.json
apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: radarr
spec:
  interval: 30m
  chart:
    spec:
      chart: app-template
      version: 3.0.4
      sourceRef:
        kind: HelmRepository
        name: bjw-s
        namespace: flux-system
  install:
    remediation:
      retries: 3
  upgrade:
    cleanupOnFail: true
    remediation:
      retries: 3
      strategy: rollback
  dependsOn:
    - name: rook-ceph-cluster
      namespace: rook-ceph
  values:
    controllers:
      radarr:
        annotations:
          reloader.stakater.com/auto: "true"
        containers:
          app:
            image:
              repository: ghcr.io/onedr0p/radarr
              tag: 5.3.6.8612@sha256:431f4d8da415645cd18359d0b704d4191f400eb57137ed3e5749774f3915c0a8
            env:
              # Ref: https://github.com/Radarr/Radarr/issues/7030#issuecomment-1039689518
              # Ref: https://github.com/dotnet/runtime/issues/9336
              COMPlus_EnableDiagnostics: "0"
              PUSHOVER_DEBUG: "false"
              RADARR__AUTHENTICATION_METHOD: External
              RADARR__AUTHENTICATION_REQUIRED: DisabledForLocalAddresses
              RADARR__INSTANCE_NAME: Radarr
              RADARR__PORT: &port 80
              RADARR__LOG_LEVEL: info
              RADARR__THEME: dark
              RADARR__POSTGRES_HOST:
                valueFrom:
                  secretKeyRef:
                    name: "${APP}-pguser-${DB_USER}"
                    key: host
              RADARR__POSTGRES_PORT: "5432"
              RADARR__POSTGRES_USER:
                valueFrom:
                  secretKeyRef:
                    name: "${APP}-pguser-${DB_USER}"
                    key: user
              RADARR__POSTGRES_PASSWORD:
                valueFrom:
                  secretKeyRef:
                    name: "${APP}-pguser-${DB_USER}"
                    key: password
              RADARR__POSTGRES_MAIN_DB: radarr_main
              RADARR__POSTGRES_LOG_DB: radarr_logs
              TZ: America/Chicago
            envFrom:
              - secretRef:
                  name: radarr-secret
            probes:
              liveness: &probes
                enabled: true
                custom: true
                spec:
                  httpGet:
                    path: /ping
                    port: *port
                  initialDelaySeconds: 0
                  periodSeconds: 10
                  timeoutSeconds: 1
                  failureThreshold: 3
              readiness: *probes
              startup:
                enabled: false
            securityContext:
              allowPrivilegeEscalation: false
              readOnlyRootFilesystem: true
              capabilities: { drop: ["ALL"] }
            resources:
              requests:
                cpu: 10m
              limits:
                memory: 4Gi
        pod:
          securityContext:
            runAsUser: 568
            runAsGroup: 568
            runAsNonRoot: true
            fsGroup: 568
            fsGroupChangePolicy: OnRootMismatch
            supplementalGroups: [10000]
    service:
      app:
        controller: radarr
        ports:
          http:
            port: *port
    ingress:
      app:
        enabled: true
        className: internal-nginx
        hosts:
          - host: &host "{{ .Release.Name }}.jahanson.tech"
            paths:
              - path: /
                service:
                  identifier: app
                  port: http
        tls:
          - hosts:
              - *host
    persistence:
      config:
        enabled: true
        existingClaim: radarr
      pushover-notify:
        type: configMap
        name: radarr-configmap
        defaultMode: 0775
        globalMounts:
          - path: /scripts/pushover-notify.sh
            subPath: pushover-notify.sh
            readOnly: true
      tmp:
        type: emptyDir
      media:
        type: nfs
        server: 10.1.1.11
        path: /volume1/Media
        globalMounts:
          - path: /data/nas-media
      sting-media:
        type: nfs
        server: 10.1.1.12
        path: /mnt/user/Media/
        globalMounts:
          - path: /data/sting-media