kubernetes: k8s.io/kubernetes/pkg/scheduler/algorithm/priorities Index | Files | Directories

package priorities

import "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"

Index

Package Files

balanced_resource_allocation.go even_pods_spread.go image_locality.go interpod_affinity.go least_requested.go metadata.go most_requested.go node_affinity.go node_label.go node_prefer_avoid_pods.go priorities.go reduce.go requested_to_capacity_ratio.go resource_allocation.go resource_limits.go selector_spreading.go taint_toleration.go test_util.go types.go

Constants

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

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
)
var CalculateNodeAffinityPriorityReduce = NormalizeReduce(framework.MaxNodeScore, false)

CalculateNodeAffinityPriorityReduce is a reduce function for node affinity priority calculation.

var ComputeTaintTolerationPriorityReduce = NormalizeReduce(framework.MaxNodeScore, true)

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

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

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

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
)
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
)

func CalculateEvenPodsSpreadPriorityMap Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

EmptyMetadataProducer returns a no-op MetadataProducer type.

func ImageLocalityPriorityMap Uses

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 Uses

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

NewNodeLabelPriority creates a NodeLabelPrioritizer.

func NewSelectorSpreadPriority Uses

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

NewSelectorSpreadPriority creates a SelectorSpread.

func NewServiceAntiAffinityPriority Uses

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

NewServiceAntiAffinityPriority creates a ServiceAntiAffinity.

func ResourceLimitsPriorityMap Uses

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.

type FunctionShape Uses

type FunctionShape []FunctionShapePoint

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

func NewFunctionShape Uses

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

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

type FunctionShapePoint Uses

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 Uses

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

MetadataFactory is a factory to produce PriorityMetadata.

func (*MetadataFactory) PriorityMetadata Uses

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 Uses

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 Uses

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

NewMetadataFactory creates a MetadataFactory.

type NodeLabelPrioritizer Uses

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

NodeLabelPrioritizer contains information to calculate node label priority.

func (*NodeLabelPrioritizer) CalculateNodeLabelPriorityMap Uses

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 Uses

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

PriorityConfig is a config used for a priority function.

type PriorityMapFunction Uses

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 Uses

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 Uses

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 Uses

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

ResourceAllocationPriority contains information to calculate resource allocation priority.

func RequestedToCapacityRatioResourceAllocationPriority Uses

func RequestedToCapacityRatioResourceAllocationPriority(scoringFunctionShape FunctionShape, resourceToWeightMap ResourceToWeightMap) *ResourceAllocationPriority

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

func RequestedToCapacityRatioResourceAllocationPriorityDefault Uses

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 Uses

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 Uses

type ResourceToValueMap map[v1.ResourceName]int64

ResourceToValueMap contains resource name and score.

type ResourceToWeightMap Uses

type ResourceToWeightMap map[v1.ResourceName]int64

ResourceToWeightMap contains resource name and weight.

type SelectorSpread Uses

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

SelectorSpread contains information to calculate selector spread priority.

func (*SelectorSpread) CalculateSpreadPriorityMap Uses

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 Uses

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 Uses

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

ServiceAntiAffinity contains information to calculate service anti-affinity priority.

func (*ServiceAntiAffinity) CalculateAntiAffinityPriorityMap Uses

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 Uses

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

PathSynopsis
util

Package priorities imports 26 packages (graph) and is imported by 108 packages. Updated 2019-11-15. Refresh now. Tools for package owners.