scheduler

package
v0.11.1-0...-86a0193 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package scheduler contains a generic Scheduler interface and several implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapPodsToMachines

func MapPodsToMachines(lister PodLister) (map[string][]api.Pod, error)

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

func NoDiskConflict(pod api.Pod, existingPods []api.Pod, node string) (bool, error)

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 PodFitsHost(pod api.Pod, existingPods []api.Pod, node string) (bool, error)

func PodFitsPorts

func PodFitsPorts(pod api.Pod, existingPods []api.Pod, node string) (bool, error)

Types

type ClientNodeInfo

type ClientNodeInfo struct {
	*client.Client
}

func (ClientNodeInfo) GetNodeInfo

func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)

type FakeMinionLister

type FakeMinionLister api.NodeList

FakeMinionLister implements MinionLister on a []string for test purposes.

func (FakeMinionLister) List

func (f FakeMinionLister) List() (api.NodeList, error)

List returns minions as a []string.

type FakePodLister

type FakePodLister []api.Pod

FakePodLister implements PodLister on an []api.Pods for test purposes.

func (FakePodLister) List

func (f FakePodLister) List(s labels.Selector) (selected []api.Pod, err error)

List returns []api.Pod matching a query.

type FakeServiceLister

type FakeServiceLister []api.Service

FakeServiceLister implements ServiceLister on []api.Service for test purposes.

func (FakeServiceLister) GetPodServices

func (f FakeServiceLister) GetPodServices(pod api.Pod) (services []api.Service, err error)

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 FitPredicate

type FitPredicate func(pod api.Pod, existingPods []api.Pod, node string) (bool, error)

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

type MinionLister interface {
	List() (list api.NodeList, err error)
}

MinionLister interface represents anything that can list minions for a scheduler.

type NodeInfo

type NodeInfo interface {
	GetNodeInfo(nodeID string) (*api.Node, error)
}

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

func (n *NodeSelector) PodSelectorMatches(pod api.Pod, existingPods []api.Pod, node string) (bool, error)

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 []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

type StaticNodeInfo struct {
	*api.NodeList
}

func (StaticNodeInfo) GetNodeInfo

func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL