From 630dfc767ac4359fa91ef5e200c446a6538dcf22 Mon Sep 17 00:00:00 2001 From: Mattia Eleuteri Date: Tue, 10 Mar 2026 16:56:50 +0100 Subject: [PATCH] [tenant] Allow egress to virt-handler for VM metrics scraping - Add CiliumClusterwideNetworkPolicy for vmagent egress to virt-handler - Restrict endpointSelector to vmagent pods only via app.kubernetes.io/name label Signed-off-by: Mattia Eleuteri Signed-off-by: mattia-eleuteri --- .../apps/tenant/templates/networkpolicy.yaml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/apps/tenant/templates/networkpolicy.yaml b/packages/apps/tenant/templates/networkpolicy.yaml index d9f87856d..ce3e33ab9 100644 --- a/packages/apps/tenant/templates/networkpolicy.yaml +++ b/packages/apps/tenant/templates/networkpolicy.yaml @@ -207,6 +207,27 @@ spec: - toEndpoints: - matchLabels: "k8s:io.kubernetes.pod.namespace": cozy-kubevirt-cdi +{{- if .Values.monitoring }} +--- +apiVersion: cilium.io/v2 +kind: CiliumClusterwideNetworkPolicy +metadata: + name: {{ include "tenant.name" . }}-egress-virt-handler +spec: + endpointSelector: + matchLabels: + "k8s:io.kubernetes.pod.namespace": "{{ include "tenant.name" . }}" + "k8s:app.kubernetes.io/name": "vmagent" + egress: + - toEndpoints: + - matchLabels: + "k8s:kubevirt.io": "virt-handler" + "k8s:io.kubernetes.pod.namespace": "cozy-kubevirt" + toPorts: + - ports: + - port: "8443" + protocol: TCP +{{- end }} --- apiVersion: cilium.io/v2 kind: CiliumNetworkPolicy