apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: htpc
    run: sonarr
  name: sonarr
  namespace: media
spec:
  replicas: 1
  selector:
    matchLabels:
      app: htpc
      run: sonarr
  template:
    metadata:
      labels:
        app: htpc
        run: sonarr
    spec:
      containers:
      - env:
        - name: TZ
          value: Africa/Johannesburg
        - name: PUID
          value: "1000"
        - name: PGID
          value: "1000"
        image: linuxserver/sonarr:latest
        livenessProbe:
          exec:
            command:
            - /bin/sh
            - -c
            - curl "http://localhost:8989/sonarr/api/health?ApiKey=$(sed -ne '/ApiKey/{s/.*<ApiKey>\(.*\)<\/ApiKey>.*/\1/p;q;}'
              </config/config.xml)"
          initialDelaySeconds: 30
          periodSeconds: 10
        name: sonarr
        ports:
        - containerPort: 8989
          name: webui
        readinessProbe:
          exec:
            command:
            - /bin/sh
            - -c
            - curl "http://localhost:8989/sonarr/api/system/status?ApiKey=$(sed -ne
              '/ApiKey/{s/.*<ApiKey>\(.*\)<\/ApiKey>.*/\1/p;q;}' </config/config.xml)"
          initialDelaySeconds: 30
          periodSeconds: 10
        volumeMounts:
        - mountPath: /config
          name: nfs
          subPath: sonarr
        - mountPath: /tv
          name: nfs
          subPath: media/tv
        - mountPath: /downloads
          name: nfs
          subPath: downloads
      securityContext:
        fsGroup: 1000
      volumes:
      - persistentVolumeClaim:
          claimName: nfs
        name: nfs
