evpa

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 18 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)
)
View Source
const (
	DefaultStabWindowSeconds = int32(120)
)

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 GetEstimatedResourceForContainer

func GetEstimatedResourceForContainer(evpa *autoscalingapi.EffectiveVerticalPodAutoscaler, containerPolicy autoscalingapi.ContainerResourcePolicy, containerResource *corev1.ResourceRequirements, rankedEstimators []ResourceEstimatorInstanceRanked, currentEstimatorStatus []autoscalingapi.ResourceEstimatorStatus) corev1.ResourceList

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 UpdateCurrentEstimatorStatus

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

func UpdateRecommendStatus

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

Types

type EffectiveVPAController

type EffectiveVPAController struct {
	client.Client
	Scheme           *runtime.Scheme
	Recorder         record.EventRecorder
	OOMRecorder      oom.Recorder
	EstimatorManager estimator.ResourceEstimatorManager
	// 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) 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 (*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