evpa

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0, BSD-2-Clause Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultComponentScaleDownStabWindowSeconds = int32(43200)
	DefaultComponentScaleUpStabWindowSeconds   = int32(150)

	// DefaultScaleDownCPUUtilPercentageThreshold defines the cpu scaledown threshold,
	// If the ratio of actual used cpu resources divided by request resources is less than DefaultScaleDownCPUUtilPercentageThreshold,
	// it will trigger cpu scaledown.
	DefaultScaleDownCPUUtilPercentageThreshold = int32(35)
	// DefaultScaleUpCPUUtilPercentageThreshold defines the cpu scaleup threshold,
	// If the ratio of actual used cpu resources divided by limit resources is greater than DefaultScaleUpCPUUtilPercentageThreshold,
	// it will trigger cpu scaleup.
	DefaultScaleUpCPUUtilPercentageThreshold = int32(95)
	// DefaultScaleDownMemoryUtilPercentageThreshold defines the memory scaledown threshold,
	// If the ratio of actual used memory resources divided by request resources is less than DefaultScaleDownMemoryUtilPercentageThreshold,
	// it will trigger memory scaledown.
	DefaultScaleDownMemoryUtilPercentageThreshold = int32(40)
	// DefaultScaleUpMemoryUtilPercentageThreshold defines the memory scaleup threshold,
	// If the ratio of actual used cpu resources divided by limit resources is greater than DefaultScaleUpCPUUtilPercentageThreshold,
	// it will trigger memory scaleup.
	DefaultScaleUpMemoryUtilPercentageThreshold = int32(95)

	// DefaultStabWindowSeconds defines the cold down seconds between two scaling for one container.
	DefaultStabWindowSeconds = int32(120)

	// DefaultCpuToleranceMilliCores defines the tolerance cpu change when scaling
	DefaultCpuToleranceMilliCores = 100

	// DefaultMemoryToleranceMB defines the tolerance memory change when scaling
	DefaultMemoryToleranceMB = 100 * 1024 * 1024

	// DefaultEVPARsyncPeriod defines the rsync period for EVPA controller
	DefaultEVPARsyncPeriod = time.Second * 60
)
View Source
const (
	EffectiveVPAConditionTypeReady = "Ready"
)

Variables

View Source
var (
	DefaultControlledResources = []autoscalingapi.ResourceName{autoscalingapi.ResourceName("cpu"), autoscalingapi.ResourceName("memory")}
)

Functions

func CalculateResourceByPriority

func CalculateResourceByPriority(resourceLists []corev1.ResourceList) corev1.ResourceList

func CalculateResourceByValue

func CalculateResourceByValue(resourceByValue corev1.ResourceList, resourcesEstimated corev1.ResourceList)

func GetContainerTargetResource added in v0.4.0

func GetContainerTargetResource(recommendation *vpatypes.RecommendedPodResources, containerName string) corev1.ResourceList

func GetEstimatedResourceForContainer

GetEstimatedResourceForContainer iterate resources based on the result from estimator If priority is equal, use the larger resource value If priority is larger, use the larger estimator's value if value is not Zero

func GetResourceUsedRatio

func GetResourceUsedRatio(oldResource, newResource corev1.ResourceList, resourceName corev1.ResourceName) (int32, error)

GetResourceUsedRatio get Resource used ratio from oldResource and newResource

func GetScaleEventKey

func GetScaleEventKey(namespace string, workload string, container string, direction string) string

GetScaleEventKey concat information for scale event key

func IsResourceListEmpty

func IsResourceListEmpty(resourceList corev1.ResourceList) bool

IsResourceListEmpty loop all resource quantities in resourceList, if all resources' quantity are zero, return true, otherwise return false.

func ResourceWithTolerance added in v0.4.0

func ResourceWithTolerance(resource corev1.ResourceList, target corev1.ResourceList)

func ResourceWithToleranceCpu added in v0.4.0

func ResourceWithToleranceCpu(resource corev1.ResourceList, target corev1.ResourceList)

ResourceWithToleranceCpu handle cpu resource with tolerance

func ResourceWithToleranceMemory added in v0.4.0

func ResourceWithToleranceMemory(resource corev1.ResourceList, target corev1.ResourceList)

ResourceWithToleranceMemory handle memory resource with tolerance

func UpdateCurrentEstimatorStatus

func UpdateCurrentEstimatorStatus(estimator estimator.ResourceEstimatorInstance, containerName string, resourceList corev1.ResourceList, currentEstimatorStatus []autoscalingapi.ResourceEstimatorStatus) []autoscalingapi.ResourceEstimatorStatus

func UpdateRecommendStatus

func UpdateRecommendStatus(recommendation *vpatypes.RecommendedPodResources, containerName string, recommendResource corev1.ResourceList)

UpdateRecommendStatus update recommend resource

Types

type EffectiveVPAController

type EffectiveVPAController struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         record.EventRecorder
	OOMRecorder      oom.Recorder
	EstimatorManager estimator.ResourceEstimatorManager

	Predictor     prediction.Interface
	TargetFetcher target.SelectorFetcher
	// contains filtered or unexported fields
}

EffectiveVPAController is responsible for scaling workload's replica based on EffectiveVerticalPodAutoscaler spec

func (*EffectiveVPAController) CheckContainerScalingCondition

func (c *EffectiveVPAController) CheckContainerScalingCondition(evpa *autoscalingapi.EffectiveVerticalPodAutoscaler, containerPolicy autoscalingapi.ContainerResourcePolicy, scalingPolicy *autoscalingapi.ContainerScalingPolicy, direction ScaleDirection, containerResource corev1.ResourceList, recommendContainerResource corev1.ResourceList) (bool, string)

CheckContainerScalingCondition check the conditions for container with scale direction

func (*EffectiveVPAController) CleanLastScaleTime added in v0.4.0

func (*EffectiveVPAController) DeleteLastScaleTime added in v0.4.0

func (c *EffectiveVPAController) DeleteLastScaleTime(namespace string, workload string, container string, direction string)

func (*EffectiveVPAController) GetLastScaleTime

func (c *EffectiveVPAController) GetLastScaleTime(namespace string, workload string, container string, direction string) metav1.Time

func (*EffectiveVPAController) Reconcile

func (c *EffectiveVPAController) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

func (*EffectiveVPAController) ReconcileContainerPolicies

func (c *EffectiveVPAController) ReconcileContainerPolicies(evpa *autoscalingapi.EffectiveVerticalPodAutoscaler, podTemplate *corev1.PodTemplateSpec, resourceEstimators []estimator.ResourceEstimatorInstance) (currentEstimatorStatus []autoscalingapi.ResourceEstimatorStatus, recommendation *vpatypes.RecommendedPodResources, err error)

func (*EffectiveVPAController) SetupWithManager

func (c *EffectiveVPAController) SetupWithManager(mgr ctrl.Manager) error

type ResourceEstimatorInstanceRanked

type ResourceEstimatorInstanceRanked struct {
	Estimators []estimator.ResourceEstimatorInstance
	Priority   int
}

func RankEstimators

func RankEstimators(resourceEstimators []estimator.ResourceEstimatorInstance) []ResourceEstimatorInstanceRanked

RankEstimators return ranked estimator list

type ScaleDirection

type ScaleDirection string
const (
	ScaleUp   ScaleDirection = "ScaleUp"
	ScaleDown ScaleDirection = "ScaleDown"
)

Jump to

Keyboard shortcuts

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