diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml index 01f24b9..24aa4ca 100644 --- a/.github/workflows/lint-test.yaml +++ b/.github/workflows/lint-test.yaml @@ -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 diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index b11dfc6..047c3c7 100644 --- a/charts/common/Chart.yaml +++ b/charts/common/Chart.yaml @@ -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 diff --git a/charts/common/templates/_all.tpl b/charts/common/templates/_all.tpl index e844bfb..08630a3 100644 --- a/charts/common/templates/_all.tpl +++ b/charts/common/templates/_all.tpl @@ -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 -}} diff --git a/charts/common/templates/_prometheusrule.tpl b/charts/common/templates/_prometheusrule.tpl new file mode 100644 index 0000000..628c833 --- /dev/null +++ b/charts/common/templates/_prometheusrule.tpl @@ -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 }} diff --git a/charts/common/templates/_servicemonitor.tpl b/charts/common/templates/_servicemonitor.tpl new file mode 100644 index 0000000..2c45197 --- /dev/null +++ b/charts/common/templates/_servicemonitor.tpl @@ -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 }} diff --git a/charts/common/values.yaml b/charts/common/values.yaml index 2dd7cd0..a96e4af 100644 --- a/charts/common/values.yaml +++ b/charts/common/values.yaml @@ -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: