Skip to main content
Version: v1.4 (dev)

CPU Pinning

Available as of v1.4.0

Harvester supports VM CPU pinning. To use this feature, you must first enable the CPU Manager on the nodes, and then enable CPU pinning when you create the VM.

Kubernetes CPU Manager

The CPU Manager feature improves CPU resource allocation in Kubernetes clusters, ensuring that workloads with strict performance needs receive stable and predictable CPU resources. This is especially important for high-performance and latency-sensitive applications.

Harvester uses the static CPU Manager policy when the CPU Manager is enabled. This policy manages a shared pool of CPUs that initially includes all CPUs on nodes with the following configuration:

  • Pods in the Guaranteed quality of service (QoS) class that request whole CPU cores (for example, CPU: "2") are assigned dedicated CPUs. These CPUs are "pinned" to the pod and are removed from the shared CPU pool.
  • Pods in the Burstable and BestEffort QoS classes share the remaining CPUs in the shared pool.

Calculation of Shared CPU Pool

Harvester reserves CPU resources for system-level operations based on the GKE formula, with the systemReserved and kubeReserved values allocated in a 2:3 ratio.

Example (node with 16 CPU cores):

systemReserved: 408 millicores
kubeReserved: 612 millicores

In this example, approximately 15 cores (14980 millicores) are available for workloads.

When a VM (pod) in the Guaranteed QoS class requests 4 CPUs, 4 cores are dedicated to that VM. Pods in the other QoS classes share the remaining 11 cores in the shared pool.

Enable and Disable CPU Manager

When you enable the CPU Manager, Harvester sets the CPU Manager policy to static. When you disable the feature, Harvester switches the CPU Manager policy back to none.

You must enable or disable the CPU Manager on each node separately.

  1. On the Harvester UI, go to Hosts.

  2. Locate the node in the list, and then select > Enable CPU Manager or Disable CPU Manager.

Allow some time for Harvester to apply the corresponding CPU Manager policy.

enable-cpu-manager disable-cpu-manager

Limitations

  • The CPU Manager cannot be enabled on the witness node.

  • The CPU Manager must be enabled or disabled on each management node separately. You must wait for the operation to be completed before starting another.

  • VMs with CPU pinning enabled must be stopped before CPU Manager is disabled on the corresponding node.

Enable CPU Pinning on a New VM

  1. Verify that CPU Manager is enabled on one or more nodes.

  2. Go to Virtual Machines.

  3. Click Create.

    create-vm

  4. On the Advanced Options tab, select Enable CPU Pinning.

    vm-advanced-options

  5. Click Save.

Enabling CPU pinning adds dedicatedCpuPlacement: true to .spec.template.spec.domain.cpu in the virtual machine configuration (YAML). When dedicatedCpuPlacement is set to true, the CPU and memory resource requests are automatically set to match the limits to ensure that the criteria for Guaranteed QoS are met.

Because the requests and limits are identical, CPU and memory Resource Overcommit settings do not apply to VMs with CPU pinning enabled.

note

To use CPU pinning on an existing VM, you must restart the VM after enabling the feature and saving the change.

VM Live Migration

VMs with CPU pinning enabled can be migrated only if the CPU Manager is enabled on the target node.

Upgrades

When upgrading a node, Harvester drains all pods and live migrates VMs to another node. To avoid interruptions to the upgrade process, ensure that the CPU Manager is enabled on other nodes and sufficient resources are available whenever you use VMs with CPU pinning enabled.