Add PrometheusRule and ServiceMonitor to common (#47)

* Add PrometheusRule and ServiceMonitor to common

* Bump Kind version
This commit is contained in:
2023-03-05 08:29:38 +00:00
committed by GitHub
parent 067d636a28
commit 855c04e7f3
6 changed files with 80 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ jobs:
- name: Create k3d cluster
uses: nolar/setup-k3d-k3s@v1
with:
version: v1.19
version: v1.23
if: steps.list-changed.outputs.changed == 'true'
- name: Remove node taints

View File

@@ -2,7 +2,7 @@ apiVersion: v2
name: common
description: Common chart library, based off KaH's common
type: library
version: 4.5.2
version: 4.5.3
kubeVersion: ">=1.16.0-0"
keywords:
- common

View File

@@ -55,4 +55,12 @@ Main entrypoint for the common library chart. It will render all underlying temp
{{- if .Values.secret -}}
{{ include "common.secret" . | nindent 0 }}
{{- end -}}
{{- if .Values.metrics.enabled -}}
{{ include "common.serviceMonitor" . | nindent 0 }}
{{- end -}}
{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled -}}
{{ include "common.prometheusRule" . | nindent 0 }}
{{- end -}}
{{- end -}}

View File

@@ -0,0 +1,19 @@
{{- define "common.prometheusRule" }}
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.metrics.prometheusRule.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
groups:
- name: {{ include "common.names.fullname" . }}
rules:
{{- with .Values.metrics.prometheusRule.rules }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,25 @@
{{- define "common.serviceMonitor" }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- include "common.labels" . | nindent 4 }}
{{- with .Values.metrics.serviceMonitor.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
{{- include "common.labels.selectorLabels" . | nindent 6 }}
endpoints:
- port: metrics
{{- with .Values.metrics.serviceMonitor.interval }}
interval: {{ . }}
{{- end }}
{{- with .Values.metrics.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ . }}
{{- end }}
path: /metrics
{{- end }}

View File

@@ -472,6 +472,32 @@ resources: {}
# cpu: 100m
# memory: 128Mi
metrics:
# -- Enable metrics collections with 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: SonarrDown
# annotations:
# description: Sonarr service is down.
# summary: Sonarr is down.
# expr: |
# sonarr_system_status == 0
# for: 5m
# labels:
# severity: critical
# -- The common chart supports several add-ons. These can be configured under this key.
# @default -- See below
addons: