You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Add additional-guest-memory-overhead-ratio setting
Signed-off-by: Jian Wang <[email protected]>
* Update with more details
Signed-off-by: Jian Wang <[email protected]>
* Add more supporting data
Signed-off-by: Jian Wang <[email protected]>
* Update resource quota about vm memory overhead
Signed-off-by: Jian Wang <[email protected]>
* Hint that change the setting does not affect running VMs immediately
Signed-off-by: Jian Wang <[email protected]>
* Add new settings and other changes to v1.4 branch
Signed-off-by: Jian Wang <[email protected]>
* Address review comments
Signed-off-by: Jian Wang <[email protected]>
---------
Signed-off-by: Jian Wang <[email protected]>
Copy file name to clipboardexpand all lines: docs/advanced/settings.md
+120
Original file line number
Diff line number
Diff line change
@@ -328,6 +328,126 @@ A VM that is configured to use 2 CPUs (equivalent to 2,000 milliCPU) can consume
328
328
}
329
329
```
330
330
331
+
### `additional-guest-memory-overhead-ratio`
332
+
333
+
**Definition**: The ratio to futher tune the VM `memory overhead`.
334
+
335
+
Each VM is configured with a memory value, this memory is targeted for the VM guest OS to see and use. In Harvester, the VM run in a virt-launcher pod. CPU/VM resource limits are translated and applied to the launcher pod [Resource requests and limits of Pod and container](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-requests-and-limits-of-pod-and-container). Kubevirt ensures certain amount of memory is reserved in the pod for managing the virtualization process. Harvester and KubeVirt summarize such additional memory as the VM `Memory Overhead`. The `Memory Overhead` is computed by a complex formula formula. However, sometimes the OOM(Out Of Memory) can still happen and the related VM is killed by the Harvester OS, the direct cause is that the whole POD/Container exceeds its memory limits. From practice, the `Memory Overhead` varies on different kinds of VM, different kinds of VM operating system, and also depends on the running workloads on the VM.
336
+
337
+
This setting is for more flexibly tuning the VM `Memory Overhead`.
338
+
339
+
**Default values**: `"1.5"`
340
+
341
+
Valid values: `""`, `"0"` and from `"1.0"` to `"10.0"`.
342
+
343
+
A VM that is configured to have `1 CPU, 2 Gi Memory, 1 Volume and 1 NIC` will get around `240 Mi``Memory Overhead` when the ratio is `"1.0"`. When the ratio is `"1.5"`, the `Memory Overhead` is `360 Mi`. When the ratio is `"3"`, the `Memory Overhead` is `720 Mi`.
344
+
345
+
A VM that is configured to have `1 CPU, 64 Gi Memory, 1 Volume and 1 NIC` will get around `250 Mi``Memory Overhead` when the ratio is `"1.0"`. The VM memory size does not have a big influence on the computing of `Memory Overhead`. The overhead of `guest OS pagetables` needs one bit for every 512b of RAM size.
346
+
347
+
The yaml output of this setting on a new cluster:
348
+
349
+
```
350
+
apiVersion: harvesterhci.io/v1beta1
351
+
default: "1.5"
352
+
kind: Setting
353
+
metadata:
354
+
name: additional-guest-memory-overhead-ratio
355
+
value: ""
356
+
```
357
+
358
+
When the `value` field is `""`, the `default` field is used.
359
+
360
+
When the `value` field is `"0"`, the `additional-guest-memory-overhead-ratio` setting is not used, Harvester will fallback to the legacy [Reserved Memory](../../versioned_docs/version-v1.3/vm/create-vm.md#reserved-memory) which is used in Harvester v1.3.x, v1.2.x and earlier versions. When a new VM is created and the `Reserved Memory` field on WebUI is not filled, this VM will get the `100Mi default Reserved Memory`.
361
+
362
+
If you have already set a valid value on the `spec.configuration.additionalGuestMemoryOverheadRatio` field of `kubevirt` object before Harvester v1.4.0 and then upgrade to v1.4.0, Harvester will fetch and convert it to the `value` field of this setting on the upgrade path. After that, Harvester will always use this setting to sync to the `kubevirt` object.
363
+
364
+
This setting and the VM configuration field [Reserved Memroy](../vm/create-vm.md#reserved-memory) are both taken into account to get a final `Total Memory Overhead` for each VM.
| VM Configured Memory | Reserved Memory | additional-guest-memory-overhead-ratio| Guest OS Memory | POD Container Memory Limit | Total Memory Overhead |
371
+
| --- | --- | --- | --- | --- | --- |
372
+
| 2 Gi | ""(not configured) | "0.0" | 2 Gi - 100 Mi | 2 Gi + 240 Mi |~340 Mi |
373
+
| 2 Gi | 256 Mi | "0.0" | 2 Gi - 256 Mi | 2 Gi + 240 Mi |~500 Mi |
374
+
| --- | --- | --- | --- | --- | --- |
375
+
| 2 Gi | ""(not configured) | "1.0" | 2 Gi | 2 Gi + 240*1.0 Mi |~240 Mi |
376
+
| 2 Gi | ""(not configured) | "3.0" | 2 Gi | 2 Gi + 240*3.0 Mi |~720 Mi |
377
+
| --- | --- | --- | --- | --- | --- |
378
+
| 2 Gi | ""(not configured) | "1.5" | 2 Gi | 2 Gi + 240*1.5 Mi |~360 Mi |
379
+
| 2 Gi | 256 Mi | "1.5" | 2 Gi - 256 Mi | 2 Gi + 240*1.5 Mi |~620 Mi |
380
+
381
+
The related information can be fetched from those objects:
382
+
383
+
```
384
+
When `additional-guest-memory-overhead-ratio` is set as "1.5".
385
+
386
+
The VM object:
387
+
...
388
+
memory:
389
+
guest: 2Gi // Guest OS Memory
390
+
resources:
391
+
limits:
392
+
cpu: "1"
393
+
memory: 2Gi // VM Configured Memory
394
+
395
+
The POD object:
396
+
...
397
+
resources:
398
+
limits:
399
+
cpu: "1"
400
+
devices.kubevirt.io/kvm: "1"
401
+
devices.kubevirt.io/tun: "1"
402
+
devices.kubevirt.io/vhost-net: "1"
403
+
memory: "2532309561" // POD Container Memory Limit
404
+
405
+
```
406
+
407
+
**Example**:
408
+
409
+
```
410
+
2.0
411
+
```
412
+
413
+
:::note
414
+
415
+
To reduce the chance of hitting OOM, Harvester suggests to:
416
+
417
+
- Configure this setting with value `"2"` to give all the VMs `~480 Mi``Memory Overhead`, if the cluster has no memory resource pressure.
418
+
419
+
- Configure the `Reserved Memory` field to have a bigger `Total Memory Overhead`, if some VMs are important. The rules based on experiences are:
420
+
421
+
- When `VM Configured Memory` is between `5 Gi` and `10 Gi`, the `Total Memory Overhead` is `>= VM Configured Memory * 10%`.
422
+
423
+
- When `VM Configured Memory` is greater than `10 Gi`, the `Total Memory Overhead` is `>= 1 Gi`.
424
+
425
+
- Keep observing, tuning and testing to get the best values for each VM.
426
+
427
+
- Avoid configuring the `spec.configuration.additionalGuestMemoryOverheadRatio` field of `kubevirt` object directly.
428
+
429
+
The bigger `Total Memory Overhead` does not mean that the amount of memory is used up all the time, it is set to tolerant the peak and hence avoid hitting OOM.
430
+
431
+
There is no `one-fit-all` solution.
432
+
433
+
:::
434
+
435
+
:::important
436
+
437
+
If you have set the `Reserved Memory` field for each VM and plan to keep the legacy [Reserved Memory](../../versioned_docs/version-v1.3/vm/create-vm.md#reserved-memory), after the cluster is upgraded to Harvester v1.4.0, you can set the `additional-guest-memory-overhead-ratio` setting to `"0"`.
438
+
439
+
Changing the `additional-guest-memory-overhead-ratio` setting affects the VMs per following rules:
440
+
441
+
- It will affect the VMs newly created after this change immediately.
442
+
443
+
- It will not affect the running VMs immediately, those VMs will get the new `Memory Overhead` calculated from the setting after those VMs are rebooted.
444
+
445
+
- When a VM has a user configured `Reserved Memory`, this is always kept.
446
+
447
+
- When the value changes between `"0"` and the range `["", "1.0" .. "10.0"]`, the existing VMs which have the `100Mi default Reserved Memory` will keep it, the existing VMs which do not have `100Mi default Reserved Memory` will not get it automatically.
448
+
449
+
:::
450
+
331
451
### `release-download-url`
332
452
333
453
**Definition**: URL for downloading the software required for upgrades.
Copy file name to clipboardexpand all lines: docs/rancher/resource-quota.md
+20-7
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,13 @@ You can configure the **Namespace** limits as follows:
41
41
Attempts to provision VMs for guest clusters are blocked when the resource quotas are reached. Rancher responds by creating a new VM in a loop, in which each failed attempt to create a VM is immediately followed by another creation attempt. This results in a transient error state in the cluster that is not recorded as the VM is recreated.
42
42
:::
43
43
44
-
## Overhead memory of virtual machine
44
+
:::important
45
+
46
+
Due to the [Overhead Memory of Virtual Machine](#overhead-memory-of-virtual-machine), each VM needs some additional memory to work. When setting **Memory Limit**, this should be taken into account. For example, when the project **Memory Limit** is `24 Gi`, it is not possible to run 3 VMs each has `8 Gi` memory.
47
+
48
+
:::
49
+
50
+
## Overhead Memory of Virtual Machine
45
51
Upon creating a virtual machine (VM), the VM controller seamlessly incorporates overhead resources into the VM's configuration. These additional resources intend to guarantee the consistent and uninterrupted functioning of the VM. It's important to note that configuring memory limits requires a higher memory reservation due to the inclusion of these overhead resources.
46
52
47
53
For example, consider the creation of a new VM with the following configuration:
@@ -56,18 +62,25 @@ Memory Overhead is calculated in the following sections:
56
62
-**Memory PageTables Overhead:** This accounts for one bit for every 512b RAM size. For instance, a memory of 16Gi requires an overhead of 32Mi.
57
63
-**VM Fixed Overhead:** This consists of several components:
58
64
-`VirtLauncherMonitorOverhead`: 25Mi (the `ps` RSS for virt-launcher-monitor)
59
-
-`VirtLauncherOverhead`: 75Mi (the `ps` RSS for the virt-launcher process)
60
-
-`VirtlogdOverhead`: 17Mi (the `ps` RSS for virtlogd)
61
-
-`LibvirtdOverhead`: 33Mi (the `ps` RSS for libvirtd)
65
+
-`VirtLauncherOverhead`: 100Mi (the `ps` RSS for the virt-launcher process)
66
+
-`VirtlogdOverhead`: 20Mi (the `ps` RSS for virtlogd)
67
+
-`VirtqemudOverhead`: 35Mi (the `ps` RSS for virtqemud)
62
68
-`QemuOverhead` : 30Mi (the `ps` RSS for qemu, minus the RAM of its (stressed) guest, minus the virtual page table)
63
69
-**8Mi per CPU (vCPU) Overhead:** Additionally, 8Mi of overhead per vCPU is added, along with a fixed 8Mi overhead for IOThread.
64
70
-**Extra Added Overhead:** This encompasses various factors like video RAM overhead and architecture overhead. Refer to [Additional Overhead](https://github.com/kubevirt/kubevirt/blob/2bb88c3d35d33177ea16c0f1e9fffdef1fd350c6/pkg/virt-controller/services/template.go#L1853-L1890) for further details.
71
+
-**additional-guest-memory-overhead-ratio** User can further tune the `Memory Overhead` by the Harvester setting [additional-guest-memory-overhead-ratio](../advanced/settings.md#additional-guest-memory-overhead-ratio), which defaults to `"1.5"`. This setting is important for VM to eliminate the chance to hit OOM(Out of Memory).
65
72
66
-
This calculation demonstrates that the VM instance necessitates an additional memory overhead of approximately 276Mi.
73
+
This calculation demonstrates that the VM instance necessitates an additional memory overhead of approximately 380Mi.
67
74
68
75
For more information, see [Memory Overhead](https://kubevirt.io/user-guide/virtual_machines/virtual_hardware/#memory-overhead).
69
76
70
-
For more information on how the memory overhead is calculated in Kubevirt, refer to [kubevirt/pkg/virt-controller/services/template.go](https://github.com/kubevirt/kubevirt/blob/v0.54.0/pkg/virt-controller/services/template.go#L1804).
77
+
For more information on how the memory overhead is calculated in Kubevirt, refer to the source code [GetMemoryOverhead](https://github.com/kubevirt/kubevirt/blob/1466b658f78b9b8bb9517ffb6dafd4b777f33fe6/pkg/virt-controller/services/renderresources.go#L307).
78
+
79
+
:::note
80
+
81
+
The `Overhead Memory` varies between different Harvester releases (with different Kubevirt releases) because all those backing components are keeping adding new features and fixing bugs, they need more memory.
82
+
83
+
:::
71
84
72
85
## Automatic adjustment of ResourceQuota during migration
73
86
When the allocated resource quota controlled by the `ResourceQuota` object reaches its limit, migrating a VM becomes unfeasible. The migration process automatically creates a new pod mirroring the resource requirements of the source VM. If these pod creation prerequisites surpass the defined quota, the migration operation cannot proceed.
@@ -81,4 +94,4 @@ Please be aware of the following constrains of the automatic resizing of `Resour
81
94
- When raising the `ResourceQuota` value, if you create, start, or restore other VMs, Harvester will verify if the resources are sufficient based on the original `ResourceQuota`. If the conditions are not met, the system will alert that the migration process is not feasible.
82
95
- After expanding `ResourceQuota`, potential resource contention may occur between non-VM pods and VM pods, leading to migration failures. Therefore, deploying custom container workloads and VMs to the same namespace is not recommended.
83
96
- Due to the concurrent limitation of the webhook validator, the VM controller will execute a secondary validation to confirm resource sufficiency. If the resource is insufficient, it will auto config the VM's `RunStrategy` to `Halted`, and a new annotation `harvesterhci.io/insufficient-resource-quota` will be added to the VM object, informing you that the VM was shut down due to insufficient resources.
Copy file name to clipboardexpand all lines: docs/vm/create-vm.md
+17
Original file line number
Diff line number
Diff line change
@@ -238,6 +238,23 @@ In order to meet the scenario requirements of more users, the `RunStrategy` fiel
238
238
- Stop: There will be no VM instance. If the guest is already running, it will be stopped. This is the same behavior as `Running: false`.
239
239
240
240
241
+
### Reserved Memory
242
+
243
+
Each VM is configured with a memory value, this memory is targeted for the VM guest OS to see and use. In Harvester, the VM is carried by a Kubernetes POD. The memory limitation is achieved by Kubernetes [Resource requests and limits of Pod and container](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-requests-and-limits-of-pod-and-container). Certain amount of memory is required to simulate and manage the `CPU/Memory/Storage/Network/...` for the VM to run. Harvester and KubeVirt summarize such additional memory as the VM `Memory Overhead`. The `Memory Overhead` is computed by a complex formula. However, sometimes the OOM(Out Of Memory) can still happen and the related VM is killed by the Harvester OS, the direct cause is that the whole POD/Container exceeds its memory limits. From practice, the `Memory Overhead` varies on different kinds of VM, different kinds of VM operating system, and also depends on the running workloads on the VM.
244
+
245
+
Harvester adds a `Reserved Memory` field and a setting `additional-guest-memory-overhead-ratio` for users to adjust the guest OS memory and the `Total Memory Overhead`.
Copy file name to clipboardexpand all lines: versioned_docs/version-v1.3/rancher/resource-quota.md
+14-2
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,12 @@ You can configure the **Namespace** limits as follows:
40
40
Attempts to provision VMs for guest clusters are blocked when the resource quotas are reached. Rancher responds by creating a new VM in a loop, in which each failed attempt to create a VM is immediately followed by another creation attempt. This results in a transient error state in the cluster that is not recorded as the VM is recreated.
41
41
:::
42
42
43
+
:::important
44
+
45
+
Due to the [Overhead Memory of Virtual Machine](#overhead-memory-of-virtual-machine), each VM needs some additional memory to work. When setting **Memory Limit**, this should be taken into account. For example, when the project **Memory Limit** is `24 Gi`, it is not possible to run 3 VMs each has `8 Gi` memory.
46
+
47
+
:::
48
+
43
49
## Overhead memory of virtual machine
44
50
Upon creating a virtual machine (VM), the VM controller seamlessly incorporates overhead resources into the VM's configuration. These additional resources intend to guarantee the consistent and uninterrupted functioning of the VM. It's important to note that configuring memory limits requires a higher memory reservation due to the inclusion of these overhead resources.
45
51
@@ -66,7 +72,13 @@ This calculation demonstrates that the VM instance necessitates an additional me
66
72
67
73
For more information, see [Memory Overhead](https://kubevirt.io/user-guide/virtual_machines/virtual_hardware/#memory-overhead).
68
74
69
-
For more information on how the memory overhead is calculated in Kubevirt, refer to [kubevirt/pkg/virt-controller/services/template.go](https://github.com/kubevirt/kubevirt/blob/v0.54.0/pkg/virt-controller/services/template.go#L1804).
75
+
For more information on how the memory overhead is calculated in Kubevirt, refer to the source code [GetMemoryOverhead](https://github.com/kubevirt/kubevirt/blob/e8e638edc22587ec7be2cc3d983b61763e33f973/pkg/virt-controller/services/renderresources.go#L299).
76
+
77
+
:::note
78
+
79
+
The `Overhead Memory` varies between different Harvester releases (with different Kubevirt releases) because all those backing components are keeping adding new features and fixing bugs, they need more memory.
80
+
81
+
:::
70
82
71
83
## Automatic adjustment of ResourceQuota during migration
72
84
When the allocated resource quota controlled by the `ResourceQuota` object reaches its limit, migrating a VM becomes unfeasible. The migration process automatically creates a new pod mirroring the resource requirements of the source VM. If these pod creation prerequisites surpass the defined quota, the migration operation cannot proceed.
@@ -80,4 +92,4 @@ Please be aware of the following constrains of the automatic resizing of `Resour
80
92
- When raising the `ResourceQuota` value, if you create, start, or restore other VMs, Harvester will verify if the resources are sufficient based on the original `ResourceQuota`. If the conditions are not met, the system will alert that the migration process is not feasible.
81
93
- After expanding `ResourceQuota`, potential resource contention may occur between non-VM pods and VM pods, leading to migration failures. Therefore, deploying custom container workloads and VMs to the same namespace is not recommended.
82
94
- Due to the concurrent limitation of the webhook validator, the VM controller will execute a secondary validation to confirm resource sufficiency. If the resource is insufficient, it will auto config the VM's `RunStrategy` to `Halted`, and a new annotation `harvesterhci.io/insufficient-resource-quota` will be added to the VM object, informing you that the VM was shut down due to insufficient resources.
0 commit comments