package memorymanager
import "k8s.io/kubernetes/pkg/kubelet/cm/memorymanager"
Index ¶
- Constants
- type ActivePodsFunc
- type Manager
- func NewFakeManager(logger klog.Logger) Manager
- func NewManager(logger klog.Logger, policyName string, machineInfo *cadvisorapi.MachineInfo, nodeAllocatableReservation v1.ResourceList, reservedMemory []kubeletconfig.MemoryReservation, stateFileDirectory string, affinity topologymanager.Store) (Manager, error)
- type Policy
- func NewPolicyBestEffort(logger logr.Logger, machineInfo *cadvisorapi.MachineInfo, reserved systemReservedMemory, affinity topologymanager.Store) (Policy, error)
- func NewPolicyNone(logger klog.Logger) Policy
- func NewPolicyStatic(logger klog.Logger, machineInfo *cadvisorapi.MachineInfo, reserved systemReservedMemory, affinity topologymanager.Store) (Policy, error)
Constants ¶
const PolicyTypeStatic policyType = "Static"
Types ¶
type ActivePodsFunc ¶
ActivePodsFunc is a function that returns a list of active pods
type Manager ¶
type Manager interface {
// Start is called during Kubelet initialization.
Start(ctx context.Context, activePods ActivePodsFunc, sourcesReady config.SourcesReady, podStatusProvider status.PodStatusProvider, containerRuntime runtimeService, initialContainers containermap.ContainerMap) error
// AddContainer adds the mapping between container ID to pod UID and the container name
// The mapping used to remove the memory allocation during the container removal
AddContainer(logger klog.Logger, p *v1.Pod, c *v1.Container, containerID string)
// Allocate is called to pre-allocate memory resources during Pod admission.
// This must be called at some point prior to the AddContainer() call for a container, e.g. at pod admission time.
Allocate(pod *v1.Pod, container *v1.Container) error
// RemoveContainer is called after Kubelet decides to kill or delete a
// container. After this call, any memory allocated to the container is freed.
RemoveContainer(logger klog.Logger, containerID string) error
// State returns a read-only interface to the internal memory manager state.
State() state.Reader
// GetTopologyHints implements the topologymanager.HintProvider Interface
// and is consulted to achieve NUMA aware resource alignment among this
// and other resource controllers.
GetTopologyHints(*v1.Pod, *v1.Container) map[string][]topologymanager.TopologyHint
// GetPodTopologyHints implements the topologymanager.HintProvider Interface
// and is consulted to achieve NUMA aware resource alignment among this
// and other resource controllers.
GetPodTopologyHints(*v1.Pod) map[string][]topologymanager.TopologyHint
// GetMemoryNUMANodes provides NUMA nodes that are used to allocate the container memory
GetMemoryNUMANodes(logger klog.Logger, pod *v1.Pod, container *v1.Container) sets.Set[int]
// GetAllocatableMemory returns the amount of allocatable memory for each NUMA node
GetAllocatableMemory() []state.Block
// GetMemory returns the memory allocated by a container from NUMA nodes
GetMemory(podUID, containerName string) []state.Block
}
Manager interface provides methods for Kubelet to manage pod memory.
func NewFakeManager ¶
func NewFakeManager(logger klog.Logger) Manager
NewFakeManager creates empty/fake memory manager
func NewManager ¶
func NewManager(logger klog.Logger, policyName string, machineInfo *cadvisorapi.MachineInfo, nodeAllocatableReservation v1.ResourceList, reservedMemory []kubeletconfig.MemoryReservation, stateFileDirectory string, affinity topologymanager.Store) (Manager, error)
NewManager returns new instance of the memory manager
type Policy ¶
type Policy interface {
Name() string
Start(logger klog.Logger, s state.State) error
// Allocate call is idempotent
Allocate(logger klog.Logger, s state.State, pod *v1.Pod, container *v1.Container) error
// RemoveContainer call is idempotent
RemoveContainer(logger klog.Logger, s state.State, podUID string, containerName string)
// GetTopologyHints implements the topologymanager.HintProvider Interface
// and is consulted to achieve NUMA aware resource alignment among this
// and other resource controllers.
GetTopologyHints(logger klog.Logger, s state.State, pod *v1.Pod, container *v1.Container) map[string][]topologymanager.TopologyHint
// GetPodTopologyHints implements the topologymanager.HintProvider Interface
// and is consulted to achieve NUMA aware resource alignment among this
// and other resource controllers.
GetPodTopologyHints(logger klog.Logger, s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint
// GetAllocatableMemory returns the amount of allocatable memory for each NUMA node
GetAllocatableMemory(s state.State) []state.Block
}
Policy implements logic for pod container to a memory assignment.
func NewPolicyBestEffort ¶
func NewPolicyBestEffort(logger logr.Logger, machineInfo *cadvisorapi.MachineInfo, reserved systemReservedMemory, affinity topologymanager.Store) (Policy, error)
func NewPolicyNone ¶
func NewPolicyNone(logger klog.Logger) Policy
NewPolicyNone returns new none policy instance
func NewPolicyStatic ¶
func NewPolicyStatic(logger klog.Logger, machineInfo *cadvisorapi.MachineInfo, reserved systemReservedMemory, affinity topologymanager.Store) (Policy, error)
NewPolicyStatic returns new static policy instance
Source Files ¶
fake_memory_manager.go memory_manager.go policy.go policy_best_effort.go policy_none.go policy_static.go
Directories ¶
| Path | Synopsis |
|---|---|
| pkg/kubelet/cm/memorymanager/state |
- Version
- v1.35.1 (latest)
- Published
- Feb 10, 2026
- Platform
- linux/amd64
- Imports
- 26 packages
- Last checked
- 2 months ago –
Tools for package owners.