From 53a2ee99a062a39414965101476ef68159441608 Mon Sep 17 00:00:00 2001 From: Saeed Padari Date: Thu, 14 Aug 2025 01:19:10 +0330 Subject: [PATCH] charts/libvirt: add Prometheus libvirt exporter support - Introduce ghcr.io/inovex/prometheus-libvirt-exporter image for libvirt metrics - Compatible with Kolla-Ansible deployments for consistent monitoring Change-Id: I6516693c989bfaac4d67d86e6b0b6144335eb2b7 Signed-off-by: Saeed Padari --- .../notes/libvirt-339936ca478fbf50.yaml | 7 +++++++ libvirt/templates/daemonset-libvirt.yaml | 12 ++++++++++-- libvirt/templates/pod-monitor.yaml | 18 ++++++++++++++++++ libvirt/values.yaml | 6 +++++- values_overrides/libvirt/inovex_exporter.yaml | 13 +++++++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 libvirt/releasenotes/notes/libvirt-339936ca478fbf50.yaml create mode 100644 libvirt/templates/pod-monitor.yaml create mode 100644 values_overrides/libvirt/inovex_exporter.yaml diff --git a/libvirt/releasenotes/notes/libvirt-339936ca478fbf50.yaml b/libvirt/releasenotes/notes/libvirt-339936ca478fbf50.yaml new file mode 100644 index 0000000000..e8d902dcf8 --- /dev/null +++ b/libvirt/releasenotes/notes/libvirt-339936ca478fbf50.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Make exporter container args configurable in values to make it possible to use + ghcr.io/inovex/prometheus-libvirt-exporter image which assumes + having no additional args. +... diff --git a/libvirt/templates/daemonset-libvirt.yaml b/libvirt/templates/daemonset-libvirt.yaml index 48c16b04c0..cdd3d53f22 100644 --- a/libvirt/templates/daemonset-libvirt.yaml +++ b/libvirt/templates/daemonset-libvirt.yaml @@ -295,13 +295,19 @@ spec: readOnly: true {{- end }} {{ if $mounts_libvirt.volumeMounts }}{{ toYaml $mounts_libvirt.volumeMounts | indent 12 }}{{ end }} - {{- if .Values.pod.sidecars.libvirt_exporter }} + {{- if .Values.pod.sidecars.libvirt_exporter.enabled }} - name: libvirt-exporter {{ tuple $envAll "libvirt_exporter" | include "helm-toolkit.snippets.image" | indent 10 }} {{ tuple $envAll $envAll.Values.pod.resources.libvirt_exporter | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} {{ dict "envAll" $envAll "application" "libvirt" "container" "libvirt_exporter" | include "helm-toolkit.snippets.kubernetes_container_security_context" | indent 10 }} + {{- with .Values.pod.sidecars.libvirt_exporter }} + {{- if and (hasKey . "args") (gt (len .args) 0) }} args: - - "--libvirt.nova" + {{- range .args }} + - {{ . | quote }} + {{- end }} + {{- end }} + {{- end }} ports: - name: metrics protocol: TCP @@ -310,10 +316,12 @@ spec: httpGet: path: / port: metrics + timeoutSeconds: 5 readinessProbe: httpGet: path: / port: metrics + timeoutSeconds: 5 volumeMounts: - name: run mountPath: /run diff --git a/libvirt/templates/pod-monitor.yaml b/libvirt/templates/pod-monitor.yaml new file mode 100644 index 0000000000..2d0b7bc722 --- /dev/null +++ b/libvirt/templates/pod-monitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.manifests.podmonitor -}} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: libvirt-exporter +spec: + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + podMetricsEndpoints: + - interval: 10s + path: /metrics + port: metrics + scheme: http + selector: + matchLabels: + app.kubernetes.io/name: libvirt-exporter +{{- end -}} diff --git a/libvirt/values.yaml b/libvirt/values.yaml index a38fb68849..4900048856 100644 --- a/libvirt/values.yaml +++ b/libvirt/values.yaml @@ -291,7 +291,10 @@ pod: drop: - ALL sidecars: - libvirt_exporter: false + libvirt_exporter: + enabled: false + args: + - "--libvirt.nova" affinity: anti: @@ -403,6 +406,7 @@ manifests: network_policy: false role_cert_manager: false secret_registry: true + podmonitor: false secrets: oci_image_registry: diff --git a/values_overrides/libvirt/inovex_exporter.yaml b/values_overrides/libvirt/inovex_exporter.yaml new file mode 100644 index 0000000000..88a85a9f19 --- /dev/null +++ b/values_overrides/libvirt/inovex_exporter.yaml @@ -0,0 +1,13 @@ +--- +# NOTE: Use the inovex exporter image by default since 2026.1 release. +images: + tags: + libvirt_exporter: ghcr.io/inovex/prometheus-libvirt-exporter:2.2.0 +pod: + sidecars: + libvirt_exporter: + enabled: true + args: [] +manifests: + podmonitor: true +...