|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt/post_installation_configuration/virt-perf-optimization.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="virt-CPU-manager-policy_{context}"] |
| 7 | += Configuring full physical cores for virtual machines |
| 8 | + |
| 9 | +[role="_abstract"] |
| 10 | +As a cluster administrator, you can allocate a full physical core to a specific virtual machine (VM), instead of allowing different VMs to share the same physical core. |
| 11 | +Configuring your VMs to use only full physical cores can optimize performance for high-throughput or latency-critical VMs. |
| 12 | + |
| 13 | +Allocating only full physical cores is important on simultaneous multi-threading (SMT) enabled systems because it offers the following benefits: |
| 14 | + |
| 15 | +* Prevents noisy neighbors and resource contention |
| 16 | +* Mitigates performance degradation |
| 17 | +* Offers predictable latency |
| 18 | +* Guarantees exclusive CPU resources |
| 19 | +
|
| 20 | +You can configure full physical core allocation by modifying the `cpuManagerPolicy` and `cpuManagerPolicyOptions` settings in the `KubeletConfig` custom resource (CR). |
| 21 | + |
| 22 | +.Prerequisites |
| 23 | + |
| 24 | +* You have cluster administrator access to a {product-title} cluster with {VirtProductName} installed. |
| 25 | +* You have installed the {oc-first}. |
| 26 | +* You have enabled CPU Manager on the node where your VM runs. |
| 27 | +
|
| 28 | +.Procedure |
| 29 | + |
| 30 | +. Edit the `KubeletConfig` CR to add the required `cpuManagerPolicy` and `cpuManagerPolicyOptions` configurations: |
| 31 | ++ |
| 32 | +[source,yaml] |
| 33 | +---- |
| 34 | +apiVersion: machineconfiguration.openshift.io/v1 |
| 35 | +kind: KubeletConfig |
| 36 | +# ... |
| 37 | +cpuManagerPolicy: static |
| 38 | +cpuManagerPolicyOptions: |
| 39 | + full-pcpus-only: true |
| 40 | +kubeReserved: |
| 41 | + cpu: "1" |
| 42 | +# ... |
| 43 | +---- |
| 44 | ++ |
| 45 | +* You must set the `cpuManagerPolicy: static` policy to enable exclusive CPU allocation. This setting is a prerequisite for configuring the `cpuManagerPolicyOptions` settings. |
| 46 | +* You must set the `full-pcpus-only: true` policy option so that the static CPU Manager policy only allocates full physical cores. |
| 47 | +* You must reserve 1 CPU for the system by setting `cpu: "1"` in the `kubeReserved` settings. This ensures that the cluster remains stable, by requiring that the system's core functions always have access to the CPU that they need to work correctly. |
| 48 | +
|
| 49 | +. Run the following command to apply the changes to the `KubeletConfig` CR: |
| 50 | ++ |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +$ oc apply -f <filename>.yaml |
| 54 | +---- |
| 55 | + |
| 56 | +.Verification |
| 57 | + |
| 58 | +* Inspect the kubelet configuration on a node where the change you applied the change, by running the following command and inspecting the output: |
| 59 | ++ |
| 60 | +[source,terminal] |
| 61 | +---- |
| 62 | +$ oc debug node/<node_name> -- chroot /host cat /etc/kubernetes/kubelet.conf | grep -E -A 2 'cpuManagerPolicy|kubeReserved' |
| 63 | +---- |
| 64 | ++ |
| 65 | +Example output: |
| 66 | ++ |
| 67 | +[source,YAML] |
| 68 | +---- |
| 69 | +cpuManagerPolicy: static |
| 70 | +cpuManagerPolicyOptions: |
| 71 | + full-pcpus-only: true |
| 72 | +-- |
| 73 | +kubeReserved: |
| 74 | + cpu: "1" |
| 75 | +---- |
0 commit comments