10.12.2. Setting the VM interface link state by using the CLI
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:
apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: my-vm spec: template: spec: domain: devices: interfaces: - name: default state: down masquerade: { } networks: - name: default pod: { } # ...-
spec.template.spec.domain.devices.interfaces.namedefines the name of the interface. spec.template.spec.domain.devices.interfaces.statedefines 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.중요If you have defined readiness or liveness probes to run VM health checks, setting the primary interface’s link state to
downcauses the probes to fail. If a liveness probe fails, the VM is deleted and a new VM is created to restore responsiveness.
-
-
Apply the
VirtualMachinemanifest:$ oc apply -f <filename>.yaml
Verification
Verify that the desired link state is set by checking the
status.interfaces.linkStatefield of theVirtualMachineInstancemanifest.$ oc get vmi <vmi-name>Example output:
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 # ...