$ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
OpenShift Virtualization can activate kernel samepage merging (KSM) when nodes are overloaded. KSM deduplicates identical data found in the memory pages of virtual machines (VMs). If you have very similar VMs, KSM can make it possible to schedule more VMs on a single node.
You must only use KSM with trusted workloads. |
Ensure that an administrator has configured KSM support on any nodes where you want OpenShift Virtualization to activate KSM.
You can configure OpenShift Virtualization to activate kernel samepage merging (KSM) when nodes experience memory overload.
You can enable or disable the KSM activation feature for all nodes by using the OpenShift Container Platform web console or by editing the HyperConverged
custom resource (CR). The HyperConverged
CR supports more granular configuration.
You can configure the KSM activation feature by editing the spec.configuration.ksmConfiguration
stanza of the HyperConverged
CR.
You enable the feature and configure settings by editing the ksmConfiguration
stanza.
You disable the feature by deleting the ksmConfiguration
stanza.
You can allow OpenShift Virtualization to enable KSM on only a subset of nodes by adding node selection syntax to the ksmConfiguration.nodeLabelSelector
field.
Even if the KSM activation feature is disabled in OpenShift Virtualization, an administrator can still enable KSM on nodes that support it. |
OpenShift Virtualization identifies nodes that are configured to support KSM and applies the following node labels:
kubevirt.io/ksm-handler-managed: "false"
This label is set to "true"
when OpenShift Virtualization activates KSM on a node that is experiencing memory overload. This label is not set to "true"
if an administrator activates KSM.
kubevirt.io/ksm-enabled: "false"
This label is set to "true"
when KSM is activated on a node, even if OpenShift Virtualization did not activate KSM.
These labels are not applied to nodes that do not support KSM.
You can allow OpenShift Virtualization to activate kernel samepage merging (KSM) on all nodes in your cluster by using the OpenShift Container Platform web console.
From the side menu, click Virtualization → Overview.
Select the Settings tab.
Select the Cluster tab.
Expand Resource management.
Enable or disable the feature for all nodes:
Set Kernel Samepage Merging (KSM) to on.
Set Kernel Samepage Merging (KSM) to off.
You can enable or disable OpenShift Virtualization’s kernel samepage merging (KSM) activation feature by editing the HyperConverged
custom resource (CR). Use this method if you want OpenShift Virtualization to activate KSM on only a subset of nodes.
Open the HyperConverged
CR in your default editor by running the following command:
$ oc edit hyperconverged kubevirt-hyperconverged -n openshift-cnv
Edit the ksmConfiguration
stanza:
To enable the KSM activation feature for all nodes, set the nodeLabelSelector
value to {}
. For example:
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
configuration:
ksmConfiguration:
nodeLabelSelector: {}
# ...
To enable the KSM activation feature on a subset of nodes, edit the nodeLabelSelector
field. Add syntax that matches the nodes where you want OpenShift Virtualization to enable KSM. For example, the following configuration allows OpenShift Virtualization to enable KSM on nodes where both <first_example_key>
and <second_example_key>
are set to "true"
:
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
configuration:
ksmConfiguration:
nodeLabelSelector:
matchLabels:
<first_example_key>: "true"
<second_example_key>: "true"
# ...
To disable the KSM activation feature, delete the ksmConfiguration
stanza. For example:
apiVersion: hco.kubevirt.io/v1beta1
kind: HyperConverged
metadata:
name: kubevirt-hyperconverged
namespace: openshift-cnv
spec:
configuration:
# ...
Save the file.
Managing kernel samepage merging in the Red Hat Enterprise Linux (RHEL) documentation