apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: radarr
  name: radarr
  namespace: multimedia
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: radarr
  serviceName: radarr
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: radarr
      labels:
        app.kubernetes.io/name: radarr
    spec:
      containers:
      - env:
        - name: PUID
          value: "1000"
        - name: PGID
          value: "1000"
        - name: TZ
          value: Europe/Berlin
        image: ghcr.io/linuxserver/radarr:develop
        imagePullPolicy: Always
        name: radarr
        ports:
        - containerPort: 7878
          name: http-radarr
        readinessProbe:
          failureThreshold: 5
          tcpSocket:
            port: http-radarr
          timeoutSeconds: 10
        resources:
          requests:
            cpu: 40m
            memory: 635Mi
        volumeMounts:
        - mountPath: /config
          name: config
        - mountPath: /movies
          name: data
        - mountPath: /download/completed
          name: downloads
        - mountPath: /backup
          name: backup
      - args:
        - exportarr
        - radarr
        env:
        - name: CONFIG
          value: /radarr/config.xml
        - name: URL
          value: http://localhost
        - name: PORT
          value: "9708"
        image: ghcr.io/onedr0p/exportarr:v0.6.1
        imagePullPolicy: IfNotPresent
        name: exportarr
        ports:
        - containerPort: 9708
          name: metrics
        readinessProbe:
          failureThreshold: 5
          httpGet:
            path: /healthz
            port: metrics
          periodSeconds: 10
        resources:
          limits:
            cpu: 50m
            memory: 100Mi
          requests:
            cpu: 1m
            memory: 11Mi
        volumeMounts:
        - mountPath: /radarr
          name: config
          readOnly: true
      initContainers:
      - args:
        - -c
        - cd /config && unzip $(find /backup/scheduled -type f -exec stat -c '%n'
          {} + | sort -r | head -n1)
        command:
        - /bin/sh
        image: quay.io/paulfantom/rsync
        name: restore
        volumeMounts:
        - mountPath: /config
          name: config
        - mountPath: /backup
          name: backup
          readOnly: true
      nodeSelector:
        kubernetes.io/arch: amd64
        storage.infra/main: "true"
      restartPolicy: Always
      tolerations: []
      volumes:
      - emptyDir: {}
        name: config
      - name: data
        persistentVolumeClaim:
          claimName: movies
      - name: downloads
        persistentVolumeClaim:
          claimName: torrents
      - name: backup
        persistentVolumeClaim:
          claimName: radarr-backup
