component-helpersk8s.io/component-helpers/resource Index | Files

package resource

import "k8s.io/component-helpers/resource"

Index

Functions

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 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 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
	// 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 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.

Source Files

helpers.go

Version
v0.32.0-beta.0
Published
Nov 6, 2024
Platform
js/wasm
Imports
1 packages
Last checked
49 minutes ago

Tools for package owners.