kubernetesk8s.io/kubernetes/pkg/kubelet/allocation Index | Files | Directories

package allocation

import "k8s.io/kubernetes/pkg/kubelet/allocation"

Package allocation handles tracking pod resource allocations.

Index

Functions

func IsInPlacePodVerticalScalingAllowed

func IsInPlacePodVerticalScalingAllowed(_ *v1.Pod) (allowed bool, msg string)

Types

type Manager

type Manager interface {
	// GetContainerResourceAllocation returns the AllocatedResources value for the container
	GetContainerResourceAllocation(podUID types.UID, containerName string) (v1.ResourceRequirements, bool)

	// UpdatePodFromAllocation overwrites the pod spec with the allocation.
	// This function does a deep copy only if updates are needed.
	// Returns the updated (or original) pod, and whether there was an allocation stored.
	UpdatePodFromAllocation(pod *v1.Pod) (*v1.Pod, bool)

	// SetAllocatedResources checkpoints the resources allocated to a pod's containers.
	SetAllocatedResources(allocatedPod *v1.Pod) error

	// SetActuatedResources records the actuated resources of the given container (or the entire
	// pod, if actuatedContainer is nil).
	SetActuatedResources(allocatedPod *v1.Pod, actuatedContainer *v1.Container) error

	// GetActuatedResources returns the stored actuated resources for the container, and whether they exist.
	GetActuatedResources(podUID types.UID, containerName string) (v1.ResourceRequirements, bool)

	// AddPodAdmitHandlers adds the admit handlers to the allocation manager.
	// TODO: See if we can remove this and just add them in the allocation manager constructor.
	AddPodAdmitHandlers(handlers lifecycle.PodAdmitHandlers)

	// AddPod checks if a pod can be admitted. If so, it admits the pod and updates the allocation.
	// The function returns a boolean value indicating whether the pod
	// can be admitted, a brief single-word reason and a message explaining why
	// the pod cannot be admitted.
	// allocatedPods should represent the pods that have already been admitted, along with their
	// admitted (allocated) resources.
	AddPod(activePods []*v1.Pod, pod *v1.Pod) (ok bool, reason, message string)

	// RemovePod removes any stored state for the given pod UID.
	RemovePod(uid types.UID)

	// RemoveOrphanedPods removes the stored state for any pods not included in the set of remaining pods.
	RemoveOrphanedPods(remainingPods sets.Set[types.UID])

	// HandlePodResourcesResize returns the "allocated pod", which should be used for all resource
	// calculations after this function is called. It also updates the cached ResizeStatus according to
	// the allocation decision and pod status.
	HandlePodResourcesResize(runtime kubecontainer.Runtime, allocatedPods []*v1.Pod, pod *v1.Pod, podStatus *kubecontainer.PodStatus) (*v1.Pod, error)
}

AllocationManager tracks pod resource allocations.

func NewInMemoryManager

func NewInMemoryManager(containerManager cm.ContainerManager, statusManager status.Manager) Manager

NewInMemoryManager returns an allocation manager that doesn't persist state. For testing purposes only!

func NewManager

func NewManager(checkpointDirectory string, containerManager cm.ContainerManager, statusManager status.Manager) Manager

Source Files

allocation_manager.go doc.go features_windows.go

Directories

PathSynopsis
pkg/kubelet/allocation/state
Version
v1.34.0-alpha.3
Published
Jul 9, 2025
Platform
windows/amd64
Imports
21 packages
Last checked
6 minutes ago

Tools for package owners.