priorities

package
v0.0.0-...-d75b2e9 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// BalancedResourceAllocationMap favors nodes with balanced resource usage rate.
	// BalancedResourceAllocationMap should **NOT** be used alone, and **MUST** be used together
	// with LeastRequestedPriority. It calculates the difference between the cpu and memory fraction
	// of capacity, and prioritizes the host based on how close the two metrics are to each other.
	// Detail: score = 10 - variance(cpuFraction,memoryFraction,volumeFraction)*10. The algorithm is partly inspired by:
	// "Wei Huang et al. An Energy Efficient Virtual Machine Placement Algorithm with Balanced
	// Resource Utilization"
	BalancedResourceAllocationMap = balancedResourcePriority.PriorityMap
)
View Source
var CalculateNodeAffinityPriorityReduce = NormalizeReduce(schedulerapi.MaxPriority, false)

CalculateNodeAffinityPriorityReduce is a reduce function for node affinity priority calculation.

View Source
var ComputeTaintTolerationPriorityReduce = NormalizeReduce(schedulerapi.MaxPriority, true)

ComputeTaintTolerationPriorityReduce calculates the source of each node based on the number of intolerable taints on the node

View Source
var (

	// LeastRequestedPriorityMap is a priority function that favors nodes with fewer requested resources.
	// It calculates the percentage of memory and CPU requested by pods scheduled on the node, and
	// prioritizes based on the minimum of the average of the fraction of requested to capacity.
	//
	// Details:
	// (cpu((capacity-sum(requested))*10/capacity) + memory((capacity-sum(requested))*10/capacity))/2
	LeastRequestedPriorityMap = leastResourcePriority.PriorityMap
)
View Source
var (

	// MostRequestedPriorityMap is a priority function that favors nodes with most requested resources.
	// It calculates the percentage of memory and CPU requested by pods scheduled on the node, and prioritizes
	// based on the maximum of the average of the fraction of requested to capacity.
	// Details: (cpu(10 * sum(requested) / capacity) + memory(10 * sum(requested) / capacity)) / 2
	MostRequestedPriorityMap = mostResourcePriority.PriorityMap
)

Functions

func CalculateNodeAffinityPriorityMap

func CalculateNodeAffinityPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

CalculateNodeAffinityPriorityMap prioritizes nodes according to node affinity scheduling preferences indicated in PreferredDuringSchedulingIgnoredDuringExecution. Each time a node match a preferredSchedulingTerm, it will a get an add of preferredSchedulingTerm.Weight. Thus, the more preferredSchedulingTerms the node satisfies and the more the preferredSchedulingTerm that is satisfied weights, the higher score the node gets.

func CalculateNodePreferAvoidPodsPriorityMap

func CalculateNodePreferAvoidPodsPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

CalculateNodePreferAvoidPodsPriorityMap priorities nodes according to the node annotation "scheduler.alpha.kubernetes.io/preferAvoidPods".

func ComputeTaintTolerationPriorityMap

func ComputeTaintTolerationPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

ComputeTaintTolerationPriorityMap prepares the priority list for all the nodes based on the number of intolerable taints on the node

func ImageLocalityPriorityMap

func ImageLocalityPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

ImageLocalityPriorityMap is a priority function that favors nodes that already have requested pod container's images. It will detect whether the requested images are present on a node, and then calculate a score ranging from 0 to 10 based on the total size of those images. - If none of the images are present, this node will be given the lowest priority. - If some of the images are present on a node, the larger their sizes' sum, the higher the node's priority.

func NewInterPodAffinityPriority

func NewInterPodAffinityPriority(
	info predicates.NodeInfo,
	nodeLister algorithm.NodeLister,
	podLister algorithm.PodLister,
	hardPodAffinityWeight int32) algorithm.PriorityFunction

NewInterPodAffinityPriority creates an InterPodAffinity.

func NewNodeLabelPriority

func NewNodeLabelPriority(label string, presence bool) (algorithm.PriorityMapFunction, algorithm.PriorityReduceFunction)

NewNodeLabelPriority creates a NodeLabelPrioritizer.

func NewPriorityMetadataFactory

func NewPriorityMetadataFactory(serviceLister algorithm.ServiceLister, controllerLister algorithm.ControllerLister, replicaSetLister algorithm.ReplicaSetLister, statefulSetLister algorithm.StatefulSetLister) algorithm.PriorityMetadataProducer

NewPriorityMetadataFactory creates a PriorityMetadataFactory.

func NewSelectorSpreadPriority

func NewSelectorSpreadPriority(
	serviceLister algorithm.ServiceLister,
	controllerLister algorithm.ControllerLister,
	replicaSetLister algorithm.ReplicaSetLister,
	statefulSetLister algorithm.StatefulSetLister) (algorithm.PriorityMapFunction, algorithm.PriorityReduceFunction)

NewSelectorSpreadPriority creates a SelectorSpread.

func NewServiceAntiAffinityPriority

func NewServiceAntiAffinityPriority(podLister algorithm.PodLister, serviceLister algorithm.ServiceLister, label string) (algorithm.PriorityMapFunction, algorithm.PriorityReduceFunction)

NewServiceAntiAffinityPriority creates a ServiceAntiAffinity.

func NormalizeReduce

func NormalizeReduce(maxPriority int, reverse bool) algorithm.PriorityReduceFunction

NormalizeReduce generates a PriorityReduceFunction that can normalize the result scores to [0, maxPriority]. If reverse is set to true, it reverses the scores by subtracting it from maxPriority.

func ResourceLimitsPriorityMap

func ResourceLimitsPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

ResourceLimitsPriorityMap is a priority function that increases score of input node by 1 if the node satisfies input pod's resource limits. In detail, this priority function works as follows: If a node does not publish its allocatable resources (cpu and memory both), the node score is not affected. If a pod does not specify its cpu and memory limits both, the node score is not affected. If one or both of cpu and memory limits of the pod are satisfied, the node is assigned a score of 1. Rationale of choosing the lowest score of 1 is that this is mainly selected to break ties between nodes that have same scores assigned by one of least and most requested priority functions.

Types

type FunctionShape

type FunctionShape []FunctionShapePoint

FunctionShape represents shape of scoring function. For safety use NewFunctionShape which performs precondition checks for struct creation.

func NewFunctionShape

func NewFunctionShape(points []FunctionShapePoint) (FunctionShape, error)

NewFunctionShape creates instance of FunctionShape in a safe way performing all necessary sanity checks.

type FunctionShapePoint

type FunctionShapePoint struct {
	// Utilization is function argument.
	Utilization int64
	// Score is function value.
	Score int64
}

FunctionShapePoint represents single point in scoring function shape.

type InterPodAffinity

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

InterPodAffinity contains information to calculate inter pod affinity.

func (*InterPodAffinity) CalculateInterPodAffinityPriority

func (ipa *InterPodAffinity) CalculateInterPodAffinityPriority(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo, nodes []*v1.Node) (schedulerapi.HostPriorityList, error)

CalculateInterPodAffinityPriority compute a sum by iterating through the elements of weightedPodAffinityTerm and adding "weight" to the sum if the corresponding PodAffinityTerm is satisfied for that node; the node(s) with the highest sum are the most preferred. Symmetry need to be considered for preferredDuringSchedulingIgnoredDuringExecution from podAffinity & podAntiAffinity, symmetry need to be considered for hard requirements from podAffinity

type NodeLabelPrioritizer

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

NodeLabelPrioritizer contains information to calculate node label priority.

func (*NodeLabelPrioritizer) CalculateNodeLabelPriorityMap

func (n *NodeLabelPrioritizer) CalculateNodeLabelPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

CalculateNodeLabelPriorityMap checks whether a particular label exists on a node or not, regardless of its value. If presence is true, prioritizes nodes that have the specified label, regardless of value. If presence is false, prioritizes nodes that do not have the specified label.

type PriorityMetadataFactory

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

PriorityMetadataFactory is a factory to produce PriorityMetadata.

func (*PriorityMetadataFactory) PriorityMetadata

func (pmf *PriorityMetadataFactory) PriorityMetadata(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo) interface{}

PriorityMetadata is a PriorityMetadataProducer. Node info can be nil.

type ResourceAllocationPriority

type ResourceAllocationPriority struct {
	Name string
	// contains filtered or unexported fields
}

ResourceAllocationPriority contains information to calculate resource allocation priority.

func RequestedToCapacityRatioResourceAllocationPriority

func RequestedToCapacityRatioResourceAllocationPriority(scoringFunctionShape FunctionShape) *ResourceAllocationPriority

RequestedToCapacityRatioResourceAllocationPriority creates a requestedToCapacity based ResourceAllocationPriority using provided resource scoring function shape.

func RequestedToCapacityRatioResourceAllocationPriorityDefault

func RequestedToCapacityRatioResourceAllocationPriorityDefault() *ResourceAllocationPriority

RequestedToCapacityRatioResourceAllocationPriorityDefault creates a requestedToCapacity based ResourceAllocationPriority using default resource scoring function shape. The default function assigns 1.0 to resource when all capacity is available and 0.0 when requested amount is equal to capacity.

func (*ResourceAllocationPriority) PriorityMap

func (r *ResourceAllocationPriority) PriorityMap(
	pod *v1.Pod,
	meta interface{},
	nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

PriorityMap priorities nodes according to the resource allocations on the node. It will use `scorer` function to calculate the score.

type SelectorSpread

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

SelectorSpread contains information to calculate selector spread priority.

func (*SelectorSpread) CalculateSpreadPriorityMap

func (s *SelectorSpread) CalculateSpreadPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

CalculateSpreadPriorityMap spreads pods across hosts, considering pods belonging to the same service,RC,RS or StatefulSet. When a pod is scheduled, it looks for services, RCs,RSs and StatefulSets that match the pod, then finds existing pods that match those selectors. It favors nodes that have fewer existing matching pods. i.e. it pushes the scheduler towards a node where there's the smallest number of pods which match the same service, RC,RSs or StatefulSets selectors as the pod being scheduled.

func (*SelectorSpread) CalculateSpreadPriorityReduce

func (s *SelectorSpread) CalculateSpreadPriorityReduce(pod *v1.Pod, meta interface{}, nodeNameToInfo map[string]*schedulercache.NodeInfo, result schedulerapi.HostPriorityList) error

CalculateSpreadPriorityReduce calculates the source of each node based on the number of existing matching pods on the node where zone information is included on the nodes, it favors nodes in zones with fewer existing matching pods.

type ServiceAntiAffinity

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

ServiceAntiAffinity contains information to calculate service anti-affinity priority.

func (*ServiceAntiAffinity) CalculateAntiAffinityPriorityMap

func (s *ServiceAntiAffinity) CalculateAntiAffinityPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

CalculateAntiAffinityPriorityMap spreads pods by minimizing the number of pods belonging to the same service on given machine

func (*ServiceAntiAffinity) CalculateAntiAffinityPriorityReduce

func (s *ServiceAntiAffinity) CalculateAntiAffinityPriorityReduce(pod *v1.Pod, meta interface{}, nodeNameToInfo map[string]*schedulercache.NodeInfo, result schedulerapi.HostPriorityList) error

CalculateAntiAffinityPriorityReduce computes each node score with the same value for a particular label. The label to be considered is provided to the struct (ServiceAntiAffinity).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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