$ oc label ns/my-virtualization-project alpha.kubevirt.io/auto-memory-limits-ratio=1.2
Create and manage resource quotas for virtual machines.
When the AutoResourceLimits feature gate is enabled, OKD Virtualization automatically manages CPU and memory limits for virtual machines.
By default, OKD Virtualization computes resource requests for a virtual machine. When you enable the AutoResourceLimits feature gate, OKD Virtualization also computes resource limits to meet namespace quota requirements.
If a namespace enforces both CPU and memory quotas and requires limits to be set, enabling the AutoResourceLimits feature gate is recommended. When this feature is enabled, the memory limit is automatically set to double the base memory allocation and the CPU limit is set to one per vCPU.
|
You can customize the memory limit ratio for a specific namespace by adding the For example, the following command sets the ratio to 1.2 for the
|
To enable automatic resource quota limits for virtual machines, perform the following steps:
Edit the HyperConverged custom resource (CR) by running the following command:
$ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
In the spec.featureGates section, add or set the autoResourceLimits parameter to true:
spec:
featureGates:
autoResourceLimits: true
Save the changes and exit the editor.
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.
|
Manual management of resource quota limits is not recommended. It is recommended to enable automatic resource quota limit computation instead, as described in the previous section. Manual limit settings can lead to quota misconfigurations or scheduling issues. |
Set limits for a VM by editing the VirtualMachine manifest. For example:
apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
name: with-limits
spec:
runStrategy: Halted
template:
spec:
domain:
memory:
guest: 128Mi
resources:
limits:
memory: 256Mi
where
Specifies the actual amount of RAM that is shown to the guest operating system (OS) in the VM.
Specifies the hard limit for total memory consumption by the virt-launcher pod 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.memory value is at least 100Mi larger than the spec.template.spec.domain.memory.guest value.
Save the VirtualMachine manifest.