estimator

package
v0.0.0-...-3fd892a Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 15

Documentation

Index

Constants

View Source
const (
	// BinpackingEstimatorName is the name of binpacking estimator.
	BinpackingEstimatorName = "binpacking"
)

Variables

View Source
var AvailableEstimators = []string{BinpackingEstimatorName}

AvailableEstimators is a list of available estimators.

Functions

This section is empty.

Types

type BinpackingNodeEstimator

type BinpackingNodeEstimator struct {
	// contains filtered or unexported fields
}

BinpackingNodeEstimator estimates the number of needed nodes to handle the given amount of pods.

func NewBinpackingNodeEstimator

func NewBinpackingNodeEstimator(
	predicateChecker predicatechecker.PredicateChecker,
	clusterSnapshot clustersnapshot.ClusterSnapshot,
	limiter EstimationLimiter,
	podOrderer EstimationPodOrderer,
	context EstimationContext,
	estimationAnalyserFunc EstimationAnalyserFunc,
) *BinpackingNodeEstimator

NewBinpackingNodeEstimator builds a new BinpackingNodeEstimator.

func (*BinpackingNodeEstimator) Estimate

func (e *BinpackingNodeEstimator) Estimate(
	podsEquivalenceGroups []PodEquivalenceGroup,
	nodeTemplate *schedulerframework.NodeInfo,
	nodeGroup cloudprovider.NodeGroup,
) (int, []*apiv1.Pod)

Estimate implements First-Fit bin-packing approximation algorithm The ordering of the pods depend on the EstimatePodOrderer, the default order is DecreasingPodOrderer First-Fit Decreasing bin-packing approximation algorithm. See https://en.wikipedia.org/wiki/Bin_packing_problem for more details. While it is a multi-dimensional bin packing (cpu, mem, ports) in most cases the main dimension will be cpu thus the estimated overprovisioning of 11/9 * optimal + 6/9 should be still be maintained. It is assumed that all pods from the given list can fit to nodeTemplate. Returns the number of nodes needed to accommodate all pods from the list.

type DecreasingPodOrderer

type DecreasingPodOrderer struct {
}

DecreasingPodOrderer is the default implementation of the EstimationPodOrderer It implements sorting pods by pod score in decreasing order

func NewDecreasingPodOrderer

func NewDecreasingPodOrderer() *DecreasingPodOrderer

NewDecreasingPodOrderer returns the object of DecreasingPodOrderer

func (*DecreasingPodOrderer) Order

func (d *DecreasingPodOrderer) Order(podsEquivalentGroups []PodEquivalenceGroup, nodeTemplate *framework.NodeInfo, _ cloudprovider.NodeGroup) []PodEquivalenceGroup

Order is the processing func that sorts the pods based on the size of the pod

type EstimationAnalyserFunc

type EstimationAnalyserFunc func(clustersnapshot.ClusterSnapshot, cloudprovider.NodeGroup, map[string]bool)

EstimationAnalyserFunc to be run at the end of the estimation logic.

type EstimationContext

type EstimationContext interface {
	SimilarNodeGroups() []cloudprovider.NodeGroup
	ClusterMaxNodeLimit() int
	CurrentNodeCount() int
}

EstimationContext stores static and runtime state of autoscaling, used by Estimator

func NewEstimationContext

func NewEstimationContext(clusterMaxNodeLimit int, similarNodeGroups []cloudprovider.NodeGroup, currentNodeCount int) EstimationContext

NewEstimationContext creates a patch for estimation context with runtime properties. This patch is used to update existing context.

type EstimationLimiter

type EstimationLimiter interface {
	// StartEstimation is called at the start of estimation.
	StartEstimation([]PodEquivalenceGroup, cloudprovider.NodeGroup, EstimationContext)
	// EndEstimation is called at the end of estimation.
	EndEstimation()
	// PermissionToAddNode is called by an estimator when it wants to add additional
	// nodes to simulation. If permission is not granted the Estimator is expected
	// not to add any more nodes in this simulation.
	// There is no requirement for the Estimator to stop calculations, it's
	// just not expected to add any more nodes.
	PermissionToAddNode() bool
}

EstimationLimiter controls how many nodes can be added by Estimator. A limiter can be used to prevent costly estimation if an actual ability to scale-up is limited by external factors.

func NewThresholdBasedEstimationLimiter

func NewThresholdBasedEstimationLimiter(thresholds []Threshold) EstimationLimiter

NewThresholdBasedEstimationLimiter returns an EstimationLimiter that will prevent estimation after either a node count of time-based threshold is reached. This is meant to prevent cases where binpacking of hundreds or thousands of nodes takes extremely long time rendering CA incredibly slow or even completely crashing it. Thresholds may return:

  • negative value: no new nodes are allowed to be added if at least one threshold returns negative limit
  • 0: no limit, thresholds with no limits will be ignored in favor of thresholds with positive or negative limits
  • positive value: new nodes can be added and this value represents the limit

type EstimationPodOrderer

type EstimationPodOrderer interface {
	Order(podsEquivalentGroups []PodEquivalenceGroup, nodeTemplate *framework.NodeInfo, nodeGroup cloudprovider.NodeGroup) []PodEquivalenceGroup
}

EstimationPodOrderer is an interface used to determine the order of the pods used while binpacking during scale up estimation

type Estimator

type Estimator interface {
	// Estimate estimates how many nodes are needed to provision pods coming from the given equivalence groups.
	Estimate([]PodEquivalenceGroup, *schedulerframework.NodeInfo, cloudprovider.NodeGroup) (int, []*apiv1.Pod)
}

Estimator calculates the number of nodes of given type needed to schedule pods. It returns the number of new nodes needed as well as the list of pods it managed to schedule on those nodes.

type EstimatorBuilder

EstimatorBuilder creates a new estimator object.

func NewEstimatorBuilder

func NewEstimatorBuilder(name string, limiter EstimationLimiter, orderer EstimationPodOrderer, estimationAnalyserFunc EstimationAnalyserFunc) (EstimatorBuilder, error)

NewEstimatorBuilder creates a new estimator object from flag.

type PodEquivalenceGroup

type PodEquivalenceGroup struct {
	Pods []*apiv1.Pod
}

PodEquivalenceGroup represents a group of pods, which have the same scheduling requirements and are managed by the same controller.

func (*PodEquivalenceGroup) Exemplar

func (p *PodEquivalenceGroup) Exemplar() *apiv1.Pod

Exemplar returns an example pod from the group.

type Threshold

type Threshold interface {
	NodeLimit(cloudprovider.NodeGroup, EstimationContext) int
	DurationLimit(cloudprovider.NodeGroup, EstimationContext) time.Duration
}

Threshold provides resources configuration for threshold based estimation limiter. Return value of 0 means that no limit is set.

func NewClusterCapacityThreshold

func NewClusterCapacityThreshold() Threshold

NewClusterCapacityThreshold returns a Threshold that can be used to limit binpacking by available cluster capacity

func NewSngCapacityThreshold

func NewSngCapacityThreshold() Threshold

NewSngCapacityThreshold returns a Threshold that can be used to limit binpacking by available capacity of similar node groups

func NewStaticThreshold

func NewStaticThreshold(maxNodes int, maxDuration time.Duration) Threshold

NewStaticThreshold returns a Threshold that should be used to limit result and duration of binpacking by given static values

Jump to

Keyboard shortcuts

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