From 37d354b76be041774c8cff227b982f7c65dcc9d1 Mon Sep 17 00:00:00 2001 From: Victor Login Date: Tue, 25 Jun 2024 01:22:00 +0200 Subject: [PATCH] feat: add service monitor Signed-off-by: Victor Login --- charts/zot/Chart.yaml | 2 +- charts/zot/templates/servicemonitor.yaml | 32 ++++++++++++++++++++++++ charts/zot/values.yaml | 15 +++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 charts/zot/templates/servicemonitor.yaml diff --git a/charts/zot/Chart.yaml b/charts/zot/Chart.yaml index 007b588..20a7464 100644 --- a/charts/zot/Chart.yaml +++ b/charts/zot/Chart.yaml @@ -3,4 +3,4 @@ appVersion: v2.1.0-rc2 description: A Helm chart for Kubernetes name: zot type: application -version: 0.1.56 +version: 0.1.57 diff --git a/charts/zot/templates/servicemonitor.yaml b/charts/zot/templates/servicemonitor.yaml new file mode 100644 index 0000000..46e3046 --- /dev/null +++ b/charts/zot/templates/servicemonitor.yaml @@ -0,0 +1,32 @@ +{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "zot.fullname" . }} + labels: + app.kubernetes.io/component: metrics +spec: + {{- if .Values.metrics.serviceMonitor.jobLabel }} + jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel }} + {{- end }} + selector: + matchLabels: + {{- include "zot.selectorLabels" . | nindent 6 }} + endpoints: + - port: zot + {{- if .Values.metrics.serviceMonitor.interval }} + interval: {{ .Values.metrics.serviceMonitor.interval }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scrapeTimeout }} + scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.path }} + path: {{ .Values.metrics.serviceMonitor.path }} + {{- end }} + {{- if .Values.metrics.serviceMonitor.scheme }} + scheme: {{ .Values.metrics.serviceMonitor.scheme }} + {{- end }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} +{{- end }} diff --git a/charts/zot/values.yaml b/charts/zot/values.yaml index 876f8b2..bbe33b7 100644 --- a/charts/zot/values.yaml +++ b/charts/zot/values.yaml @@ -179,3 +179,18 @@ strategy: # maxUnavailable: 25% podAnnotations: {} + +# Metrics configuration +# NOTE: need enable metric extension in config.json +metrics: + # Start a prometheus exporter + enabled: false + + # Prometheus Operator ServiceMonitor configuration + serviceMonitor: + # Start a ServiceMonitor for Prometheus Operator + enabled: false + # Specify the interval at which metrics should be scraped + interval: "30s" + # Specify the path to scrape metrics from + path: "/metrics"