Add support for K8s NUMA-aware Memory Manager

The Kubernetes Memory Manager enables the feature of guaranteed
memory (and hugepages) allocation for pods in the Guaranteed QoS
class. The Memory Manager employs hint generation protocol to
yield the most suitable NUMA affinity for a pod. The Memory
Manager feeds the central manager (Topology Manager) with these
affinity hints. Based on both the hints and Topology Manager
policy, the pod is rejected or admitted to the node.
Moreover, the Memory Manager ensures that the memory which a pod
requests is allocated from a minimum number of NUMA nodes.

To align memory resources with other requested resources in a Pod
spec:

The CPU Manager should be enabled and proper CPU Manager policy
should be configured on a Node.
The Topology Manager should be enabled and proper Topology Manager
policy should be configured on a Node. See control Topology
Management Policies.

To configure Memory manager, other Managers should be first
pre-configured. Next, the Memory Manager feature should be enabled
and be run with 'Static' policy.

Memory Manager supports two policies. one can select a policy
via a kubelet flag --memory-manager-policy:
    * None (default)
    * Static

None policy:
This is the default policy and does not affect the memory
allocation in any way. It acts the same as if the Memory
Manager is not present at all. The None policy returns
default topology hint. This special hint denotes that Hint
Provider (Memory Manager in this case) has no preference
for NUMA affinity with any resource.

Static policy
In the case of the Guaranteed pod, the Static Memory Manager
policy returns topology hints relating to the set of NUMA
nodes where the memory can be guaranteed, and reserves the
memory through updating the internal NodeMap object.

Test Plan: Install AIO-SX, lock host, assign host label
           kube-memory-mgr-policy=Static, unlock host.
           Verify that /var/lib/kubelet/memory_manager_state
           shows Policy as Static.

Story: 2010368
Task: 49889

Depends-on: https://review.opendev.org/c/starlingx/stx-puppet/+/916298

Change-Id: Id114d81cda6b121a63ed4f7d31a2a3082bc86936
Signed-off-by: Saba Touheed Mujawar <sabatouheed.mujawar@windriver.com>
This commit is contained in:
Saba Touheed Mujawar 2024-04-17 14:16:18 -04:00
parent 69e075e250
commit d605472b6b
3 changed files with 15 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# Copyright (c) 2018-2023 Wind River Systems, Inc.
# Copyright (c) 2018-2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -351,7 +351,8 @@ def _check_host_locked(host, host_labels):
common.LABEL_REMOTE_STORAGE,
common.LABEL_SRIOVDP,
constants.KUBE_TOPOLOGY_MANAGER_LABEL,
constants.KUBE_CPU_MANAGER_LABEL]
constants.KUBE_CPU_MANAGER_LABEL,
constants.KUBE_MEMORY_MANAGER_LABEL]
lock_required_labels = [x for x in host_labels
if x in labels_requiring_lock]
@ -382,6 +383,11 @@ def _semantic_check_worker_labels(body):
raise wsme.exc.ClientSideError(
_(
"Invalid value for %s label." % constants.KUBE_POWER_MANAGER_LABEL))
elif label_key == constants.KUBE_MEMORY_MANAGER_LABEL:
if label_value not in constants.KUBE_MEMORY_MANAGER_VALUES:
raise wsme.exc.ClientSideError(
_(
"Invalid value for %s label." % constants.KUBE_MEMORY_MANAGER_LABEL))
def _get_system_enabled_k8s_plugins():

View File

@ -2112,6 +2112,7 @@ SRIOVDP_LABEL = 'sriovdp=enabled'
KUBE_TOPOLOGY_MANAGER_LABEL = 'kube-topology-mgr-policy'
KUBE_CPU_MANAGER_LABEL = 'kube-cpu-mgr-policy'
KUBE_POWER_MANAGER_LABEL = 'power-management'
KUBE_MEMORY_MANAGER_LABEL = 'kube-memory-mgr-policy'
# Accepted label values
KUBE_TOPOLOGY_MANAGER_VALUES = [
@ -2124,6 +2125,10 @@ KUBE_CPU_MANAGER_VALUES = [
'none',
'static'
]
KUBE_MEMORY_MANAGER_VALUES = [
'None',
'Static'
]
KUBE_POWER_MANAGER_VALUE = 'enabled'
# Default DNS service domain
DEFAULT_DNS_SERVICE_DOMAIN = 'cluster.local'

View File

@ -621,6 +621,8 @@ class KubernetesPuppet(base.BasePuppet):
config.update({'platform::kubernetes::params::k8s_topology_mgr_policy': label.label_value})
elif label.label_key == constants.KUBE_CPU_MANAGER_LABEL:
config.update({'platform::kubernetes::params::k8s_cpu_mgr_policy': label.label_value})
elif label.label_key == constants.KUBE_MEMORY_MANAGER_LABEL:
config.update({'platform::kubernetes::params::k8s_memory_mgr_policy': label.label_value})
config.update(
{'platform::kubernetes::params::k8s_cpuset':