Documentation ¶
Overview ¶
Package scheduler contains a generic Scheduler interface and several implementations.
Index ¶
- func CheckPodsExceedingCapacity(pods []api.Pod, capacity api.ResourceList) (fitting []api.Pod, notFitting []api.Pod)
- func MapPodsToMachines(lister PodLister) (map[string][]api.Pod, error)
- func NoDiskConflict(pod api.Pod, existingPods []api.Pod, node string) (bool, error)
- func PodFitsHost(pod api.Pod, existingPods []api.Pod, node string) (bool, error)
- func PodFitsPorts(pod api.Pod, existingPods []api.Pod, node string) (bool, error)
- func PodMatchesNodeLabels(pod *api.Pod, node *api.Node) bool
- type ClientNodeInfo
- type FailedPredicateMap
- type FakeMinionLister
- type FakePodLister
- type FakeServiceLister
- type FitError
- type FitPredicate
- func NewNodeLabelPredicate(info NodeInfo, labels []string, presence bool) FitPredicate
- func NewResourceFitPredicate(info NodeInfo) FitPredicate
- func NewSelectorMatchPredicate(info NodeInfo) FitPredicate
- func NewServiceAffinityPredicate(podLister PodLister, serviceLister ServiceLister, nodeInfo NodeInfo, ...) FitPredicate
- type HostPriority
- type HostPriorityList
- func BalancedResourceAllocation(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
- func EqualPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
- func LeastRequestedPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
- type MinionLister
- type NodeInfo
- type NodeLabelChecker
- type NodeLabelPrioritizer
- type NodeSelector
- type PodLister
- type PriorityConfig
- type PriorityFunction
- type ResourceFit
- type Scheduler
- type ServiceAffinity
- type ServiceAntiAffinity
- type ServiceLister
- type ServiceSpread
- type StaticNodeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPodsExceedingCapacity ¶ added in v0.14.0
func MapPodsToMachines ¶
MapPodsToMachines obtains a list of pods and pivots that list into a map where the keys are host names and the values are the list of pods running on that host.
func NoDiskConflict ¶ added in v0.5.1
NoDiskConflict evaluates if a pod can fit due to the volumes it requests, and those that are already mounted. Some times of volumes are mounted onto node machines. For now, these mounts are exclusive so if there is already a volume mounted on that node, another pod can't schedule there. This is GCE specific for now. TODO: migrate this into some per-volume specific code?
func PodFitsHost ¶ added in v0.8.0
func PodFitsPorts ¶
Types ¶
type ClientNodeInfo ¶
func (ClientNodeInfo) GetNodeInfo ¶
func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)
type FailedPredicateMap ¶ added in v0.12.0
type FakeMinionLister ¶
FakeMinionLister implements MinionLister on a []string for test purposes.
type FakePodLister ¶
FakePodLister implements PodLister on an []api.Pods for test purposes.
type FakeServiceLister ¶ added in v0.9.0
FakeServiceLister implements ServiceLister on []api.Service for test purposes.
func (FakeServiceLister) GetPodServices ¶ added in v0.9.0
GetPodServices gets the services that have the selector that match the labels on the given pod
func (FakeServiceLister) List ¶ added in v0.9.0
func (f FakeServiceLister) List() (api.ServiceList, error)
FakeServiceLister returns api.ServiceList, the list of all services.
type FitError ¶ added in v0.12.0
type FitError struct { Pod api.Pod FailedPredicates FailedPredicateMap }
type FitPredicate ¶
FitPredicate is a function that indicates if a pod fits into an existing node.
func NewNodeLabelPredicate ¶ added in v0.9.0
func NewNodeLabelPredicate(info NodeInfo, labels []string, presence bool) FitPredicate
func NewResourceFitPredicate ¶
func NewResourceFitPredicate(info NodeInfo) FitPredicate
func NewSelectorMatchPredicate ¶ added in v0.5.1
func NewSelectorMatchPredicate(info NodeInfo) FitPredicate
func NewServiceAffinityPredicate ¶ added in v0.9.0
func NewServiceAffinityPredicate(podLister PodLister, serviceLister ServiceLister, nodeInfo NodeInfo, labels []string) FitPredicate
type HostPriority ¶
type HostPriority struct {
// contains filtered or unexported fields
}
HostPriority represents the priority of scheduling to a particular host, lower priority is better.
type HostPriorityList ¶
type HostPriorityList []HostPriority
func BalancedResourceAllocation ¶ added in v0.15.0
func BalancedResourceAllocation(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
BalancedResourceAllocation favors nodes with balanced resource usage rate. BalancedResourceAllocation should **NOT** be used alone, and **MUST** be used together with LeastRequestedPriority. It calculates the difference between the cpu and memory fracion of capacity, and prioritizes the host based on how close the two metrics are to each other. Detail: score = 10 - abs(cpuFraction-memoryFraction)*10. The algorithm is partly inspired by: "Wei Huang et al. An Energy Efficient Virtual Machine Placement Algorithm with Balanced Resource Utilization"
func EqualPriority ¶
func EqualPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
EqualPriority is a prioritizer function that gives an equal weight of one to all nodes
func LeastRequestedPriority ¶
func LeastRequestedPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
LeastRequestedPriority 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: (Sum(requested cpu) / Capacity + Sum(requested memory) / Capacity) * 50
func (HostPriorityList) Len ¶
func (h HostPriorityList) Len() int
func (HostPriorityList) Less ¶
func (h HostPriorityList) Less(i, j int) bool
func (HostPriorityList) Swap ¶
func (h HostPriorityList) Swap(i, j int)
type MinionLister ¶
MinionLister interface represents anything that can list minions for a scheduler.
type NodeLabelChecker ¶ added in v0.9.0
type NodeLabelChecker struct {
// contains filtered or unexported fields
}
func (*NodeLabelChecker) CheckNodeLabelPresence ¶ added in v0.9.0
func (n *NodeLabelChecker) CheckNodeLabelPresence(pod api.Pod, existingPods []api.Pod, node string) (bool, error)
CheckNodeLabelPresence checks whether all of the specified labels exists on a minion or not, regardless of their value If "presence" is false, then returns false if any of the requested labels matches any of the minion's labels, otherwise returns true. If "presence" is true, then returns false if any of the requested labels does not match any of the minion's labels, otherwise returns true.
Consider the cases where the minions are placed in regions/zones/racks and these are identified by labels In some cases, it is required that only minions that are part of ANY of the defined regions/zones/racks be selected
Alternately, eliminating minions that have a certain label, regardless of value, is also useful A minion may have a label with "retiring" as key and the date as the value and it may be desirable to avoid scheduling new pods on this minion
type NodeLabelPrioritizer ¶ added in v0.9.0
type NodeLabelPrioritizer struct {
// contains filtered or unexported fields
}
func (*NodeLabelPrioritizer) CalculateNodeLabelPriority ¶ added in v0.9.0
func (n *NodeLabelPrioritizer) CalculateNodeLabelPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
CalculateNodeLabelPriority checks whether a particular label exists on a minion or not, regardless of its value. If presence is true, prioritizes minions that have the specified label, regardless of value. If presence is false, prioritizes minions that do not have the specified label.
type NodeSelector ¶ added in v0.5.1
type NodeSelector struct {
// contains filtered or unexported fields
}
func (*NodeSelector) PodSelectorMatches ¶ added in v0.5.1
type PodLister ¶
type PodLister interface { // TODO: make this exactly the same as client's Pods(ns).List() method, by returning a api.PodList List(labels.Selector) ([]api.Pod, error) }
PodLister interface represents anything that can list pods for a scheduler.
type PriorityConfig ¶ added in v0.7.0
type PriorityConfig struct { Function PriorityFunction Weight int }
type PriorityFunction ¶
type PriorityFunction func(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
func NewNodeLabelPriority ¶ added in v0.9.0
func NewNodeLabelPriority(label string, presence bool) PriorityFunction
func NewServiceAntiAffinityPriority ¶ added in v0.9.0
func NewServiceAntiAffinityPriority(serviceLister ServiceLister, label string) PriorityFunction
func NewServiceSpreadPriority ¶ added in v0.9.0
func NewServiceSpreadPriority(serviceLister ServiceLister) PriorityFunction
type ResourceFit ¶
type ResourceFit struct {
// contains filtered or unexported fields
}
func (*ResourceFit) PodFitsResources ¶
func (r *ResourceFit) PodFitsResources(pod api.Pod, existingPods []api.Pod, node string) (bool, error)
PodFitsResources calculates fit based on requested, rather than used resources
type Scheduler ¶
type Scheduler interface {
Schedule(api.Pod, MinionLister) (selectedMachine string, err error)
}
Scheduler is an interface implemented by things that know how to schedule pods onto machines.
func NewGenericScheduler ¶
func NewGenericScheduler(predicates map[string]FitPredicate, prioritizers []PriorityConfig, pods PodLister, random *rand.Rand) Scheduler
type ServiceAffinity ¶ added in v0.9.0
type ServiceAffinity struct {
// contains filtered or unexported fields
}
func (*ServiceAffinity) CheckServiceAffinity ¶ added in v0.9.0
func (s *ServiceAffinity) CheckServiceAffinity(pod api.Pod, existingPods []api.Pod, node string) (bool, error)
CheckServiceAffinity ensures that only the minions that match the specified labels are considered for scheduling. The set of labels to be considered are provided to the struct (ServiceAffinity). The pod is checked for the labels and any missing labels are then checked in the minion that hosts the service pods (peers) for the given pod.
We add an implicit selector requiring some particular value V for label L to a pod, if: - L is listed in the ServiceAffinity object that is passed into the function - the pod does not have any NodeSelector for L - some other pod from the same service is already scheduled onto a minion that has value V for label L
type ServiceAntiAffinity ¶ added in v0.9.0
type ServiceAntiAffinity struct {
// contains filtered or unexported fields
}
func (*ServiceAntiAffinity) CalculateAntiAffinityPriority ¶ added in v0.9.0
func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
CalculateAntiAffinityPriority spreads pods by minimizing the number of pods belonging to the same service on machines with the same value for a particular label. The label to be considered is provided to the struct (ServiceAntiAffinity).
type ServiceLister ¶ added in v0.9.0
type ServiceLister interface { // Lists all the services List() (api.ServiceList, error) // Gets the services for the given pod GetPodServices(api.Pod) ([]api.Service, error) }
ServiceLister interface represents anything that can produce a list of services; the list is consumed by a scheduler.
type ServiceSpread ¶ added in v0.9.0
type ServiceSpread struct {
// contains filtered or unexported fields
}
func (*ServiceSpread) CalculateSpreadPriority ¶ added in v0.9.0
func (s *ServiceSpread) CalculateSpreadPriority(pod api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
CalculateSpreadPriority spreads pods by minimizing the number of pods belonging to the same service on the same machine.
type StaticNodeInfo ¶
func (StaticNodeInfo) GetNodeInfo ¶
func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)