Hot Plugging Resources

Accessing the OpenShift Cluster

Web Console

{openshift_cluster_console_url}[{openshift_cluster_console_url},window=_blank]

CLI Login
oc login -u {openshift_cluster_admin_username} -p {openshift_cluster_admin_password} --server={openshift_api_server_url}
Cluster API

{openshift_api_server_url}[{openshift_api_server_url},window=_blank]

OpenShift Username
{openshift_cluster_admin_username}
OpenShift Password
{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

  1. Ensure you are logged in to the OpenShift Console as the admin user from your web browser and continue to the next step.

  2. 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.

    03 image cpu 001
    Figure 1. CPU and Memory before hot plug
  3. 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.

    03 image cpu 002
    Figure 2. Virtual Machine details
  4. 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.

    03 image cpu 003
    Figure 3. Edit Instance Type
  5. The configuration in the Details panel will now show that the virtual machine has 2 CPUs and 4 GiB of memory.

    03 image cpu 004
    Figure 4. Virtual Machine details
  6. 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.

    03 image cpu 005
    Figure 5. CPU and Memory messages
  7. 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.
    03 image cpu 006
    Figure 6. Login to VM
  8. To validate that the VM now has 2 CPUs, run the command:

    Get the number of processors
    nproc

    You 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 -m

    You 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.
    03 image cpu 007
    Figure 7. Verify new resources

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

  1. Ensure you are logged in to the OpenShift Console as the admin user from your web browser and continue to the next step.

  2. Navigate to Virtualization → Virtual Machines, and select the hot-plug project. Select the VM named hot-plug-vm1.

    03 image disk 001
    Figure 8. hot-plug-vm1 details
  3. 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.

    03 image disk 002
    Figure 9. VM has only one disk
  4. Add an empty disk by clicking the Add disk button and then clicking on Empty disk (blank).

    03 image disk 003
    Figure 10. Add an empty disk
  5. 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.

    03 image disk 004
    Figure 11. Configure the new disk
  6. The new disk has been added with a notification of Persistent Hotplug.

    03 image disk 005
    Figure 12. The disk is added
  7. 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.

    03 image disk 006
    Figure 13. Kernel messages about a new disk
  8. 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.

    03 image disk 007
    Figure 14. View the new disk from the OS
  9. 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 pods
    oc get pods -n hot-plug
    Output
    NAME                                READY   STATUS      RESTARTS   AGE
    hp-volume-mdnjd                     1/1     Running     0          114s
    virt-launcher-hot-plug-vm1-rb6lg    2/2     Running     0          147m
  10. 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.

  11. 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.

  12. 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.

    03 image disk 011
    Figure 15. Detach the disk
  13. Confirm the action by clicking on the Detach button.

    03 image disk 012
    Figure 16. Confirm disk detach
  14. 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.
    03 image disk 013
    Figure 17. Disk is removed in OS

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.

  1. 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.

  2. 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.

    03 image disk persist 002
    Figure 18. Stop the VM
  3. Click on the Configuration tab, and then Storage. Click on the Add pull down menu and select Volume.

    03 image disk persist 003
    Figure 19. Add a volume
  4. 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)

    03 image disk persist 004
    Figure 20. Select the PVC
  5. 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.
    03 image disk persist 005
    Figure 21. Both disks are attached
  6. Start the virtual machine by either clicking on the blue Play icon, or by pulling down the Actions menu and clicking on Start.

    03 image disk persist 006
    Figure 22. Both disks are attached
  7. 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.

    03 image disk persist 007
    Figure 23. The disk is attached

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

  1. Ensure you are logged in to the OpenShift Console as the admin user from your web browser and continue to the next step.

  2. Navigate to Virtualization → Virtual Machines, and select the hot-plug project. Select the VM named hot-plug-vm1.

  3. Take note of the worker node on which the VM is running (e.g. worker-cluster-m2ssq-3)

    03 image nic 002
    Figure 24. Identify the worker node
  4. Click on the Configuration tab and select Network. Note that the VM currently has a single NIC.

    03 image nic 003a
    Figure 25. Single NIC only

    You may also login to the VM via the Console tab and view the NIC details from the operating system.

    03 image nic 003b
    Figure 26. Single NIC in Console
  5. 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.

    03 image nic 004
    Figure 27. Add network interface
  6. 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.

    03 image nic 005
    Figure 28. View pending changes
  7. 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.

    03 image nic 006
    Figure 29. Migrate the VM
  8. 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.

    03 image nic 008
    Figure 30. Messages on consoel about new NIC
  9. The new NIC is now available for use (e.g. enp2s0, but your environment may have a different interface name).

    03 image nic 009
    Figure 31. New NIC is up