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(_ *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 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 ¶
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 ¶
func PodFitsPorts ¶
Types ¶
type ClientNodeInfo ¶
func (ClientNodeInfo) GetNodeInfo ¶
func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)
type FailedPredicateMap ¶
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 ¶
FakeServiceLister implements ServiceLister on []api.Service for test purposes.
func (FakeServiceLister) GetPodServices ¶
GetPodServices gets the services that have the selector that match the labels on the given pod
func (FakeServiceLister) List ¶
func (f FakeServiceLister) List() (api.ServiceList, error)
FakeServiceLister returns api.ServiceList, the list of all services.
type FitError ¶
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 ¶
func NewNodeLabelPredicate(info NodeInfo, labels []string, presence bool) FitPredicate
func NewResourceFitPredicate ¶
func NewResourceFitPredicate(info NodeInfo) FitPredicate
func NewSelectorMatchPredicate ¶
func NewSelectorMatchPredicate(info NodeInfo) FitPredicate
func NewServiceAffinityPredicate ¶
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 ¶
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(_ *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 ¶
type NodeLabelChecker struct {
// contains filtered or unexported fields
}
func (*NodeLabelChecker) CheckNodeLabelPresence ¶
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 ¶
type NodeLabelPrioritizer struct {
// contains filtered or unexported fields
}
func (*NodeLabelPrioritizer) CalculateNodeLabelPriority ¶
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 ¶
type NodeSelector struct {
// contains filtered or unexported fields
}
func (*NodeSelector) PodSelectorMatches ¶
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 ¶
type PriorityConfig struct { Function PriorityFunction Weight int }
type PriorityFunction ¶
type PriorityFunction func(pod *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)
func NewNodeLabelPriority ¶
func NewNodeLabelPriority(label string, presence bool) PriorityFunction
func NewServiceAntiAffinityPriority ¶
func NewServiceAntiAffinityPriority(serviceLister ServiceLister, label string) PriorityFunction
func NewServiceSpreadPriority ¶
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 ¶
type ServiceAffinity struct {
// contains filtered or unexported fields
}
func (*ServiceAffinity) CheckServiceAffinity ¶
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 ¶
type ServiceAntiAffinity struct {
// contains filtered or unexported fields
}
func (*ServiceAntiAffinity) CalculateAntiAffinityPriority ¶
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 ¶
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 ¶
type ServiceSpread struct {
// contains filtered or unexported fields
}
func (*ServiceSpread) CalculateSpreadPriority ¶
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)