scheduler

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2016 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultExtenderTimeout = 5 * time.Second
)

Variables

View Source
var ErrNoNodesAvailable = fmt.Errorf("no nodes available to schedule pods")

Functions

func EqualPriority added in v0.19.2

func EqualPriority(_ *api.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo, nodeLister algorithm.NodeLister) (schedulerapi.HostPriorityList, error)

EqualPriority is a prioritizer function that gives an equal weight of one to all nodes

func NewGenericScheduler added in v0.19.2

func NewGenericScheduler(predicates map[string]algorithm.FitPredicate, prioritizers []algorithm.PriorityConfig, extenders []algorithm.SchedulerExtender, pods algorithm.PodLister, random *rand.Rand) algorithm.ScheduleAlgorithm

func NewHTTPExtender added in v1.2.2

func NewHTTPExtender(config *schedulerapi.ExtenderConfig, apiVersion string) (algorithm.SchedulerExtender, error)

func PrioritizeNodes added in v0.21.3

func PrioritizeNodes(
	pod *api.Pod,
	nodeNameToInfo map[string]*schedulercache.NodeInfo,
	podLister algorithm.PodLister,
	priorityConfigs []algorithm.PriorityConfig,
	nodeLister algorithm.NodeLister,
	extenders []algorithm.SchedulerExtender,
) (schedulerapi.HostPriorityList, error)

Prioritizes the nodes by running the individual priority functions in parallel. Each priority function is expected to set a score of 0-10 0 is the lowest priority score (least preferred node) and 10 is the highest Each priority function can also have its own weight The node scores returned by the priority function are multiplied by the weights to get weighted scores All scores are finally combined (added) to get the total weighted scores of all nodes

Types

type Binder

type Binder interface {
	Bind(binding *api.Binding) error
}

Binder knows how to write a binding.

type Config

type Config struct {
	// It is expected that changes made via modeler will be observed
	// by NodeLister and Algorithm.
	Modeler    SystemModeler
	NodeLister algorithm.NodeLister
	Algorithm  algorithm.ScheduleAlgorithm
	Binder     Binder

	// NextPod should be a function that blocks until the next pod
	// is available. We don't use a channel for this, because scheduling
	// a pod may take some amount of time and we don't want pods to get
	// stale while they sit in a channel.
	NextPod func() *api.Pod

	// Error is called if there is an error. It is passed the pod in
	// question, and the error
	Error func(*api.Pod, error)

	// Recorder is the EventRecorder to use
	Recorder record.EventRecorder

	// Close this to shut down the scheduler.
	StopEverything chan struct{}
}

type ExtendedPodLister added in v0.13.2

type ExtendedPodLister interface {
	algorithm.PodLister
	Exists(pod *api.Pod) (bool, error)
}

ExtendedPodLister: SimpleModeler needs to be able to check for a pod's existence in addition to listing the pods.

type FailedPredicateMap added in v0.19.2

type FailedPredicateMap map[string]sets.String

type FakeModeler added in v0.13.2

type FakeModeler struct {
	AssumePodFunc      func(pod *api.Pod)
	ForgetPodFunc      func(pod *api.Pod)
	ForgetPodByKeyFunc func(key string)
	// contains filtered or unexported fields
}

FakeModeler implements the SystemModeler interface.

func (*FakeModeler) AssumePod added in v0.13.2

func (f *FakeModeler) AssumePod(pod *api.Pod)

AssumePod calls the function variable if it is not nil.

func (*FakeModeler) ForgetPod added in v0.16.0

func (f *FakeModeler) ForgetPod(pod *api.Pod)

ForgetPod calls the function variable if it is not nil.

func (*FakeModeler) ForgetPodByKey added in v0.16.0

func (f *FakeModeler) ForgetPodByKey(key string)

ForgetPodByKey calls the function variable if it is not nil.

func (*FakeModeler) LockedAction added in v0.16.0

func (a *FakeModeler) LockedAction(do func())

LockedAction serializes calls of whatever is passed as 'do'.

type FitError added in v0.19.2

type FitError struct {
	Pod              *api.Pod
	FailedPredicates FailedPredicateMap
}

func (*FitError) Error added in v0.19.2

func (f *FitError) Error() string

Error returns detailed information of why the pod failed to fit on each node

type HTTPExtender added in v1.2.2

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

HTTPExtender implements the algorithm.SchedulerExtender interface.

func (*HTTPExtender) Filter added in v1.2.2

func (h *HTTPExtender) Filter(pod *api.Pod, nodes *api.NodeList) (*api.NodeList, error)

Filter based on extender implemented predicate functions. The filtered list is expected to be a subset of the supplied list.

func (*HTTPExtender) Prioritize added in v1.2.2

func (h *HTTPExtender) Prioritize(pod *api.Pod, nodes *api.NodeList) (*schedulerapi.HostPriorityList, int, error)

Prioritize based on extender implemented priority functions. Weight*priority is added up for each such priority function. The returned score is added to the score computed by Kubernetes scheduler. The total score is used to do the host selection.

type Scheduler

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

Scheduler watches for new unscheduled pods. It attempts to find nodes that they fit on and writes bindings back to the api server.

func New

func New(c *Config) *Scheduler

New returns a new scheduler.

func (*Scheduler) Run

func (s *Scheduler) Run()

Run begins watching and scheduling. It starts a goroutine and returns immediately.

type SimpleModeler added in v0.13.2

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

SimpleModeler implements the SystemModeler interface with a timed pod cache.

func NewSimpleModeler added in v0.13.2

func NewSimpleModeler(queuedPods, scheduledPods ExtendedPodLister) *SimpleModeler

NewSimpleModeler returns a new SimpleModeler.

queuedPods: a PodLister that will return pods that have not been scheduled yet.
scheduledPods: a PodLister that will return pods that we know for sure have been scheduled.

func (*SimpleModeler) AssumePod added in v0.13.2

func (s *SimpleModeler) AssumePod(pod *api.Pod)

func (*SimpleModeler) ForgetPod added in v0.16.0

func (s *SimpleModeler) ForgetPod(pod *api.Pod)

func (*SimpleModeler) ForgetPodByKey added in v0.16.0

func (s *SimpleModeler) ForgetPodByKey(key string)

func (*SimpleModeler) LockedAction added in v0.16.0

func (a *SimpleModeler) LockedAction(do func())

LockedAction serializes calls of whatever is passed as 'do'.

func (*SimpleModeler) PodLister added in v0.13.2

func (s *SimpleModeler) PodLister() algorithm.PodLister

PodLister returns a PodLister that will list pods that we think we have scheduled in addition to pods that we know have been scheduled.

type SystemModeler added in v0.13.2

type SystemModeler interface {
	// AssumePod assumes that the given pod exists in the system.
	// The assumtion should last until the system confirms the
	// assumtion or disconfirms it.
	AssumePod(pod *api.Pod)
	// ForgetPod removes a pod assumtion. (It won't make the model
	// show the absence of the given pod if the pod is in the scheduled
	// pods list!)
	ForgetPod(pod *api.Pod)
	ForgetPodByKey(key string)

	// For serializing calls to Assume/ForgetPod: imagine you want to add
	// a pod if and only if a bind succeeds, but also remove a pod if it is deleted.
	// TODO: if SystemModeler begins modeling things other than pods, this
	// should probably be parameterized or specialized for pods.
	LockedAction(f func())
}

SystemModeler can help scheduler produce a model of the system that anticipates reality. For example, if scheduler has pods A and B both using hostPort 80, when it binds A to machine M it should not bind B to machine M in the time when it hasn't observed the binding of A take effect yet.

Since the model is only an optimization, it's expected to handle any errors itself without sending them back to the scheduler.

Directories

Path Synopsis
Package scheduler contains a generic Scheduler interface and several implementations.
Package scheduler contains a generic Scheduler interface and several implementations.
This package is used to register algorithm provider plugins.
This package is used to register algorithm provider plugins.
defaults
This is the default algorithm provider for the scheduler.
This is the default algorithm provider for the scheduler.
api
v1
Package factory can set up a scheduler.
Package factory can set up a scheduler.

Jump to

Keyboard shortcuts

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