1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/virt-configuring-interface-link-state.adoc
2025-11-18 16:29:25 +01:00

90 lines
2.1 KiB
Plaintext

// Module included in the following assemblies:
//
// * virt/vm_networking/virt-setting-interface-link-state.adoc
:_mod-docs-content-type: PROCEDURE
[id="virt-configuring-interface-link-state_{context}"]
= Setting the VM interface link state by using the CLI
[role="_abstract"]
You can set the link state of a primary or secondary virtual machine (VM) network interface by using the CLI.
.Prerequisites
* You have installed the OpenShift CLI (`oc`).
.Procedure
. Edit the VM configuration to set the interface link state, as in the following example:
+
[source,yaml]
----
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: my-vm
spec:
template:
spec:
domain:
devices:
interfaces:
- name: default # <1>
state: down # <2>
masquerade: { }
networks:
- name: default
pod: { }
# ...
----
<1> The name of the interface.
<2> The state of the interface. The possible values are:
+
* `up`: Represents an active network connection. This is the default if no value is specified.
* `down`: Represents a network interface link that is switched off.
* `absent`: Represents a network interface that is hot unplugged.
+
[IMPORTANT]
====
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.
====
. Apply the `VirtualMachine` manifest:
+
[source,terminal]
----
$ oc apply -f <filename>.yaml
----
.Verification
* Verify that the desired link state is set by checking the `status.interfaces.linkState` field of the `VirtualMachineInstance` manifest.
+
[source,terminal]
----
$ oc get vmi <vmi-name>
----
+
Example output:
+
[source,yaml]
----
apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
name: my-vm
spec:
domain:
devices:
interfaces:
- name: default
state: down
masquerade: { }
networks:
- name: default
pod: { }
status:
interfaces:
- name: default
linkState: down
# ...
----