From ebbbde208110b527f3d41416bfee9005e58eeb88 Mon Sep 17 00:00:00 2001 From: Pascal Reeb Date: Sun, 17 Sep 2023 17:45:09 +0200 Subject: [PATCH 1/6] feat(readarr): init --- charts/readarr/Chart.yaml | 24 ++++ charts/readarr/README.md | 53 +++++++++ charts/readarr/ci/ct-exportarr-values.yaml | 26 +++++ charts/readarr/templates/common.yaml | 50 ++++++++ charts/readarr/templates/prometheusrules.yaml | 39 +++++++ charts/readarr/templates/servicemonitor.yaml | 26 +++++ charts/readarr/values.yaml | 109 ++++++++++++++++++ 7 files changed, 327 insertions(+) create mode 100644 charts/readarr/Chart.yaml create mode 100644 charts/readarr/README.md create mode 100644 charts/readarr/ci/ct-exportarr-values.yaml create mode 100644 charts/readarr/templates/common.yaml create mode 100644 charts/readarr/templates/prometheusrules.yaml create mode 100644 charts/readarr/templates/servicemonitor.yaml create mode 100644 charts/readarr/values.yaml diff --git a/charts/readarr/Chart.yaml b/charts/readarr/Chart.yaml new file mode 100644 index 00000000..ad920742 --- /dev/null +++ b/charts/readarr/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: readarr +description: Book Manager and Automation (Sonarr for Ebooks) +type: application +version: 1.0.0 +# renovate: image=ghcr.io/onedr0p/readarr-develop +appVersion: "0.3.5.2217" +keywords: + - readarr + - servarr + - torrent + - usenet +home: https://github.com/pree/helm-charts/tree/master/charts/readarr +icon: https://raw.githubusercontent.com/Readarr/Readarr/develop/Logo/512.png +sources: + - https://github.com/Readarr/Readarr + - https://github.com/onedr0p/containers +maintainers: + - name: pree + email: pascal@reeb.io +dependencies: + - name: common + repository: https://bjw-s.github.io/helm-charts/ + version: 1.5.1 diff --git a/charts/readarr/README.md b/charts/readarr/README.md new file mode 100644 index 00000000..bbc57ebb --- /dev/null +++ b/charts/readarr/README.md @@ -0,0 +1,53 @@ +# readarr + +![Version: 1.0.0](https://img.shields.io/badge/Version-1.0.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 0.3.5.2217](https://img.shields.io/badge/AppVersion-0.3.5.2217-informational?style=flat-square) + +Book Manager and Automation (Sonarr for Ebooks) + +**Homepage:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| pree | | | + +## Source Code + +* +* + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| https://bjw-s.github.io/helm-charts/ | common | 1.5.1 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| env | object | See below | environment variables. | +| env.TZ | string | `"UTC"` | Set the container timezone | +| image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| image.repository | string | `"ghcr.io/onedr0p/readarr"` | image repository | +| image.tag | string | `nil` | | +| ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | +| metrics.enabled | bool | See values.yaml | Enable and configure Exportarr sidecar and Prometheus serviceMonitor. | +| metrics.exporter.env.additionalMetrics | bool | `false` | Set to true to enable gathering of additional metrics (slow) | +| metrics.exporter.env.port | int | `9794` | metrics port | +| metrics.exporter.env.unknownQueueItems | bool | `false` | Set to true to enable gathering unknown queue items | +| metrics.exporter.image.pullPolicy | string | `"IfNotPresent"` | image pull policy | +| metrics.exporter.image.repository | string | `"ghcr.io/onedr0p/exportarr"` | image repository | +| metrics.exporter.image.tag | string | `"v1.5.3"` | image tag | +| metrics.prometheusRule | object | See values.yaml | Enable and configure Prometheus Rules for the chart under this key. | +| metrics.prometheusRule.rules | list | See prometheusrules.yaml | Configure additionial rules for the chart under this key. | +| metrics.serviceMonitor.interval | string | `"3m"` | | +| metrics.serviceMonitor.labels | object | `{}` | | +| metrics.serviceMonitor.scrapeTimeout | string | `"1m"` | | +| persistence | object | See values.yaml | Configure persistence settings for the chart under this key. # Config persistence is required for the Prometheus exporter sidecar. | +| probes | object | See values.yaml | Configures the probes for the main Pod. | +| service | object | See values.yaml | Configures service settings for the chart. | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.11.0](https://github.com/norwoodj/helm-docs/releases/v1.11.0) diff --git a/charts/readarr/ci/ct-exportarr-values.yaml b/charts/readarr/ci/ct-exportarr-values.yaml new file mode 100644 index 00000000..d1a4f800 --- /dev/null +++ b/charts/readarr/ci/ct-exportarr-values.yaml @@ -0,0 +1,26 @@ +# Test exportarr +persistence: + config: + enabled: true + type: emptyDir + +additionalContainers: + exportarr: + name: exportarr + image: ghcr.io/onedr0p/exportarr:v1.0.0 + imagePullPolicy: IfNotPresent + args: ["readarr"] + env: + - name: PORT + value: "32123" + - name: URL + value: "http://localhost" + - name: CONFIG + value: "/config/config.xml" + ports: + - name: exportarr + containerPort: 32123 + volumeMounts: + - name: config + mountPath: /config + readOnly: true diff --git a/charts/readarr/templates/common.yaml b/charts/readarr/templates/common.yaml new file mode 100644 index 00000000..f7e6a41e --- /dev/null +++ b/charts/readarr/templates/common.yaml @@ -0,0 +1,50 @@ +{{/* Make sure all variables are set properly */}} +{{- include "bjw-s.common.loader.init" . }} + +{{/* Append the hardcoded settings */}} +{{- define "readarr.harcodedValues" -}} +{{ if .Values.metrics.enabled }} +additionalContainers: + exporter: + name: exporter + image: "{{ .Values.metrics.exporter.image.repository }}:{{ .Values.metrics.exporter.image.tag }}" + imagePullPolicy: {{ .Values.metrics.exporter.image.pullPolicy }} + args: ["readarr"] + env: + - name: URL + value: "http://localhost" + - name: CONFIG + value: "/config/config.xml" + - name: PORT + value: "{{ .Values.metrics.exporter.env.port }}" + - name: ENABLE_ADDITIONAL_METRICS + value: "{{ .Values.metrics.exporter.env.additionalMetrics }}" + - name: ENABLE_UNKNOWN_QUEUE_ITEMS + value: "{{ .Values.metrics.exporter.env.unknownQueueItems }}" + ports: + - name: metrics + containerPort: {{ .Values.metrics.exporter.env.port }} + volumeMounts: + {{ if .Values.persistence.config.enabled }} + - name: config + mountPath: /config + readOnly: true + {{ if .Values.persistence.config.subPath }} + subPath: {{ .Values.persistence.config.subPath }} + {{ end }} + {{ end }} + +service: + metrics: + enabled: true + ports: + metrics: + enabled: true + protocol: TCP + port: {{ .Values.metrics.exporter.env.port }} +{{ end }} +{{- end -}} +{{- $_ := mergeOverwrite .Values (include "readarr.harcodedValues" . | fromYaml) -}} + +{{/* Render the templates */}} +{{ include "bjw-s.common.loader.generate" . }} diff --git a/charts/readarr/templates/prometheusrules.yaml b/charts/readarr/templates/prometheusrules.yaml new file mode 100644 index 00000000..61012d78 --- /dev/null +++ b/charts/readarr/templates/prometheusrules.yaml @@ -0,0 +1,39 @@ +{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }} +{{- include "bjw-s.common.loader.init" . -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: PrometheusRule +metadata: + name: {{ include "bjw-s.common.lib.chart.names.fullname" . }} + labels: + {{- include "bjw-s.common.lib.controller.metadata.labels" . | nindent 4 }} + {{- with .Values.metrics.prometheusRule.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + groups: + - name: {{ include "bjw-s.common.lib.chart.names.fullname" . }} + rules: + - alert: ExportarrAbsent + annotations: + description: Readarr Exportarr has disappeared from Prometheus + service discovery. + summary: Exportarr is down. + expr: | + absent(up{job=~".*{{ include "bjw-s.common.lib.chart.names.fullname" . }}.*"} == 1) + for: 5m + labels: + severity: critical + - alert: ReadarrDown + annotations: + description: Readarr service is down. + summary: Readarr is down. + expr: | + readarr_system_status{job=~".*{{ include "bjw-s.common.lib.chart.names.fullname" . }}.*"} == 0 + for: 5m + labels: + severity: critical + {{- with .Values.metrics.prometheusRule.rules }} + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} diff --git a/charts/readarr/templates/servicemonitor.yaml b/charts/readarr/templates/servicemonitor.yaml new file mode 100644 index 00000000..d3b1ad64 --- /dev/null +++ b/charts/readarr/templates/servicemonitor.yaml @@ -0,0 +1,26 @@ +{{- if .Values.metrics.enabled }} +{{- include "bjw-s.common.loader.init" . -}} +--- +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "bjw-s.common.lib.chart.names.fullname" . }} + labels: + {{- include "bjw-s.common.lib.controller.metadata.labels" . | nindent 4 }} + {{- with .Values.metrics.serviceMonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "bjw-s.common.lib.metadata.selectorLabels" . | nindent 6 }} + endpoints: + - port: metrics + {{- with .Values.metrics.serviceMonitor.interval }} + interval: {{ . }} + {{- end }} + {{- with .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ . }} + {{- end }} + path: /metrics +{{- end }} diff --git a/charts/readarr/values.yaml b/charts/readarr/values.yaml new file mode 100644 index 00000000..51db11b2 --- /dev/null +++ b/charts/readarr/values.yaml @@ -0,0 +1,109 @@ +# +# IMPORTANT NOTE +# +# This chart inherits from bjw-s's common library chart. You can check the default values/options here: +# https://github.com/bjw-s/helm-charts/tree/main/charts/library/common/values.yaml +# + +image: + # -- image repository + repository: ghcr.io/onedr0p/readarr + # @default -- chart.appVersion + tag: + # -- image pull policy + pullPolicy: IfNotPresent + +# -- environment variables. +# @default -- See below +env: + # -- Set the container timezone + TZ: UTC + +# -- Configures service settings for the chart. +# @default -- See values.yaml +service: + main: + ports: + http: + port: 8787 + +ingress: + # -- Enable and configure ingress settings for the chart under this key. + # @default -- See values.yaml + main: + enabled: false + +# -- Configures the probes for the main Pod. +# @default -- See values.yaml +probes: + liveness: + enabled: true + ## Set this to true if you wish to specify your own livenessProbe + custom: true + ## The spec field contains the values for the default livenessProbe. + ## If you selected custom: true, this field holds the definition of the livenessProbe. + spec: + exec: + command: + - /usr/bin/env + - bash + - -c + - curl --fail localhost:8787/api/v3/system/status?apiKey=`IFS=\> && while + read -d \< E C; do if [[ $E = "ApiKey" ]]; then echo $C; fi; done < /config/config.xml` + failureThreshold: 5 + initialDelaySeconds: 60 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 10 + +# -- Configure persistence settings for the chart under this key. +## Config persistence is required for the Prometheus exporter sidecar. +# @default -- See values.yaml +persistence: + config: + enabled: false + + media: + enabled: false + mountPath: /media + +metrics: + # -- Enable and configure Exportarr sidecar and Prometheus serviceMonitor. + # @default -- See values.yaml + enabled: false + serviceMonitor: + interval: 3m + scrapeTimeout: 1m + labels: {} + # -- Enable and configure Prometheus Rules for the chart under this key. + # @default -- See values.yaml + prometheusRule: + enabled: false + labels: {} + # -- Configure additionial rules for the chart under this key. + # @default -- See prometheusrules.yaml + rules: [] + # - alert: ReadarrDown + # annotations: + # description: Readarr service is down. + # summary: Readarr is down. + # expr: | + # readarr_system_status == 0 + # for: 5m + # labels: + # severity: critical + exporter: + image: + # -- image repository + repository: ghcr.io/onedr0p/exportarr + # -- image tag + tag: v1.5.3 + # -- image pull policy + pullPolicy: IfNotPresent + env: + # -- metrics port + port: 9794 + # -- Set to true to enable gathering of additional metrics (slow) + additionalMetrics: false + # -- Set to true to enable gathering unknown queue items + unknownQueueItems: false From e68e6aa9b743ee6e580ffab99639bcdfdf810f40 Mon Sep 17 00:00:00 2001 From: Pascal Reeb Date: Sun, 17 Sep 2023 17:52:54 +0200 Subject: [PATCH 2/6] fix(readarr): fix image repository --- charts/readarr/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/readarr/values.yaml b/charts/readarr/values.yaml index 51db11b2..67ea56ed 100644 --- a/charts/readarr/values.yaml +++ b/charts/readarr/values.yaml @@ -7,7 +7,7 @@ image: # -- image repository - repository: ghcr.io/onedr0p/readarr + repository: ghcr.io/onedr0p/readarr-develop # @default -- chart.appVersion tag: # -- image pull policy From 6f16b74e45a2fe65036a5e33be75027e0ebb424c Mon Sep 17 00:00:00 2001 From: Pascal Reeb Date: Sun, 17 Sep 2023 17:54:11 +0200 Subject: [PATCH 3/6] fix(readarr): helm-docs --- charts/readarr/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/readarr/README.md b/charts/readarr/README.md index bbc57ebb..ef34664d 100644 --- a/charts/readarr/README.md +++ b/charts/readarr/README.md @@ -30,7 +30,7 @@ Book Manager and Automation (Sonarr for Ebooks) | env | object | See below | environment variables. | | env.TZ | string | `"UTC"` | Set the container timezone | | image.pullPolicy | string | `"IfNotPresent"` | image pull policy | -| image.repository | string | `"ghcr.io/onedr0p/readarr"` | image repository | +| image.repository | string | `"ghcr.io/onedr0p/readarr-develop"` | image repository | | image.tag | string | `nil` | | | ingress.main | object | See values.yaml | Enable and configure ingress settings for the chart under this key. | | metrics.enabled | bool | See values.yaml | Enable and configure Exportarr sidecar and Prometheus serviceMonitor. | From 70a943cb1619fcc0913f302be9ce8d171c57f839 Mon Sep 17 00:00:00 2001 From: Pascal Reeb Date: Sun, 17 Sep 2023 18:07:14 +0200 Subject: [PATCH 4/6] fix(readarr): current apiVersion is v1 --- charts/readarr/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/readarr/values.yaml b/charts/readarr/values.yaml index 67ea56ed..9e7758bb 100644 --- a/charts/readarr/values.yaml +++ b/charts/readarr/values.yaml @@ -48,7 +48,7 @@ probes: - /usr/bin/env - bash - -c - - curl --fail localhost:8787/api/v3/system/status?apiKey=`IFS=\> && while + - curl --fail localhost:8787/api/v1/system/status?apiKey=`IFS=\> && while read -d \< E C; do if [[ $E = "ApiKey" ]]; then echo $C; fi; done < /config/config.xml` failureThreshold: 5 initialDelaySeconds: 60 From 133e40e85ff788519d946ea6261ccaf2adc82eac Mon Sep 17 00:00:00 2001 From: Pascal Reeb Date: Sun, 17 Sep 2023 18:26:07 +0200 Subject: [PATCH 5/6] fix(readarr): use metrics values instead of additionalContainers --- charts/readarr/ci/ct-exportarr-values.yaml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/charts/readarr/ci/ct-exportarr-values.yaml b/charts/readarr/ci/ct-exportarr-values.yaml index d1a4f800..eaeebcc7 100644 --- a/charts/readarr/ci/ct-exportarr-values.yaml +++ b/charts/readarr/ci/ct-exportarr-values.yaml @@ -4,23 +4,5 @@ persistence: enabled: true type: emptyDir -additionalContainers: - exportarr: - name: exportarr - image: ghcr.io/onedr0p/exportarr:v1.0.0 - imagePullPolicy: IfNotPresent - args: ["readarr"] - env: - - name: PORT - value: "32123" - - name: URL - value: "http://localhost" - - name: CONFIG - value: "/config/config.xml" - ports: - - name: exportarr - containerPort: 32123 - volumeMounts: - - name: config - mountPath: /config - readOnly: true +metrics: + enabled: true From c7c2326cf5734320c3cd6e0b672a560d05d91629 Mon Sep 17 00:00:00 2001 From: Pascal Reeb Date: Sun, 17 Sep 2023 18:52:34 +0200 Subject: [PATCH 6/6] feat(github-actions): install prom crds --- .github/workflows/test.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ac25ddd4..feaef5e7 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -24,6 +24,7 @@ jobs: helm repo add adfinis https://charts.adfinis.com helm repo add bjw-s https://bjw-s.github.io/helm-charts/ helm repo add bitnami https://charts.bitnami.com/bitnami + helm repo add prometheus-community https://prometheus-community.github.io/helm-charts - uses: actions/setup-python@v4 with: @@ -48,5 +49,8 @@ jobs: uses: helm/kind-action@v1.8.0 if: steps.list-changed.outputs.changed == 'true' + - name: Install Prometheus CRDs + run: helm install prom-crds prometheus-community/prometheus-operator-crds + - name: Run chart-testing (install) run: ct install