[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) <jm616v@att.com>
This commit is contained in:
Mosher, Jaymes (jm616v)
2025-09-30 16:41:24 -06:00
committed by Jaymes Mosher
parent eaff9dd646
commit 9443055a25
4 changed files with 30 additions and 0 deletions

View File

@@ -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 }}

View File

@@ -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

View File

@@ -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:

View File

@@ -0,0 +1,5 @@
---
features:
- |
Added ability to configure libvirt hooks.
...