From 9f380d96352ce37e0f62729d31344ff46f44b753 Mon Sep 17 00:00:00 2001 From: Nat Allan Date: Mon, 4 Apr 2022 15:40:23 +1000 Subject: [PATCH] Add trash-updator - #258 --- .../flux/orchestration/organizarrs.yaml | 19 ++++- .../organizarrs/trash-updater/cronjob.yaml | 85 +++++++++++++++++++ .../trash-updater/kustomization.yaml | 15 ++++ .../trash-updater/secret.sops.yaml | 9 ++ .../organizarrs/trash-updater/trash.yaml | 50 +++++++++++ 5 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 k8s/manifests/organizarrs/trash-updater/cronjob.yaml create mode 100644 k8s/manifests/organizarrs/trash-updater/kustomization.yaml create mode 100644 k8s/manifests/organizarrs/trash-updater/secret.sops.yaml create mode 100644 k8s/manifests/organizarrs/trash-updater/trash.yaml diff --git a/k8s/clusters/hegira/flux/orchestration/organizarrs.yaml b/k8s/clusters/hegira/flux/orchestration/organizarrs.yaml index f678002e5e..f451b4e47e 100644 --- a/k8s/clusters/hegira/flux/orchestration/organizarrs.yaml +++ b/k8s/clusters/hegira/flux/orchestration/organizarrs.yaml @@ -165,7 +165,6 @@ spec: sourceRef: kind: GitRepository name: home-cluster - --- apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 kind: Kustomization @@ -184,3 +183,21 @@ spec: sourceRef: kind: GitRepository name: home-cluster +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1beta2 +kind: Kustomization +metadata: + name: organizarrs-trash-updater + namespace: flux-system +spec: + dependsOn: + - name: organizarrs-namespace + - name: organizarrs-sonarr + - name: organizarrs-radarr + interval: 5m + path: "./k8s/manifests/organizarrs/trash-updater" + prune: true + wait: true + sourceRef: + kind: GitRepository + name: home-cluster diff --git a/k8s/manifests/organizarrs/trash-updater/cronjob.yaml b/k8s/manifests/organizarrs/trash-updater/cronjob.yaml new file mode 100644 index 0000000000..d6c73d6b0b --- /dev/null +++ b/k8s/manifests/organizarrs/trash-updater/cronjob.yaml @@ -0,0 +1,85 @@ +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: trash-updater + namespace: organizarrs + labels: + app: trash-updater +spec: + schedule: "0 3 * * *" + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + spec: + automountServiceAccountToken: false + + initContainers: + - name: render-config + image: ghcr.io/k8s-at-home/trash-updater:v1.8.2 + env: + - name: RADARR_API_KEY + valueFrom: + secretKeyRef: + name: trash-updater-secrets + key: radarrApiKey + - name: SONARR_API_KEY + valueFrom: + secretKeyRef: + name: trash-updater-secrets + key: sonarrApiKey + command: + - "/bin/bash" + - -c + args: + - "envsubst < /config/trash.yaml > /shared/trash.yaml" + volumeMounts: + - name: config + mountPath: /config + - name: shared + mountPath: /shared + + containers: + - name: trash-updater-sonarr + image: ghcr.io/k8s-at-home/trash-updater:v1.8.2 + imagePullPolicy: IfNotPresent + env: + - name: TZ + value: "${TIMEZONE}" + command: + - /app/trash + args: + - sonarr + - --config + - /config/trash.yaml + volumeMounts: + - name: shared + mountPath: /config + readOnly: true + + - name: trash-updater-radarr + image: ghcr.io/k8s-at-home/trash-updater:v1.8.2 + imagePullPolicy: IfNotPresent + env: + - name: TZ + value: "${TIMEZONE}" + command: + - /app/trash + args: + - radarr + - --config + - /config/trash.yaml + volumeMounts: + - name: shared + mountPath: /config + readOnly: true + + restartPolicy: OnFailure + + volumes: + - name: config + configMap: + name: trash-updater-config + - name: shared + emptyDir: {} diff --git a/k8s/manifests/organizarrs/trash-updater/kustomization.yaml b/k8s/manifests/organizarrs/trash-updater/kustomization.yaml new file mode 100644 index 0000000000..1223b2de4a --- /dev/null +++ b/k8s/manifests/organizarrs/trash-updater/kustomization.yaml @@ -0,0 +1,15 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: downloads +resources: + - secret.sops.yaml + - cronjob.yaml +configMapGenerator: + - name: trash-updater-config + files: + - trash.yaml +generatorOptions: + disableNameSuffixHash: true + annotations: + kustomize.toolkit.fluxcd.io/substitute: disabled diff --git a/k8s/manifests/organizarrs/trash-updater/secret.sops.yaml b/k8s/manifests/organizarrs/trash-updater/secret.sops.yaml new file mode 100644 index 0000000000..74c3513c00 --- /dev/null +++ b/k8s/manifests/organizarrs/trash-updater/secret.sops.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: trash-updater-secrets + namespace: organizarrs +stringData: + radarrApiKey: 81b871ddf3d24beb9d832eec2f951727 + sonarrApiKey: 55a99987569d40448bd9e1f47614b4c1 diff --git a/k8s/manifests/organizarrs/trash-updater/trash.yaml b/k8s/manifests/organizarrs/trash-updater/trash.yaml new file mode 100644 index 0000000000..8a6f36fa06 --- /dev/null +++ b/k8s/manifests/organizarrs/trash-updater/trash.yaml @@ -0,0 +1,50 @@ +# For more details on the configuration, see the Configuration Reference on the wiki here: +# https://github.com/rcdailey/trash-updater/wiki/Configuration-Reference + +# Configuration specific to Sonarr +sonarr: + - base_url: http://sonarr.organizarrs:8989 + api_key: ${SONARR_API_KEY} + + quality_definition: series + + release_profiles: + - type: series + +# Configuration specific to Radarr. +radarr: + - base_url: http://radarr.organizarrs:7878 + api_key: ${RADARR_API_KEY} + + quality_definition: + type: movie + + delete_old_custom_formats: true + + custom_formats: + - names: + - 3D + - 5.1 Surround + - BR-DISK + - DV + - EVO (no WEBDL) + - HDR + - HDR (undefined) + - HQ-Remux + - HQ-WEBDL + - LQ + - No-RlsGroup + - Repack/Proper + - Special Edition + - Theatrical Cut + - x265 (720/1080p) + quality_profiles: + - name: HD-1080p + + - names: + - Multi + quality_profiles: + - name: HD-1080p + score: -10000 + - name: Ultra-HD + score: -10000