priorities

package
v1.14.6-k3s.1 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: Apache-2.0 Imports: 20 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"
)

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

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

func EmptyPriorityMetadataProducer

func EmptyPriorityMetadataProducer(pod *v1.Pod, nodeNameToInfo map[string]*schedulernodeinfo.NodeInfo) interface{}

EmptyPriorityMetadataProducer returns a no-op PriorityMetadataProducer type.

func ImageLocalityPriorityMap

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

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

NewNodeLabelPriority creates a NodeLabelPrioritizer.

func NewSelectorSpreadPriority

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

NewSelectorSpreadPriority creates a SelectorSpread.

func NewServiceAntiAffinityPriority

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

NewServiceAntiAffinityPriority creates a ServiceAntiAffinity.

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]*schedulernodeinfo.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 *schedulernodeinfo.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 PriorityConfig

type PriorityConfig struct {
	Name   string
	Map    PriorityMapFunction
	Reduce PriorityReduceFunction
	// TODO: Remove it after migrating all functions to
	// Map-Reduce pattern.
	Function PriorityFunction
	Weight   int
}

PriorityConfig is a config used for a priority function.

type PriorityFunction

type PriorityFunction func(pod *v1.Pod, nodeNameToInfo map[string]*schedulernodeinfo.NodeInfo, nodes []*v1.Node) (schedulerapi.HostPriorityList, error)

PriorityFunction is a function that computes scores for all nodes. DEPRECATED Use Map-Reduce pattern for priority functions.

func NewInterPodAffinityPriority

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

NewInterPodAffinityPriority creates an InterPodAffinity.

type PriorityMapFunction

type PriorityMapFunction func(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (schedulerapi.HostPriority, 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 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]*schedulernodeinfo.NodeInfo) interface{}

PriorityMetadata is a PriorityMetadataProducer. Node info can be nil.

type PriorityMetadataProducer

type PriorityMetadataProducer func(pod *v1.Pod, nodeNameToInfo map[string]*schedulernodeinfo.NodeInfo) interface{}

PriorityMetadataProducer 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 NewPriorityMetadataFactory

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

NewPriorityMetadataFactory creates a PriorityMetadataFactory.

type PriorityReduceFunction

type PriorityReduceFunction func(pod *v1.Pod, meta interface{}, nodeNameToInfo map[string]*schedulernodeinfo.NodeInfo, result schedulerapi.HostPriorityList) 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 int, 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

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 *schedulernodeinfo.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 *schedulernodeinfo.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]*schedulernodeinfo.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 *schedulernodeinfo.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]*schedulernodeinfo.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