kubernetesk8s.io/kubernetes/pkg/kubelet/cm/cpumanager Index | Files | Directories

package cpumanager

import "k8s.io/kubernetes/pkg/kubelet/cm/cpumanager"

Index

Constants

const (
	FullPCPUsOnlyOption            string = "full-pcpus-only"
	DistributeCPUsAcrossNUMAOption string = "distribute-cpus-across-numa"
)
const (

	// PolicyStatic is the name of the static policy.
	// Should options be given, these will be ignored and backward (up to 1.21 included)
	// compatible behaviour will be enforced
	PolicyStatic policyName = "static"
	// ErrorSMTAlignment represents the type of an SMTAlignmentError
	ErrorSMTAlignment = "SMTAlignmentError"
)
const PolicyNone policyName = "none"

PolicyNone name of none policy

Functions

func CheckPolicyOptionAvailable

func CheckPolicyOptionAvailable(option string) error

Types

type ActivePodsFunc

type ActivePodsFunc func() []*v1.Pod

ActivePodsFunc is a function that returns a list of pods to reconcile.

type LoopControl

type LoopControl int
const (
	Continue LoopControl = iota
	Break
)

type Manager

type Manager interface {
	// Start is called during Kubelet initialization.
	Start(activePods ActivePodsFunc, sourcesReady config.SourcesReady, podStatusProvider status.PodStatusProvider, containerRuntime runtimeService, initialContainers containermap.ContainerMap) error

	// Called to trigger the allocation of CPUs to a container. 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

	// AddContainer adds the mapping between container ID to pod UID and the container name
	// The mapping used to remove the CPU allocation during the container removal
	AddContainer(p *v1.Pod, c *v1.Container, containerID string)

	// RemoveContainer is called after Kubelet decides to kill or delete a
	// container. After this call, the CPU manager stops trying to reconcile
	// that container and any CPUs dedicated to the container are freed.
	RemoveContainer(containerID string) error

	// State returns a read-only interface to the internal CPU 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

	// GetExclusiveCPUs implements the podresources.CPUsProvider interface to provide
	// exclusively allocated cpus for the container
	GetExclusiveCPUs(podUID, containerName string) cpuset.CPUSet

	// GetPodTopologyHints implements the topologymanager.HintProvider Interface
	// and is consulted to achieve NUMA aware resource alignment per Pod
	// among this and other resource controllers.
	GetPodTopologyHints(pod *v1.Pod) map[string][]topologymanager.TopologyHint

	// GetAllocatableCPUs returns the total set of CPUs available for allocation.
	GetAllocatableCPUs() cpuset.CPUSet

	// GetCPUAffinity returns cpuset which includes cpus from shared pools
	// as well as exclusively allocated cpus
	GetCPUAffinity(podUID, containerName string) cpuset.CPUSet
}

Manager interface provides methods for Kubelet to manage pod cpus.

func NewFakeManager

func NewFakeManager() Manager

NewFakeManager creates empty/fake cpu manager

func NewManager

func NewManager(cpuPolicyName string, cpuPolicyOptions map[string]string, reconcilePeriod time.Duration, machineInfo *cadvisorapi.MachineInfo, specificCPUs cpuset.CPUSet, nodeAllocatableReservation v1.ResourceList, stateFileDirectory string, affinity topologymanager.Store) (Manager, error)

NewManager creates new cpu manager based on provided policy

type Policy

type Policy interface {
	Name() string
	Start(s state.State) error
	// Allocate call is idempotent
	Allocate(s state.State, pod *v1.Pod, container *v1.Container) error
	// RemoveContainer call is idempotent
	RemoveContainer(s state.State, podUID string, containerName string) error
	// GetTopologyHints implements the topologymanager.HintProvider Interface
	// and is consulted to achieve NUMA aware resource alignment among this
	// and other resource controllers.
	GetTopologyHints(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 per Pod
	// among this and other resource controllers.
	GetPodTopologyHints(s state.State, pod *v1.Pod) map[string][]topologymanager.TopologyHint
	// GetAllocatableCPUs returns the total set of CPUs available for allocation.
	GetAllocatableCPUs(m state.State) cpuset.CPUSet
}

Policy implements logic for pod container to CPU assignment.

func NewNonePolicy

func NewNonePolicy(cpuPolicyOptions map[string]string) (Policy, error)

NewNonePolicy returns a cpuset manager policy that does nothing

func NewStaticPolicy

func NewStaticPolicy(topology *topology.CPUTopology, numReservedCPUs int, reservedCPUs cpuset.CPUSet, affinity topologymanager.Store, cpuPolicyOptions map[string]string) (Policy, error)

NewStaticPolicy returns a CPU manager policy that does not change CPU assignments for exclusively pinned guaranteed containers after the main container process starts.

type SMTAlignmentError

type SMTAlignmentError struct {
	RequestedCPUs int
	CpusPerCore   int
}

SMTAlignmentError represents an error due to SMT alignment

func (SMTAlignmentError) Error

func (e SMTAlignmentError) Error() string

func (SMTAlignmentError) Type

func (e SMTAlignmentError) Type() string

type StaticPolicyOptions

type StaticPolicyOptions struct {
	// flag to enable extra allocation restrictions to avoid
	// different containers to possibly end up on the same core.
	// we consider "core" and "physical CPU" synonim here, leaning
	// towards the terminoloy k8s hints. We acknowledge this is confusing.
	//
	// looking at https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/,
	// any possible naming scheme will lead to ambiguity to some extent.
	// We picked "pcpu" because it the established docs hints at vCPU already.
	FullPhysicalCPUsOnly bool
	// Flag to evenly distribute CPUs across NUMA nodes in cases where more
	// than one NUMA node is required to satisfy the allocation.
	DistributeCPUsAcrossNUMA bool
}

func NewStaticPolicyOptions

func NewStaticPolicyOptions(policyOptions map[string]string) (StaticPolicyOptions, error)

Source Files

cpu_assignment.go cpu_manager.go fake_cpu_manager.go policy.go policy_none.go policy_options.go policy_static.go

Directories

PathSynopsis
pkg/kubelet/cm/cpumanager/state
pkg/kubelet/cm/cpumanager/state/testing
pkg/kubelet/cm/cpumanager/topologyPackage topology contains helpers for the CPU manager.
Version
v1.24.14
Published
May 17, 2023
Platform
js/wasm
Imports
24 packages
Last checked
14 minutes ago

Tools for package owners.