From 9443055a2502e64ff6a0acffb8b9d6e629a10953 Mon Sep 17 00:00:00 2001 From: "Mosher, Jaymes (jm616v)" Date: Tue, 30 Sep 2025 16:41:24 -0600 Subject: [PATCH] [libvirt] Add support for configuring hook scripts Allow configuring hook scripts for libvirt, that are called by the daemon on various events. https: //www.libvirt.org/hooks.html Change-Id: I7cf06741dfdc8e9b97179d45975bd97b460855a9 Signed-off-by: Mosher, Jaymes (jm616v) --- libvirt/templates/configmap-bin.yaml | 6 ++++++ libvirt/templates/daemonset-libvirt.yaml | 8 ++++++++ libvirt/values.yaml | 11 +++++++++++ releasenotes/notes/libvirt-5bf3185fc00a9938.yaml | 5 +++++ 4 files changed, 30 insertions(+) create mode 100644 releasenotes/notes/libvirt-5bf3185fc00a9938.yaml diff --git a/libvirt/templates/configmap-bin.yaml b/libvirt/templates/configmap-bin.yaml index 22e99db50c..b37691cb47 100644 --- a/libvirt/templates/configmap-bin.yaml +++ b/libvirt/templates/configmap-bin.yaml @@ -40,6 +40,12 @@ data: {{- end }} {{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.init_modules.script "key" "libvirt-init-modules.sh") | indent 2 }} {{- include "helm-toolkit.snippets.values_template_renderer" (dict "envAll" $envAll "template" .Values.conf.dynamic_options.script "key" "init-dynamic-options.sh") | indent 2 }} +{{- if .Values.conf.hooks.enabled }} +{{- range $k, $v := .Values.conf.hooks.scripts }} + {{ $k }}: | +{{ tpl $v . | indent 4 }} +{{- end }} +{{- end }} {{- end }} {{- end }} {{- if .Values.manifests.configmap_bin }} diff --git a/libvirt/templates/daemonset-libvirt.yaml b/libvirt/templates/daemonset-libvirt.yaml index 00599f6563..99fd70585d 100644 --- a/libvirt/templates/daemonset-libvirt.yaml +++ b/libvirt/templates/daemonset-libvirt.yaml @@ -301,6 +301,14 @@ spec: subPath: key readOnly: true {{- end }} + {{- if .Values.conf.hooks.enabled }} + {{- range $k, $v := .Values.conf.hooks.scripts }} + - name: libvirt-bin + mountPath: /etc/libvirt/hooks/{{ $k }} + subPath: {{ $k }} + readOnly: true + {{- end }} + {{- end }} {{ if $mounts_libvirt.volumeMounts }}{{ toYaml $mounts_libvirt.volumeMounts | indent 12 }}{{ end }} {{- if .Values.pod.sidecars.libvirt_exporter.enabled }} - name: libvirt-exporter diff --git a/libvirt/values.yaml b/libvirt/values.yaml index ef36d25880..35e97c1333 100644 --- a/libvirt/values.yaml +++ b/libvirt/values.yaml @@ -246,6 +246,17 @@ conf: kubectl -n ${POD_NAMESPACE} get secret ${POD_NAME}-${TYPE} -o jsonpath='{.data.tls\.crt}' | base64 -d > /tmp/${TYPE}.crt kubectl -n ${POD_NAMESPACE} get secret ${POD_NAME}-${TYPE} -o jsonpath='{.data.tls\.key}' | base64 -d > /tmp/${TYPE}.key kubectl -n ${POD_NAMESPACE} get secret ${POD_NAME}-${TYPE} -o jsonpath='{.data.ca\.crt}' | base64 -d > /tmp/${TYPE}-ca.crt + hooks: + # Libvirt hook scripts, that are placed in /etc/libvirt/hooks + enabled: false + scripts: + # daemon: + # qemu: + # lxc: + # libxl: + # bhyve: + # network: + pod: probes: libvirt: diff --git a/releasenotes/notes/libvirt-5bf3185fc00a9938.yaml b/releasenotes/notes/libvirt-5bf3185fc00a9938.yaml new file mode 100644 index 0000000000..d2d7230926 --- /dev/null +++ b/releasenotes/notes/libvirt-5bf3185fc00a9938.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added ability to configure libvirt hooks. +...