resource

package
v0.32.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2025 License: Apache-2.0 Imports: 2 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateContainerLimits

func AggregateContainerLimits(pod *v1.Pod, opts PodResourcesOptions) v1.ResourceList

AggregateContainerLimits computes the aggregated resource limits of all the containers in a pod. This computation follows the formula defined in the KEP for sidecar containers. See https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/753-sidecar-containers#resources-calculation-for-scheduling-and-pod-admission for more details.

func AggregateContainerRequests

func AggregateContainerRequests(pod *v1.Pod, opts PodResourcesOptions) v1.ResourceList

AggregateContainerRequests computes the total resource requests of all the containers in a pod. This computation folows the formula defined in the KEP for sidecar containers. See https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/753-sidecar-containers#resources-calculation-for-scheduling-and-pod-admission for more details.

func IsPodLevelRequestsSet

func IsPodLevelRequestsSet(pod *v1.Pod) bool

IsPodLevelRequestsSet checks if pod-level requests are set. It returns true if Requests map is non-empty.

func IsPodLevelResourcesSet

func IsPodLevelResourcesSet(pod *v1.Pod) bool

IsPodLevelResourcesSet check if PodLevelResources pod-level resources are set. It returns true if either the Requests or Limits maps are non-empty.

func IsSupportedPodLevelResource

func IsSupportedPodLevelResource(name v1.ResourceName) bool

IsSupportedPodLevelResources checks if a given resource is supported by pod-level resource management through the PodLevelResources feature. Returns true if the resource is supported.

func PodLimits

func PodLimits(pod *v1.Pod, opts PodResourcesOptions) v1.ResourceList

PodLimits computes the pod limits per the PodResourcesOptions supplied. If PodResourcesOptions is nil, then the limits are returned including pod overhead for any non-zero limits. The computation is part of the API and must be reviewed as an API change.

func PodRequests

func PodRequests(pod *v1.Pod, opts PodResourcesOptions) v1.ResourceList

PodRequests computes the total pod requests per the PodResourcesOptions supplied. If PodResourcesOptions is nil, then the requests are returned including pod overhead. If the PodLevelResources feature is enabled AND the pod-level resources are set, those pod-level values are used in calculating Pod Requests. The computation is part of the API and must be reviewed as an API change.

func SupportedPodLevelResources

func SupportedPodLevelResources() sets.Set[v1.ResourceName]

Types

type ContainerType

type ContainerType int

ContainerType signifies container type

const (
	// Containers is for normal containers
	Containers ContainerType = 1 << iota
	// InitContainers is for init containers
	InitContainers
)

type PodResourcesOptions

type PodResourcesOptions struct {
	// Reuse, if provided will be reused to accumulate resources and returned by the PodRequests or PodLimits
	// functions. All existing values in Reuse will be lost.
	Reuse v1.ResourceList
	// UseStatusResources indicates whether resources reported by the PodStatus should be considered
	// when evaluating the pod resources. This MUST be false if the InPlacePodVerticalScaling
	// feature is not enabled.
	UseStatusResources bool
	// ExcludeOverhead controls if pod overhead is excluded from the calculation.
	ExcludeOverhead bool
	// ContainerFn is called with the effective resources required for each container within the pod.
	ContainerFn func(res v1.ResourceList, containerType ContainerType)
	// NonMissingContainerRequests if provided will replace any missing container level requests for the specified resources
	// with the given values.  If the requests for those resources are explicitly set, even if zero, they will not be modified.
	NonMissingContainerRequests v1.ResourceList
	// SkipPodLevelResources controls whether pod-level resources should be skipped
	// from the calculation. If pod-level resources are not set in PodSpec,
	// pod-level resources will always be skipped.
	SkipPodLevelResources bool
}

PodResourcesOptions controls the behavior of PodRequests and PodLimits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL