resource

package
v1.29.9 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 7 Imported by: 202

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractContainerResourceValue

func ExtractContainerResourceValue(fs *v1.ResourceFieldSelector, container *v1.Container) (string, error)

ExtractContainerResourceValue extracts the value of a resource in an already known container

func ExtractResourceValueByContainerName

func ExtractResourceValueByContainerName(fs *v1.ResourceFieldSelector, pod *v1.Pod, containerName string) (string, error)

ExtractResourceValueByContainerName extracts the value of a resource by providing container name

func ExtractResourceValueByContainerNameAndNodeAllocatable

func ExtractResourceValueByContainerNameAndNodeAllocatable(fs *v1.ResourceFieldSelector, pod *v1.Pod, containerName string, nodeAllocatable v1.ResourceList) (string, error)

ExtractResourceValueByContainerNameAndNodeAllocatable extracts the value of a resource by providing container name and node allocatable

func GetResourceRequest

func GetResourceRequest(pod *v1.Pod, resource v1.ResourceName) int64

GetResourceRequest finds and returns the request value for a specific resource.

func GetResourceRequestQuantity added in v1.16.0

func GetResourceRequestQuantity(pod *v1.Pod, resourceName v1.ResourceName) resource.Quantity

GetResourceRequestQuantity finds and returns the request quantity for a specific resource.

func IsHugePageResourceName added in v1.20.0

func IsHugePageResourceName(name v1.ResourceName) bool

IsHugePageResourceName returns true if the resource name has the huge page resource prefix.

func MergeContainerResourceLimits

func MergeContainerResourceLimits(container *v1.Container,
	allocatable v1.ResourceList)

MergeContainerResourceLimits checks if a limit is applied for the container, and if not, it sets the limit to the passed resource list.

func PodLimits added in v1.27.0

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 added in v1.27.0

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

PodRequests computes the pod requests per the PodResourcesOptions supplied. If PodResourcesOptions is nil, then the requests are returned including pod overhead. The computation is part of the API and must be reviewed as an API change.

Types

type PodResourcesOptions added in v1.27.0

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
	// InPlacePodVerticalScalingEnabled indicates that the in-place pod vertical scaling feature gate is enabled.
	InPlacePodVerticalScalingEnabled 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 podutil.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
}

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