Memory hotplug was introduced in KubeVirt version 1.1, enabling the dynamic resizing of the amount of memory available to a running VM.
- Memory hotplug is currently only supported on the x86_64 architecture.
- Current hotplug implementation involves live-migration of the VM workload.
To use memory hotplug we need to add the
VMLiveUpdateFeatures feature gate in the KubeVirt CR:
Configure the Workload Update Strategy¶
workloadUpdateStrategy in the KubeVirt CR, since the current implementation of the hotplug process requires the VM to live-migrate.
Enable in VM Specification¶
Finally, enable memory hotplug in the VM specification:KubeVirt API Reference). For example, if a VM is configured with 512Mi of guest memory and maxGuest is not defined, and maxHotplugRatio is 2, then maxGuest will equal 1Gi.
NOTE: If memory hotplug is enabled/disabled on an already running VM a reboot is necessary for the changes to take effect.
Optionally, you can set the maximum amount of memory for the guest using a cluster level setting in the KubeVirt CR.
The VM-level configuration will take precedence over the cluster-wide one.
Memory Hotplug in Action¶
First we enable the
VMLiveUpdateFeatures feature gate and set
workloadUpdateStrategy in the KubeVirt CR.
Now we create a VM with memory hotplug enabled.
The Virtual Machine will automatically start and once booted it will report the currently available memory to the guest in the
status.memory field inside the VMI.
Since the Virtual Machine is now running we can patch the VM object to double the available guest memory so that we'll go from 128Mi to 256Mi.
After the hotplug request is processed and the Virtual Machine is live migrated, the new amount of memory should be available to the guest and visible in the VMI object.