Skip to content

Commit f06dd2c

Browse files
committed
Enhancement: Add nad metric
Signed-off-by: avlitman <[email protected]>
1 parent f4c3247 commit f06dd2c

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# VEP: Adding NetworkAttachmentDefinitions Metric
2+
3+
## Release Signoff Checklist
4+
Items marked with (R) are required *prior to targeting to a milestone / release*.
5+
6+
- [X] (R) Enhancement issue created, which links to VEP dir in [kubevirt/enhancements] (not the initial VEP PR)
7+
8+
## Overview
9+
10+
Introduce a new Prometheus metric to expose information about the NetworkAttachmentDefinitions (NADs) used by VirtualMachines.
11+
This will help identify and monitor the external networks VMs are connected to.
12+
13+
## Motivation
14+
15+
NADs provide crucial configuration for VM networking. Knowing which external network each VM connects to and its properties
16+
(e.g., CNI type, VLAN, topology) is critical for debugging, auditing, and optimization.
17+
This metric fills a visibility gap in VM-network associations.
18+
19+
## Goals
20+
21+
- Add a metric named kubevirt_network_attachment_definition_info.
22+
- Expose NAD properties relevant to VM connectivity as Prometheus labels.
23+
- Support multiple CNI types including OVN, SR-IOV, bridge, and macvlan.
24+
25+
## Non Goals
26+
27+
- This metric does not expose pod-level or container-level network information.
28+
- It will not validate or mutate NADs.
29+
- Does not track live usage or connections per VM instance.
30+
31+
## Definition of Users
32+
- Cluster administrators
33+
- CNV developers
34+
- SREs needing visibility into VM network configuration
35+
36+
## User Stories
37+
38+
- As a cluster admin, I want to monitor what networks VMs are connected to.
39+
- As a CNV engineer, I want to audit CNI types used across clusters.
40+
- As an SRE, I want to correlate network config issues to VM disruptions.
41+
42+
## Repos
43+
44+
kubevirt/kubevirt.
45+
46+
## Design
47+
48+
Metric name: kubevirt_network_attachment_definition_info
49+
Type: GaugeVec
50+
Help: Details about additional network interfaces attached to Virtual Machines.
51+
52+
Labels:
53+
54+
| Label | Values | Notes |
55+
| ------------------------------------ | ---------------------------------------------- |---------------------------------------|
56+
| `namespace` | string | From VM metadata.namespace |
57+
| `network` | string | From nad.metadata.name |
58+
| `vlan` | 0-4095 or `<none>` | From nad.config.vlan |
59+
| `cni_type` | e.g., `bridge`, `sriov`, `ovn-k8s-cni-overlay` | From config.type |
60+
| `ipam_type` | string or `<none>` | From config.ipam.type |
61+
| `ovn_subnets` | comma-separated CIDRs or `<none>` | From config.subnets |
62+
| `udn_role` | `primary`/`secondary`/`<none>` | From config.role |
63+
| `ovn_topology` | `layer2`/`layer3`/`localnet` | From config.topology |
64+
| `ovn_persistent_ips` | `true`/`false`/`<none>` | From config.allowPersistentIPs |
65+
| `mac_spoof_filtering` | `true`/`false`/`off`/`<none>` | From config.macspoofchk/spoofchk |
66+
| `bridge_preserving_default_vlan` | `true`/`false`/`<none>` | From config.preserveDefaultVlan |
67+
| `bridge_disable_container_interface` | `true`/`false`/`<none>` | From config.disableContainerInterface |
68+
69+
Data is extracted from nad.Spec.Config or nad.Spec.Config -> “plugins”. The implementation parses both formats.
70+
71+
## API Example
72+
Example metric output:
73+
74+
kubevirt_network_attachment_definition_info{
75+
namespace="demo",
76+
network="l2-primary",
77+
cni_type="ovn-k8s-cni-overlay",
78+
udn_role="primary",
79+
ovn_topology="layer2",
80+
ovn_subnets="10.0.0.0/16,2001:db8::/60",
81+
ipam_type="<none>",
82+
vlan="<none>",
83+
ovn_persistent_ips="<none>",
84+
mac_spoof_filtering="<none>",
85+
bridge_preserving_default_vlan="<none>",
86+
bridge_disable_container_interface="<none>"
87+
}
88+
89+
## Alternatives
90+
91+
Integrate this metric into multus-admission-controller instead of KubeVirt. This was discarded as it complicates ownership and deployment.
92+
93+
## Scalability
94+
95+
Metric cardinality is limited by the number of NADs, not per VM, making it scalable.
96+
97+
## Update/Rollback Compatibility
98+
99+
Safe to add. No existing APIs or metrics are changed.
100+
101+
## Testing Approach
102+
103+
- Unit tests will mock NAD inputs with various Spec.Config structures.
104+
- e2e testing will deploy VMs with different network configs and validate exported metrics.
105+
106+
## Implementation Phases
107+
108+
1. Implement NAD parsing and metric registration in virt-controller.
109+
2. Add unit tests.
110+
3. Add e2e tests using example NADs.
111+
112+
113+
## Feature lifecycle Phases
114+
115+
### GA (v1.7.0)
116+
- Documented in official CNV and OpenShift documentation.
117+
- Covered by end-to-end test suites.
118+
119+

0 commit comments

Comments
 (0)