Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions modules/virt-about-cpu-and-memory-quota-namespace.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@

A _resource quota_, defined by the `ResourceQuota` object, imposes restrictions on a namespace that limit the total amount of compute resources that can be consumed by resources within that namespace.

The `HyperConverged` custom resource (CR) defines the user configuration for the Containerized Data Importer (CDI). The CPU and memory request and limit values are set to a default value of `0`. This ensures that pods created by CDI that do not specify compute resource requirements are given the default values and are allowed to run in a namespace that is restricted with a quota.

When the `AutoResourceLimits` feature gate is enabled, {VirtProductName} automatically manages CPU and memory limits. If a namespace has both CPU and memory quotas, the memory limit is set to double the base allocation and the CPU limit is one per vCPU.
The `HyperConverged` custom resource (CR) defines the user configuration for the Containerized Data Importer (CDI). The CPU and memory request and limit values are set to a default value of `0`. This ensures that pods created by CDI that do not specify compute resource requirements are given the default values and are allowed to run in a namespace that is restricted with a quota.
51 changes: 49 additions & 2 deletions modules/virt-setting-resource-quota-limits-for-vms.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,57 @@

:_mod-docs-content-type: PROCEDURE
[id="virt-setting-resource-quota-limits-for-vms_{context}"]
= Setting resource quota limits for virtual machines
= Enabling automatic resource quota limits for virtual machines

When the `AutoResourceLimits` feature gate is enabled, {VirtProductName} automatically manages CPU and memory limits for virtual machines.

By default, {VirtProductName} computes resource requests for a virtual machine. When you enable the `AutoResourceLimits` feature gate, {VirtProductName} 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.

[NOTE]
====
You can customize the memory limit ratio for a specific namespace by adding the `alpha.kubevirt.io/auto-memory-limits-ratio` annotation.

For example, the following command sets the ratio to 1.2 for the `my-virtualization-project` namespace:

[source,terminal]
----
$ oc annotate namespace my-virtualization-project alpha.kubevirt.io/auto-memory-limits-ratio=1.2
----
====

.Procedure

To enable automatic resource quota limits for virtual machines, perform the following steps:

. Edit the `HyperConverged` custom resource (CR) by running the following command:
+
[source,terminal]
----
$ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
----

. In the `spec.featureGates` section, add or set the `autoResourceLimits` parameter to `true`:
+
[source,yaml]
----
spec:
featureGates:
autoResourceLimits: true
----

. Save the changes and exit the editor.

== Manually setting resource quota limits for virtual machines

Resource quotas that only use requests automatically work with virtual machines (VMs). If your resource quota uses limits, you must manually set resource limits on VMs. Resource limits must be at least 100 MiB larger than resource requests.

[WARNING]
====
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.
====

.Procedure

. Set limits for a VM by editing the `VirtualMachine` manifest. For example:
Expand All @@ -32,4 +79,4 @@ spec:
----
<1> This configuration is supported because the `limits.memory` value is at least `100Mi` larger than the `requests.memory` value.

. Save the `VirtualMachine` manifest.
. Save the `VirtualMachine` manifest.