Testing workload isolation with a virtual machine
We’ve seen how workload partitioning works on cluster nodes, but it can also be applied to virtual machines (VM). Now we can test with virtual machines managed by Red Hat OpenShift Virtualization.
What will you learn?
- How virtual machines can use workload isolation
What you need before starting:
- Red Hat account
- Red Hat OpenShift Container Platform
- Red Hat OpenShift Virtualization
- At least 4 available CPU cores
Create a virtual machine
Use the OpenShift console or virtctl to create a virtual machine with 4 CPU cores in a project/namespace.
Access the VM and run a stress test
Use virtctl to SSH into the VM and execute the stress-ng command.
# Download and install virtctl if you haven't already
wget --no-check-certificate https://hyperconverged-cluster-cli-download-openshift-cnv.apps.demo-01-rhsys.wzhlab.top/amd64/linux/virtctl.tar.gz
tar zvxf virtctl.tar.gz
mv virtctl ~/.local/bin/
# SSH into the VM and run the test
virtctl -n demo ssh user@vm-name --identity-file=~/.ssh/id_rsa
stress-ng --cpu 4 --cpu-load 100 --temp-path /tmpObserve Host CPU usage
Checking top on the host node will again show that the QEMU process for the VM is consuming CPU cycles exclusively from the isolated cores (20-23).
# top output snippet
%Cpu19 : 1.7 us, 2.0 sy, 0.0 ni, 96.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
%Cpu20 : 99.0 us, 0.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.7 hi, 0.0 si, 0.0 st
%Cpu21 : 96.7 us, 0.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 1.0 hi, 2.0 si, 0.0 st
%Cpu22 : 98.7 us, 0.3 sy, 0.0 ni, 0.0 id, 0.0 wa, 1.0 hi, 0.0 si, 0.0 st
%Cpu23 : 99.0 us, 0.7 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.3 hi, 0.0 si, 0.0 stVerifying VM Process CPU affinity
Finally, we can confirm the CPU affinity of the VM's QEMU process on the host node. This demonstrates that the entire virtual machine, as a workload, is constrained to the isolated CPU cores.
# Find the PID of the qemu-kvm process for the VM
ps -ef | grep qemu-kvm
# 107 44891 44699 62 03:04 ? 00:04:53 /usr/libexec/qemu-kvm -name guest=demo_centos-stream10-tan-tarantula-34,.............
# Check its CPU affinity
taskset -c -p 44891
# pid 44891's current affinity list: 20-23Once you have finished this testing, we can take a look at how this all works together behind the scenes.