Hot Plugging Resources
In this module, you will perform three tasks:
Accessing the OpenShift Cluster
{openshift_cluster_console_url}[{openshift_cluster_console_url},window=_blank]
oc login -u {openshift_cluster_admin_username} -p {openshift_cluster_admin_password} --server={openshift_api_server_url}
{openshift_api_server_url}[{openshift_api_server_url},window=_blank]
{openshift_cluster_admin_username}
{openshift_cluster_admin_password}
Adding CPU and Memory to a Running VM
In this lab, we will add more CPU and Memory resources to a virtual machine by changing the virtual machine’s Instance Type. To do this, you will start with an existing VM that has a single vCPU and 2 GiB of memory. Using the OpenShift Virtualization console, you will modify the configuration of the VM Instance Type to a type that has 2 vCPU and 4 GiB of memory.
Instructions
-
Ensure you are logged in to the OpenShift Console as the admin user from your web browser and continue to the next step.
-
Navigate to Virtualization → Virtual Machines, and select the hot-plug project. Select the VM named hot-plug-vm1. Note that the InstanceType of this VM is u1.small. Above the InstanceType, you can see that the CPU | Memory for this VM is 1 CPU | 2GiB Memory. This is the current configuration for this VM.
-
Click on the Configuration tab and select Details, if it is not already selected. Note that the InstanceType is General Purpose and 1 CPU | 2GiB Memory.
-
Click on the blue pencil icon to modify the CPU and Memory resources. In the window that appears, pull down the Size menu and select 2xmedium: 2CPUs, 4Gi Memory. Click the Save button.
-
The configuration in the Details panel will now show that the virtual machine has 2 CPUs and 4 GiB of memory.
-
Click on the Console tab and view the console window of the VM. You will see messages from the kernel that additional CPU and memory are now available.
-
Verify the new resources by logging in to the VM using the credentials at the top of the console window. In this case, the username is rhel and the password is redhat.
In order for the new CPU and Memory configuration to take effect, the virtual machine will automatically migrate from one worker node to another. If the new CPU and Memory configuration does not appear immediately, you may have to wait a few minutes. -
To validate that the VM now has 2 CPUs, run the command:
Get the number of processorsnprocYou will see that two processors exist.
To validate that the VM now has 4GiB of memory, run the command:
Get the amount of memory$ free -mYou will see that the VM has approximately 4 GiB of total memory.
This VM image has kdump enabled, which reserves some memory for the kernel. This is why the memory amount appears to be less than 4 GiB. In fact, 4 GiB of memory is configured for the VM, but the operating system sees a lower number. If kdump were disabled, the total memory would be 4 GiB.
Adding a Virtual Disk to a Running VM
In this lab, we will add a new network interface connection (NIC) to an existing VM. To do this, you will start with an existing VM that has a single NIC on the pod network. Using the OpenShift Virtualization console, you will modify the configuration of the VM to include an additional NIC on a new network. You complete the hot plug action by live-migrating the VM to another worker node.
Instructions
-
Ensure you are logged in to the OpenShift Console as the admin user from your web browser and continue to the next step.
-
Navigate to Virtualization → Virtual Machines, and select the hot-plug project. Select the VM named hot-plug-vm1.
-
Click on the Configuration tab and select Storage. Note that the VM currently has a single bootable disk. You may also login to the VM via the Console tab and view the storage details from the operating system.
-
Add an empty disk by clicking the Add disk button and then clicking on Empty disk (blank).
-
In the window that appears, give the new disk a name (e.g. data-disk-01) and change the size to 5 GiB. The rest of the options may remain at their defaults. Click on the Save button.
-
The new disk has been added with a notification of Persistent Hotplug.
-
After some time, the console may show messages that a new disk has been attached (/dev/vdc). The new disk may not appear immediately, so please be patient.
-
Login to the virtual machine using the credentials in the Console tab and then run the lsblk command. Note that the new 5 GiB disk has been added as vdc.
-
The new disk is hot-plugged to the virtual machine by way of a new pod that manages access to the disk. The new pod in the project is called hp-volume-xxxxx and runs in addition to the virt-launcher pod for the VM.
Get a list of podsoc get pods -n hot-plugOutputNAME READY STATUS RESTARTS AGE hp-volume-mdnjd 1/1 Running 0 114s virt-launcher-hot-plug-vm1-rb6lg 2/2 Running 0 147m
-
The hp-volume pod will stop if the VM is stopped and the pod will start again when the VM is started. The new disk can be used as any normal disk would be used and will persist even if the VM is stopped and started.
-
Optional: Login to the VM using the credentials provided on the Console tab and create a filesystem on the new disk and mount it on the system.
-
Now you will remove the hot-plugged disk from the virtual machine. If you mounted the hot-plugged disk on your system, make sure to umount it before proceeding. Navigate to the hot-plug-vm1 virtual machine and then click on Configuration → Storage. Note the name of the PVC that you will remove (e.g. dv-hot-plug-vm1-data-disk-01-um6O11) because you may want it for the Bonus Lab later! Click on the three dots on the right side of the hot-plugged disk and select Detach.
-
Confirm the action by clicking on the Detach button.
-
Confirm in the VM that the disk (vdc) has been removed by logging into the virtual machine with the credentials in the Console tab, then running the lsblk command. The hot-plugged disk is no longer present on the system.
The detached disk still exists as a PVC. It can be re-attached, or attached to a different VM, or it can be deleted if it is no longer needed.
Bonus Lab - Convert a Hot Plug Disk to a Permanent Disk
The steps below are optional as they do not directly relate to hot plugging a new disk. However, it may be advantageous for you to know about converting a hot-plugged disk to a standard disk, which requires a VM restart.
-
The PVC you detached above still exists until it is deleted manually. Therefore, you can reattach the PVC as a standard disk while the VM is shut down.
-
Navigate to the virtual machine called hot-plug-vm1 and stop it, either by using the square stop button or by pulling down the Actions menu and clicking on Stop.
-
Click on the Configuration tab, and then Storage. Click on the Add pull down menu and select Volume.
-
Give the disk a name, if desired, and select the previously disconnected PVC name in the PersistentVolumeClaim name menu (e.g. dv-hot-plug-vm1-data-disk-01-um6O11)
-
Now both the boot volume and the new data disk are visible in the virtual machine configuration.
The new disk no longer has the Hotplug persistent label because it is not being added while the VM is running. -
Start the virtual machine by either clicking on the blue Play icon, or by pulling down the Actions menu and clicking on Start.
-
Once the virtual machine has booted, click on the Console tab and login to the virtual machine using the credentials above the console window. The disk is now attached, although it has changed names. It was vdc and now it is vdb. In the previous exercise, if you chose to write data to the second disk, you will see that the data is still there.
Adding a NIC to a Running VM
In this lab, we will add a new network interface connection (NIC) to an existing VM. To do this, you will start with an existing VM that has a single NIC on the pod network. Using the OpenShift Virtualization console, you will modify the configuration of the VM to include an additional NIC on a new network. You complete the hot plug action by live-migrating the VM to another worker node.
Instructions
-
Ensure you are logged in to the OpenShift Console as the admin user from your web browser and continue to the next step.
-
Navigate to Virtualization → Virtual Machines, and select the hot-plug project. Select the VM named hot-plug-vm1.
-
Take note of the worker node on which the VM is running (e.g. worker-cluster-m2ssq-3)
-
Click on the Configuration tab and select Network. Note that the VM currently has a single NIC.
You may also login to the VM via the Console tab and view the NIC details from the operating system.
-
Back in the Network configuration screen, click on the button “Add network interface”. Provide a name for the new interface, such as nic-1. The model should be virtio, and the Network should be default/east-west-nad. Click on the Save button.
-
Click on the > symbol next to the Pending changes banner that has appeared below the VM name and note that the message indicates a restart or migration is required for the NIC addition to take effect.
-
After the NIC is added, the VM will eventually live migrate to another node in order to complete the hardware addition. However, if you do not want to wait, you can initiate a live migration to complete the hot plug process.
-
Navigate back to the Console tab and you may see messages have appeared on the VM console that new hardware has been added. You can view the new NIC from the operating system by running the command ip address and viewing the output.
-
The new NIC is now available for use (e.g. enp2s0, but your environment may have a different interface name).






























