Skip to content

Commit 3aabf91

Browse files
authored
Merge pull request #91883 from sjhala-ccs/cnv-52859
CNV-52859: Configuring VM interface link state
2 parents 467a51a + f31eb0b commit 3aabf91

File tree

3 files changed

+111
-0
lines changed

3 files changed

+111
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4775,6 +4775,8 @@ Topics:
47754775
File: virt-connecting-vm-to-ovn-secondary-network
47764776
- Name: Hot plugging secondary network interfaces
47774777
File: virt-hot-plugging-network-interfaces
4778+
- Name: Setting VM interface link state
4779+
File: virt-setting-interface-link-state
47784780
- Name: Connecting a VM to a service mesh
47794781
File: virt-connecting-vm-to-service-mesh
47804782
- Name: Configuring a dedicated network for live migration
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/vm_networking/virt-setting-interface-link-state.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="virt-configuring-interface-link-state_{context}"]
7+
= Setting the VM interface link state by using the CLI
8+
9+
You can set the link state of a primary or secondary virtual machine (VM) network interface by using the CLI.
10+
11+
.Prerequisites
12+
* You have installed the OpenShift CLI (`oc`).
13+
14+
15+
.Procedure
16+
. Edit the VM configuration to set the interface link state, as in the following example:
17+
+
18+
[source,yaml]
19+
----
20+
apiVersion: kubevirt.io/v1
21+
kind: VirtualMachine
22+
metadata:
23+
name: my-vm
24+
spec:
25+
template:
26+
spec:
27+
domain:
28+
devices:
29+
interfaces:
30+
- name: default # <1>
31+
state: down # <2>
32+
masquerade: { }
33+
networks:
34+
- name: default
35+
pod: { }
36+
# ...
37+
----
38+
<1> The name of the interface.
39+
<2> The state of the interface. The possible values are:
40+
+
41+
* `up`: Represents an active network connection. This is the default if no value is specified.
42+
* `down`: Represents a network interface link that is switched off.
43+
* `absent`: Represents a network interface that is hot unplugged.
44+
+
45+
[IMPORTANT]
46+
====
47+
If you have defined readiness or liveness probes to run VM health checks, setting the primary interface's link state to `down` causes the probes to fail. If a liveness probe fails, the VM is deleted and a new VM is created to restore responsiveness.
48+
====
49+
50+
. Apply the `VirtualMachine` manifest:
51+
+
52+
[source,terminal]
53+
----
54+
$ oc apply -f <filename>.yaml
55+
----
56+
57+
.Verification
58+
* Verify that the desired link state is set by checking the `status.interfaces.linkState` field of the `VirtualMachineInstance` manifest.
59+
+
60+
[source,terminal]
61+
----
62+
$ oc get vmi <vmi-name>
63+
----
64+
+
65+
.Example output
66+
[source,yaml]
67+
----
68+
apiVersion: kubevirt.io/v1
69+
kind: VirtualMachineInstance
70+
metadata:
71+
name: my-vm
72+
spec:
73+
domain:
74+
devices:
75+
interfaces:
76+
- name: default
77+
state: down
78+
masquerade: { }
79+
networks:
80+
- name: default
81+
pod: { }
82+
status:
83+
interfaces:
84+
- name: default
85+
linkState: down
86+
# ...
87+
----
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
[id="virt-setting-interface-link-state"]
3+
= Managing the link state of a virtual machine interface
4+
include::_attributes/common-attributes.adoc[]
5+
:context: virt-setting-interface-link-state
6+
7+
toc::[]
8+
9+
You can manage the link state of a primary or secondary virtual machine (VM) interface by using the CLI. By specifying the link state, you can logically connect or disconnect the virtual network interface controller (vNIC) from a network.
10+
11+
[NOTE]
12+
====
13+
{VirtProductName} does not support link state management for Single Root I/O Virtualization (SR-IOV) secondary network interfaces and their link states are not reported.
14+
====
15+
16+
You can specify the desired link state when you first create a VM, by editing the configuration of an existing VM that is stopped or running, or when you hot plug a new network interface to a running VM. If you edit a running VM, you do not need to restart or migrate the VM for the changes to be applied. The current link state of a VM interface is reported in the `status.interfaces.linkState` field of the `VirtualMachineInstance` manifest.
17+
18+
:FeatureName: Setting the VM interface link state
19+
include::snippets/technology-preview.adoc[]
20+
21+
include::modules/virt-configuring-interface-link-state.adoc[leveloffset=+1]
22+

0 commit comments

Comments
 (0)