mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 21:46:22 +01:00
120 lines
3.2 KiB
Plaintext
120 lines
3.2 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
// * virt/virtual_machines/vm_networking/virt-hot-plugging-network-interfaces.adoc
|
|
|
|
:_mod-docs-content-type: PROCEDURE
|
|
[id="virt-hot-plugging-bridge-network-interface_{context}"]
|
|
= Hot plugging a secondary network interface by using the CLI
|
|
|
|
[role="_abstract"]
|
|
You can hot plug a secondary network interface to a virtual machine (VM) while the VM is running.
|
|
|
|
.Prerequisites
|
|
|
|
* A network attachment definition is configured in the same namespace as your VM.
|
|
* The VM to which you want to hot plug the network interface is running.
|
|
* You have installed the {oc-first}.
|
|
|
|
.Procedure
|
|
|
|
. Use your preferred text editor to edit the `VirtualMachine` manifest, as shown in the following example:
|
|
+
|
|
[source,yaml]
|
|
----
|
|
apiVersion: kubevirt.io/v1
|
|
kind: VirtualMachine
|
|
metadata:
|
|
name: vm-fedora
|
|
template:
|
|
spec:
|
|
domain:
|
|
devices:
|
|
interfaces:
|
|
- name: defaultnetwork
|
|
masquerade: {}
|
|
# new interface
|
|
- name: <secondary_nic> # <1>
|
|
bridge: {}
|
|
networks:
|
|
- name: defaultnetwork
|
|
pod: {}
|
|
# new network
|
|
- name: <secondary_nic> # <2>
|
|
multus:
|
|
networkName: <nad_name> # <3>
|
|
# ...
|
|
----
|
|
<1> Specifies the name of the new network interface.
|
|
<2> Specifies the name of the network. This must be the same as the `name` of the new network interface that you defined in the `template.spec.domain.devices.interfaces` list.
|
|
<3> Specifies the name of the `NetworkAttachmentDefinition` object.
|
|
|
|
. Save your changes and exit the editor.
|
|
|
|
. For the new configuration to take effect, apply the changes by running the following command. Applying the changes triggers automatic VM live migration and attaches the network interface to the running VM.
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc apply -f <filename>.yaml
|
|
----
|
|
+
|
|
where:
|
|
|
|
<filename>:: Specifies the name of your `VirtualMachine` manifest YAML file.
|
|
|
|
.Verification
|
|
|
|
. Verify that the VM live migration is successful by using the following command:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc get VirtualMachineInstanceMigration -w
|
|
----
|
|
+
|
|
Example output:
|
|
+
|
|
[source,terminal]
|
|
----
|
|
NAME PHASE VMI
|
|
kubevirt-migrate-vm-lj62q Scheduling vm-fedora
|
|
kubevirt-migrate-vm-lj62q Scheduled vm-fedora
|
|
kubevirt-migrate-vm-lj62q PreparingTarget vm-fedora
|
|
kubevirt-migrate-vm-lj62q TargetReady vm-fedora
|
|
kubevirt-migrate-vm-lj62q Running vm-fedora
|
|
kubevirt-migrate-vm-lj62q Succeeded vm-fedora
|
|
----
|
|
|
|
. Verify that the new interface is added to the VM by checking the status of the virtual machine instance (VMI):
|
|
+
|
|
[source,terminal]
|
|
----
|
|
$ oc get vmi vm-fedora -ojsonpath="{ @.status.interfaces }"
|
|
----
|
|
+
|
|
Example output:
|
|
+
|
|
[source,json]
|
|
----
|
|
[
|
|
{
|
|
"infoSource": "domain, guest-agent",
|
|
"interfaceName": "eth0",
|
|
"ipAddress": "10.130.0.195",
|
|
"ipAddresses": [
|
|
"10.130.0.195",
|
|
"fd02:0:0:3::43c"
|
|
],
|
|
"mac": "52:54:00:0e:ab:25",
|
|
"name": "default",
|
|
"queueCount": 1
|
|
},
|
|
{
|
|
"infoSource": "domain, guest-agent, multus-status",
|
|
"interfaceName": "eth1",
|
|
"mac": "02:d8:b8:00:00:2a",
|
|
"name": "bridge-interface", <1>
|
|
"queueCount": 1
|
|
}
|
|
]
|
|
----
|
|
<1> The hot plugged interface appears in the VMI status.
|