priorities

package
v1.17.17 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EqualPriority defines the name of prioritizer function that gives an equal weight of one to all nodes.
	EqualPriority = "EqualPriority"
	// MostRequestedPriority defines the name of prioritizer function that gives used nodes higher priority.
	MostRequestedPriority = "MostRequestedPriority"
	// RequestedToCapacityRatioPriority defines the name of RequestedToCapacityRatioPriority.
	RequestedToCapacityRatioPriority = "RequestedToCapacityRatioPriority"
	// SelectorSpreadPriority defines the name of prioritizer function that spreads pods by minimizing
	// the number of pods (belonging to the same service or replication controller) on the same node.
	SelectorSpreadPriority = "SelectorSpreadPriority"
	// ServiceSpreadingPriority is largely replaced by "SelectorSpreadPriority".
	ServiceSpreadingPriority = "ServiceSpreadingPriority"
	// InterPodAffinityPriority defines the name of prioritizer function that decides which pods should or
	// should not be placed in the same topological domain as some other pods.
	InterPodAffinityPriority = "InterPodAffinityPriority"
	// LeastRequestedPriority defines the name of prioritizer function that prioritize nodes by least
	// requested utilization.
	LeastRequestedPriority = "LeastRequestedPriority"
	// BalancedResourceAllocation defines the name of prioritizer function that prioritizes nodes
	// to help achieve balanced resource usage.
	BalancedResourceAllocation = "BalancedResourceAllocation"
	// NodePreferAvoidPodsPriority defines the name of prioritizer function that priorities nodes according to
	// the node annotation "scheduler.alpha.kubernetes.io/preferAvoidPods".
	NodePreferAvoidPodsPriority = "NodePreferAvoidPodsPriority"
	// NodeAffinityPriority defines the name of prioritizer function that prioritizes nodes which have labels
	// matching NodeAffinity.
	NodeAffinityPriority = "NodeAffinityPriority"
	// TaintTolerationPriority defines the name of prioritizer function that prioritizes nodes that marked
	// with taint which pod can tolerate.
	TaintTolerationPriority = "TaintTolerationPriority"
	// ImageLocalityPriority defines the name of prioritizer function that prioritizes nodes that have images
	// requested by the pod present.
	ImageLocalityPriority = "ImageLocalityPriority"
	// ResourceLimitsPriority defines the nodes of prioritizer function ResourceLimitsPriority.
	ResourceLimitsPriority = "ResourceLimitsPriority"
	// EvenPodsSpreadPriority defines the name of prioritizer function that prioritizes nodes
	// which have pods and labels matching the incoming pod's topologySpreadConstraints.
	EvenPodsSpreadPriority = "EvenPodsSpreadPriority"
)

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(framework.MaxNodeScore, false)

CalculateNodeAffinityPriorityReduce is a reduce function for node affinity priority calculation.

View Source
var ComputeTaintTolerationPriorityReduce = NormalizeReduce(framework.MaxNodeScore, true)

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

View Source
var DefaultRequestedRatioResources = ResourceToWeightMap{v1.ResourceMemory: 1, v1.ResourceCPU: 1}

DefaultRequestedRatioResources is used to set default requestToWeight map for CPU and memory

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 CalculateEvenPodsSpreadPriorityMap added in v1.17.0

func CalculateEvenPodsSpreadPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)

CalculateEvenPodsSpreadPriorityMap calculate the number of matching pods on the passed-in "node", and return the number as Score.

func CalculateEvenPodsSpreadPriorityReduce added in v1.17.0

func CalculateEvenPodsSpreadPriorityReduce(pod *v1.Pod, meta interface{}, sharedLister schedulerlisters.SharedLister,
	result framework.NodeScoreList) error

CalculateEvenPodsSpreadPriorityReduce normalizes the score for each filteredNode, The basic rule is: the bigger the score(matching number of pods) is, the smaller the final normalized score will be.

func CalculateInterPodAffinityPriorityMap added in v1.17.0

func CalculateInterPodAffinityPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)

CalculateInterPodAffinityPriorityMap calculate the number of matching pods on the passed-in "node", and return the number as Score.

func CalculateInterPodAffinityPriorityReduce added in v1.17.0

func CalculateInterPodAffinityPriorityReduce(pod *v1.Pod, meta interface{}, sharedLister schedulerlisters.SharedLister,
	result framework.NodeScoreList) error

CalculateInterPodAffinityPriorityReduce normalizes the score for each filteredNode, The basic rule is: the bigger the score(matching number of pods) is, the smaller the final normalized score will be.

func CalculateNodeAffinityPriorityMap

func CalculateNodeAffinityPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)

CalculateNodeAffinityPriorityMap prioritizes nodes according to node affinity scheduling preferences indicated in PreferredDuringSchedulingIgnoredDuringExecution. Each time a node matches a preferredSchedulingTerm, it will 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 *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)

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

func ComputeTaintTolerationPriorityMap

func ComputeTaintTolerationPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)

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

func EmptyMetadataProducer added in v1.17.0

func EmptyMetadataProducer(pod *v1.Pod, filteredNodes []*v1.Node, sharedLister schedulerlisters.SharedLister) interface{}

EmptyMetadataProducer returns a no-op MetadataProducer type.

func ImageLocalityPriorityMap

func ImageLocalityPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, 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 NewNodeLabelPriority

func NewNodeLabelPriority(presentLabelsPreference []string, absentLabelsPreference []string) (PriorityMapFunction, PriorityReduceFunction)

NewNodeLabelPriority creates a NodeLabelPrioritizer.

func NewSelectorSpreadPriority

func NewSelectorSpreadPriority(
	serviceLister corelisters.ServiceLister,
	controllerLister corelisters.ReplicationControllerLister,
	replicaSetLister appslisters.ReplicaSetLister,
	statefulSetLister appslisters.StatefulSetLister) (PriorityMapFunction, PriorityReduceFunction)

NewSelectorSpreadPriority creates a SelectorSpread.

func NewServiceAntiAffinityPriority

func NewServiceAntiAffinityPriority(podLister schedulerlisters.PodLister, serviceLister corelisters.ServiceLister, labels []string) (PriorityMapFunction, PriorityReduceFunction)

NewServiceAntiAffinityPriority creates a ServiceAntiAffinity.

func ResourceLimitsPriorityMap

func ResourceLimitsPriorityMap(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, 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 added in v1.11.0

type FunctionShape []FunctionShapePoint

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

func NewFunctionShape added in v1.11.0

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

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

type FunctionShapePoint added in v1.11.0

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

FunctionShapePoint represents single point in scoring function shape.

type MetadataFactory added in v1.17.0

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

MetadataFactory is a factory to produce PriorityMetadata.

func (*MetadataFactory) PriorityMetadata added in v1.17.0

func (pmf *MetadataFactory) PriorityMetadata(
	pod *v1.Pod,
	filteredNodes []*v1.Node,
	sharedLister schedulerlisters.SharedLister,
) interface{}

PriorityMetadata is a MetadataProducer. Node info can be nil.

type MetadataProducer added in v1.17.0

type MetadataProducer func(pod *v1.Pod, filteredNodes []*v1.Node, sharedLister schedulerlisters.SharedLister) interface{}

MetadataProducer is a function that computes metadata for a given pod. This is now used for only for priority functions. For predicates please use PredicateMetadataProducer.

func NewMetadataFactory added in v1.17.0

func NewMetadataFactory(
	serviceLister corelisters.ServiceLister,
	controllerLister corelisters.ReplicationControllerLister,
	replicaSetLister appslisters.ReplicaSetLister,
	statefulSetLister appslisters.StatefulSetLister,
	hardPodAffinityWeight int32,
) MetadataProducer

NewMetadataFactory creates a MetadataFactory.

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 *schedulernodeinfo.NodeInfo) (framework.NodeScore, 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 PriorityConfig added in v1.14.0

type PriorityConfig struct {
	Name   string
	Map    PriorityMapFunction
	Reduce PriorityReduceFunction
	Weight int64
}

PriorityConfig is a config used for a priority function.

type PriorityMapFunction added in v1.14.0

type PriorityMapFunction func(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)

PriorityMapFunction is a function that computes per-node results for a given node. TODO: Figure out the exact API of this method. TODO: Change interface{} to a specific type.

type PriorityReduceFunction added in v1.14.0

type PriorityReduceFunction func(pod *v1.Pod, meta interface{}, sharedLister schedulerlisters.SharedLister, result framework.NodeScoreList) error

PriorityReduceFunction is a function that aggregated per-node results and computes final scores for all nodes. TODO: Figure out the exact API of this method. TODO: Change interface{} to a specific type.

func NormalizeReduce

func NormalizeReduce(maxPriority int64, reverse bool) 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.

type ResourceAllocationPriority

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

ResourceAllocationPriority contains information to calculate resource allocation priority.

func RequestedToCapacityRatioResourceAllocationPriority added in v1.11.0

func RequestedToCapacityRatioResourceAllocationPriority(scoringFunctionShape FunctionShape, resourceToWeightMap ResourceToWeightMap) *ResourceAllocationPriority

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

func RequestedToCapacityRatioResourceAllocationPriorityDefault added in v1.11.0

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 *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)

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

type ResourceToValueMap added in v1.16.0

type ResourceToValueMap map[v1.ResourceName]int64

ResourceToValueMap contains resource name and score.

type ResourceToWeightMap added in v1.16.0

type ResourceToWeightMap map[v1.ResourceName]int64

ResourceToWeightMap contains resource name and weight.

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 *schedulernodeinfo.NodeInfo) (framework.NodeScore, 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{}, sharedLister schedulerlisters.SharedLister, result framework.NodeScoreList) 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 *schedulernodeinfo.NodeInfo) (framework.NodeScore, 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{}, sharedLister schedulerlisters.SharedLister, result framework.NodeScoreList) 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