Working with resource quotas for virtual machines
Manage and control virtual machine resource consumption to prevent overcommitment and ensure stable workload performance.
Create and manage resource quotas for virtual machines.
Setting resource quota limits for virtual machines
By default, OpenShift Virtualization automatically manages CPU and memory limits for virtual machines (VMs) if a namespace enforces resource quotas that require limits to be set. The memory limit is automatically set to twice the requested memory and the CPU limit is set to one per vCPU.
You can customize the memory limit ratio for a specific namespace by adding the alpha.kubevirt.io/auto-memory-limits-ratio label to the namespace. For example, the following command sets the memory limit ratio to 1.2:
$ oc label ns/my-virtualization-project alpha.kubevirt.io/auto-memory-limits-ratio=1.2
Warning
Avoid managing resource quota limits manually. To prevent misconfigurations or scheduling issues, rely on the automatic resource limit management provided by OpenShift Virtualization unless you have a specific need to override the defaults.
Resource quotas that only use requests automatically work with VMs. If your resource quota uses limits, you must manually set resource limits on VMs.
Memory resource limits, defined by the spec.template.spec.domain.resources.limits.memory value, must be at least 500 MiB, or 2% larger than the spec.template.spec.domain.memory.guest value.
-
Set limits for a VM by editing the
VirtualMachinemanifest. For example:apiVersion: kubevirt.io/v1 kind: VirtualMachine metadata: name: with-limits spec: runStrategy: Halted template: spec: domain: memory: guest: 128Mi resources: limits: memory: 256Miwhere
- spec.template.spec.domain.memory.guest
-
Specifies the actual amount of RAM that is shown to the guest operating system (OS) in the VM.
- spec.template.spec.domain.resources.limits.memory
-
Specifies the hard limit for total memory consumption by the
virt-launcherpod that hosts the VM. This limit must account for the guest OS RAM plus the hypervisor overhead.This example configuration is supported because the
spec.template.spec.domain.resources.limits.memoryvalue is at least100Milarger than thespec.template.spec.domain.memory.guestvalue.
-
Save the
VirtualMachinemanifest.