api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 22 Imported by: 83

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyVPAPolicy

ApplyVPAPolicy returns a recommendation, adjusted to obey policy.

func CreateOrUpdateVpaCheckpoint

func CreateOrUpdateVpaCheckpoint(vpaCheckpointClient vpa_api.VerticalPodAutoscalerCheckpointInterface,
	vpaCheckpoint *vpa_types.VerticalPodAutoscalerCheckpoint) error

CreateOrUpdateVpaCheckpoint updates the status field of the VPA Checkpoint API object. If object doesn't exits it is created.

func GetBoundaryRequest

func GetBoundaryRequest(resourceName core.ResourceName, originalRequest, originalLimit, boundaryLimit, defaultLimit *resource.Quantity) *resource.Quantity

GetBoundaryRequest returns the boundary (min/max) request that can be specified with preserving the original limit to request ratio. Returns nil if no boundary exists

func GetContainerControlledValues

func GetContainerControlledValues(name string, vpaResourcePolicy *vpa_types.PodResourcePolicy) vpa_types.ContainerControlledValues

GetContainerControlledValues returns controlled resource values

func GetContainerResourcePolicy

func GetContainerResourcePolicy(containerName string, policy *vpa_types.PodResourcePolicy) *vpa_types.ContainerResourcePolicy

GetContainerResourcePolicy returns the ContainerResourcePolicy for a given policy and container name. It returns nil if there is no policy specified for the container.

func GetProportionalLimit

func GetProportionalLimit(originalLimit, originalRequest, recommendation, defaultLimit core.ResourceList) (core.ResourceList, []string)

GetProportionalLimit returns limit that will be in the same proportion to recommended request as original limit had to original request.

func GetRecommendationForContainer

func GetRecommendationForContainer(containerName string, recommendation *vpa_types.RecommendedPodResources) *vpa_types.RecommendedContainerResources

GetRecommendationForContainer returns recommendation for given container name

func GetUpdateMode

GetUpdateMode returns the updatePolicy.updateMode for a given VPA. If the mode is not specified it returns the default (UpdateModeAuto).

func NewVpasLister

func NewVpasLister(vpaClient *vpa_clientset.Clientset, stopChannel <-chan struct{}, namespace string) vpa_lister.VerticalPodAutoscalerLister

NewVpasLister returns VerticalPodAutoscalerLister configured to fetch all VPA objects from namespace, set namespace to k8sapiv1.NamespaceAll to select all namespaces. The method blocks until vpaLister is initially populated.

func PodLabelsMatchVPA

func PodLabelsMatchVPA(podNamespace string, labels labels.Set, vpaNamespace string, vpaSelector labels.Selector) bool

PodLabelsMatchVPA returns true iff the vpaWithSelector matches the pod labels.

func PodMatchesVPA

func PodMatchesVPA(pod *core.Pod, vpaWithSelector *VpaWithSelector) bool

PodMatchesVPA returns true iff the vpaWithSelector matches the Pod.

func UpdateVpaStatusIfNeeded

func UpdateVpaStatusIfNeeded(vpaClient vpa_api.VerticalPodAutoscalerInterface, vpaName string, newStatus,
	oldStatus *vpa_types.VerticalPodAutoscalerStatus) (result *vpa_types.VerticalPodAutoscaler, err error)

UpdateVpaStatusIfNeeded updates the status field of the VPA API object.

Types

type ContainerResources

type ContainerResources struct {
	Limits   core.ResourceList
	Requests core.ResourceList
}

ContainerResources holds resources request for container

func (*ContainerResources) RemoveEmptyResourceKeyIfAny added in v1.0.0

func (cr *ContainerResources) RemoveEmptyResourceKeyIfAny() bool

RemoveEmptyResourceKeyIfAny ensure that we are not pushing a resource with an empty key. Return true if an empty key was eliminated

type ContainerToAnnotationsMap

type ContainerToAnnotationsMap = map[string][]string

ContainerToAnnotationsMap contains annotations per container.

type RecommendationProcessor

type RecommendationProcessor interface {
	// Apply processes and updates recommendation for given pod, based on container limits,
	// VPA policy and possibly other internal RecommendationProcessor context.
	// Must return a non-nil pointer to RecommendedPodResources or error.
	Apply(podRecommendation *vpa_types.RecommendedPodResources,
		policy *vpa_types.PodResourcePolicy,
		conditions []vpa_types.VerticalPodAutoscalerCondition,
		pod *v1.Pod) (*vpa_types.RecommendedPodResources, ContainerToAnnotationsMap, error)
}

RecommendationProcessor post-processes recommendation adjusting it to limits and environment context

func NewCappingRecommendationProcessor

func NewCappingRecommendationProcessor(limitsRangeCalculator limitrange.LimitRangeCalculator) RecommendationProcessor

NewCappingRecommendationProcessor constructs new RecommendationsProcessor that adjusts recommendation for given pod to obey VPA resources policy and container limits

func NewSequentialProcessor

func NewSequentialProcessor(processors []RecommendationProcessor) RecommendationProcessor

NewSequentialProcessor constructs RecommendationProcessor that will use provided RecommendationProcessor objects

type VpaWithSelector

type VpaWithSelector struct {
	Vpa      *vpa_types.VerticalPodAutoscaler
	Selector labels.Selector
}

VpaWithSelector is a pair of VPA and its selector.

func GetControllingVPAForPod

func GetControllingVPAForPod(pod *core.Pod, vpas []*VpaWithSelector, ctrlFetcher controllerfetcher.ControllerFetcher) *VpaWithSelector

GetControllingVPAForPod chooses the earliest created VPA from the input list that matches the given Pod.

Jump to

Keyboard shortcuts

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