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 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..ef34664d --- /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-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. | +| 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..eaeebcc7 --- /dev/null +++ b/charts/readarr/ci/ct-exportarr-values.yaml @@ -0,0 +1,8 @@ +# Test exportarr +persistence: + config: + enabled: true + type: emptyDir + +metrics: + enabled: 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..9e7758bb --- /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-develop + # @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/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 + 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