scheduler

package
v1.17.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: Apache-2.0 Imports: 53 Imported by: 106

Documentation

Index

Constants

View Source
const (
	// BindTimeoutSeconds defines the default bind timeout
	BindTimeoutSeconds = 100
	// SchedulerError is the reason recorded for events when an error occurs during scheduling a pod.
	SchedulerError = "SchedulerError"
)
View Source
const (
	// DefaultProvider defines the default algorithm provider name.
	DefaultProvider = "DefaultProvider"
)

Variables

This section is empty.

Functions

func AddAllEventHandlers added in v1.14.0

func AddAllEventHandlers(
	sched *Scheduler,
	schedulerName string,
	informerFactory informers.SharedInformerFactory,
	podInformer coreinformers.PodInformer,
)

AddAllEventHandlers is a helper function used in tests and in Scheduler to add event handlers for various informers.

func ApplyPredicatesAndPriorities added in v1.17.0

func ApplyPredicatesAndPriorities(s *Snapshot)

ApplyPredicatesAndPriorities sets state of predicates and priorities to `s`.

func InsertPredicateKeyToAlgoProvider added in v1.17.0

func InsertPredicateKeyToAlgoProvider(providerName, key string) error

InsertPredicateKeyToAlgoProvider insert a fit predicate key to algorithmProvider.

func InsertPredicateKeyToAlgorithmProviderMap added in v1.17.0

func InsertPredicateKeyToAlgorithmProviderMap(key string)

InsertPredicateKeyToAlgorithmProviderMap insert a fit predicate key to all algorithmProviders which in algorithmProviderMap.

func InsertPriorityKeyToAlgorithmProviderMap added in v1.17.0

func InsertPriorityKeyToAlgorithmProviderMap(key string)

InsertPriorityKeyToAlgorithmProviderMap inserts a priority function to all algorithmProviders which are in algorithmProviderMap.

func IsFitPredicateRegistered added in v1.17.0

func IsFitPredicateRegistered(name string) bool

IsFitPredicateRegistered is useful for testing providers.

func IsPriorityFunctionRegistered added in v1.17.0

func IsPriorityFunctionRegistered(name string) bool

IsPriorityFunctionRegistered is useful for testing providers.

func ListAlgorithmProviders added in v1.17.0

func ListAlgorithmProviders() string

ListAlgorithmProviders is called when listing all available algorithm providers in `kube-scheduler --help`

func ListRegisteredFitPredicates added in v1.17.0

func ListRegisteredFitPredicates() []string

ListRegisteredFitPredicates returns the registered fit predicates.

func ListRegisteredPriorityFunctions added in v1.17.0

func ListRegisteredPriorityFunctions() []string

ListRegisteredPriorityFunctions returns the registered priority functions.

func MakeDefaultErrorFunc added in v1.17.0

func MakeDefaultErrorFunc(client clientset.Interface, podQueue internalqueue.SchedulingQueue, schedulerCache internalcache.Cache) func(*framework.PodInfo, error)

MakeDefaultErrorFunc construct a function to handle pod scheduler error

func NewPodInformer added in v1.17.0

func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) coreinformers.PodInformer

NewPodInformer creates a shared index informer that returns only non-terminal pods.

func RegisterAlgorithmProvider added in v1.17.0

func RegisterAlgorithmProvider(name string, predicateKeys, priorityKeys sets.String) string

RegisterAlgorithmProvider registers a new algorithm provider with the algorithm registry. This should be called from the init function in a provider plugin.

func RegisterCustomFitPredicate added in v1.17.0

func RegisterCustomFitPredicate(policy schedulerapi.PredicatePolicy) string

RegisterCustomFitPredicate registers a custom fit predicate with the algorithm registry. Returns the name, with which the predicate was registered.

func RegisterCustomPriorityFunction added in v1.17.0

func RegisterCustomPriorityFunction(policy schedulerapi.PriorityPolicy) string

RegisterCustomPriorityFunction registers a custom priority function with the algorithm registry. Returns the name, with which the priority function was registered.

func RegisterFitPredicate added in v1.17.0

func RegisterFitPredicate(name string, predicate predicates.FitPredicate) string

RegisterFitPredicate registers a fit predicate with the algorithm registry. Returns the name with which the predicate was registered.

func RegisterFitPredicateFactory added in v1.17.0

func RegisterFitPredicateFactory(name string, predicateFactory FitPredicateFactory) string

RegisterFitPredicateFactory registers a fit predicate factory with the algorithm registry. Returns the name with which the predicate was registered.

func RegisterMandatoryFitPredicate added in v1.17.0

func RegisterMandatoryFitPredicate(name string, predicate predicates.FitPredicate) string

RegisterMandatoryFitPredicate registers a fit predicate with the algorithm registry, the predicate is used by kubelet, DaemonSet; it is always included in configuration. Returns the name with which the predicate was registered.

func RegisterPredicateMetadataProducer

func RegisterPredicateMetadataProducer(producer predicates.PredicateMetadataProducer)

RegisterPredicateMetadataProducer registers a PredicateMetadataProducer.

func RegisterPriorityConfigFactory added in v1.17.0

func RegisterPriorityConfigFactory(name string, pcf PriorityConfigFactory) string

RegisterPriorityConfigFactory registers a priority config factory with its name.

func RegisterPriorityFunction

func RegisterPriorityFunction(name string, function priorities.PriorityFunction, weight int) string

RegisterPriorityFunction registers a priority function with the algorithm registry. Returns the name, with which the function was registered. DEPRECATED Use Map-Reduce pattern for priority functions.

func RegisterPriorityMapReduceFunction added in v1.17.0

func RegisterPriorityMapReduceFunction(
	name string,
	mapFunction priorities.PriorityMapFunction,
	reduceFunction priorities.PriorityReduceFunction,
	weight int) string

RegisterPriorityMapReduceFunction registers a priority function with the algorithm registry. Returns the name, with which the function was registered.

func RegisterPriorityMetadataProducerFactory added in v1.17.0

func RegisterPriorityMetadataProducerFactory(factory PriorityMetadataProducerFactory)

RegisterPriorityMetadataProducerFactory registers a PriorityMetadataProducerFactory.

func RemoveFitPredicate added in v1.17.0

func RemoveFitPredicate(name string)

RemoveFitPredicate removes a fit predicate from factory.

func RemovePredicateKeyFromAlgoProvider added in v1.17.0

func RemovePredicateKeyFromAlgoProvider(providerName, key string) error

RemovePredicateKeyFromAlgoProvider removes a fit predicate key from algorithmProvider.

func RemovePredicateKeyFromAlgorithmProviderMap added in v1.17.0

func RemovePredicateKeyFromAlgorithmProviderMap(key string)

RemovePredicateKeyFromAlgorithmProviderMap removes a fit predicate key from all algorithmProviders which in algorithmProviderMap.

Types

type AlgorithmProviderConfig added in v1.17.0

type AlgorithmProviderConfig struct {
	FitPredicateKeys     sets.String
	PriorityFunctionKeys sets.String
}

AlgorithmProviderConfig is used to store the configuration of algorithm providers.

func GetAlgorithmProvider added in v1.17.0

func GetAlgorithmProvider(name string) (*AlgorithmProviderConfig, error)

GetAlgorithmProvider should not be used to modify providers. It is publicly visible for testing.

type Binder added in v1.10.0

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

Binder knows how to write a binding.

type Config added in v1.10.0

type Config struct {
	SchedulerCache internalcache.Cache

	Algorithm core.ScheduleAlgorithm
	GetBinder func(pod *v1.Pod) Binder
	// Framework runs scheduler plugins at configured extension points.
	Framework framework.Framework

	// 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() *framework.PodInfo

	// WaitForCacheSync waits for scheduler cache to populate.
	// It returns true if it was successful, false if the controller should shutdown.
	WaitForCacheSync func() bool

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

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

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

	// VolumeBinder handles PVC/PV binding for the pod.
	VolumeBinder *volumebinder.VolumeBinder

	// Disable pod preemption or not.
	DisablePreemption bool

	// SchedulingQueue holds pods to be scheduled
	SchedulingQueue internalqueue.SchedulingQueue

	// The final configuration of the framework.
	Plugins      config.Plugins
	PluginConfig []config.PluginConfig
}

Config is an implementation of the Scheduler's configured input data. TODO over time we should make this struct a hidden implementation detail of the scheduler.

type ConfigFactoryArgs

type ConfigFactoryArgs struct {
	Client                         clientset.Interface
	InformerFactory                informers.SharedInformerFactory
	NodeInformer                   coreinformers.NodeInformer
	PodInformer                    coreinformers.PodInformer
	PvInformer                     coreinformers.PersistentVolumeInformer
	PvcInformer                    coreinformers.PersistentVolumeClaimInformer
	ReplicationControllerInformer  coreinformers.ReplicationControllerInformer
	ReplicaSetInformer             appsinformers.ReplicaSetInformer
	StatefulSetInformer            appsinformers.StatefulSetInformer
	ServiceInformer                coreinformers.ServiceInformer
	PdbInformer                    policyinformers.PodDisruptionBudgetInformer
	StorageClassInformer           storageinformersv1.StorageClassInformer
	CSINodeInformer                storageinformersv1beta1.CSINodeInformer
	VolumeBinder                   *volumebinder.VolumeBinder
	SchedulerCache                 internalcache.Cache
	HardPodAffinitySymmetricWeight int32
	DisablePreemption              bool
	PercentageOfNodesToScore       int32
	BindTimeoutSeconds             int64
	PodInitialBackoffSeconds       int64
	PodMaxBackoffSeconds           int64
	StopCh                         <-chan struct{}
	Registry                       framework.Registry
	Plugins                        *config.Plugins
	PluginConfig                   []config.PluginConfig
	PluginConfigProducerRegistry   *plugins.ConfigProducerRegistry
}

ConfigFactoryArgs is a set arguments passed to NewConfigFactory.

type Configurator added in v1.10.0

type Configurator struct {

	// Close this to stop all reflectors
	StopEverything <-chan struct{}
	// contains filtered or unexported fields
}

Configurator defines I/O, caching, and other functionality needed to construct a new scheduler.

func NewConfigFactory

func NewConfigFactory(args *ConfigFactoryArgs) *Configurator

NewConfigFactory initializes the default implementation of a Configurator. To encourage eventual privatization of the struct type, we only return the interface.

func (*Configurator) Create added in v1.10.0

func (c *Configurator) Create() (*Config, error)

Create creates a scheduler with the default algorithm provider.

func (*Configurator) CreateFromConfig added in v1.10.0

func (c *Configurator) CreateFromConfig(policy schedulerapi.Policy) (*Config, error)

CreateFromConfig creates a scheduler from the configuration file

func (*Configurator) CreateFromKeys added in v1.10.0

func (c *Configurator) CreateFromKeys(predicateKeys, priorityKeys sets.String, extenders []algorithm.SchedulerExtender) (*Config, error)

CreateFromKeys creates a scheduler from a set of registered fit predicate keys and priority keys.

func (*Configurator) CreateFromProvider added in v1.10.0

func (c *Configurator) CreateFromProvider(providerName string) (*Config, error)

CreateFromProvider creates a scheduler from the name of a registered algorithm provider.

func (*Configurator) GetHardPodAffinitySymmetricWeight added in v1.10.0

func (c *Configurator) GetHardPodAffinitySymmetricWeight() int32

GetHardPodAffinitySymmetricWeight is exposed for testing.

func (*Configurator) GetPredicateMetadataProducer added in v1.10.0

func (c *Configurator) GetPredicateMetadataProducer() (predicates.PredicateMetadataProducer, error)

GetPredicateMetadataProducer returns a function to build Predicate Metadata. It is used by the scheduler and other components, such as k8s.io/autoscaler/cluster-autoscaler.

type FitPredicateFactory added in v1.17.0

type FitPredicateFactory func(PluginFactoryArgs) predicates.FitPredicate

FitPredicateFactory produces a FitPredicate from the given args.

type Option added in v1.13.0

type Option func(*schedulerOptions)

Option configures a Scheduler

func WithBindTimeoutSeconds added in v1.13.0

func WithBindTimeoutSeconds(bindTimeoutSeconds int64) Option

WithBindTimeoutSeconds sets bindTimeoutSeconds for Scheduler, the default value is 100

func WithFrameworkConfigProducerRegistry added in v1.17.0

func WithFrameworkConfigProducerRegistry(registry *frameworkplugins.ConfigProducerRegistry) Option

WithFrameworkConfigProducerRegistry sets the framework plugin producer registry.

func WithFrameworkDefaultRegistry added in v1.17.0

func WithFrameworkDefaultRegistry(registry framework.Registry) Option

WithFrameworkDefaultRegistry sets the framework's default registry.

func WithFrameworkOutOfTreeRegistry added in v1.17.0

func WithFrameworkOutOfTreeRegistry(registry framework.Registry) Option

WithFrameworkOutOfTreeRegistry sets the registry for out-of-tree plugins. Those plugins will be appended to the default registry.

func WithFrameworkPluginConfig added in v1.17.0

func WithFrameworkPluginConfig(pluginConfig []kubeschedulerconfig.PluginConfig) Option

WithFrameworkPluginConfig sets the PluginConfig slice that the framework should be configured with.

func WithFrameworkPlugins added in v1.17.0

func WithFrameworkPlugins(plugins *kubeschedulerconfig.Plugins) Option

WithFrameworkPlugins sets the plugins that the framework should be configured with.

func WithHardPodAffinitySymmetricWeight added in v1.13.0

func WithHardPodAffinitySymmetricWeight(hardPodAffinitySymmetricWeight int32) Option

WithHardPodAffinitySymmetricWeight sets hardPodAffinitySymmetricWeight for Scheduler, the default value is 1

func WithName added in v1.13.0

func WithName(schedulerName string) Option

WithName sets schedulerName for Scheduler, the default schedulerName is default-scheduler

func WithPercentageOfNodesToScore added in v1.13.0

func WithPercentageOfNodesToScore(percentageOfNodesToScore int32) Option

WithPercentageOfNodesToScore sets percentageOfNodesToScore for Scheduler, the default value is 50

func WithPodInitialBackoffSeconds added in v1.17.0

func WithPodInitialBackoffSeconds(podInitialBackoffSeconds int64) Option

WithPodInitialBackoffSeconds sets podInitialBackoffSeconds for Scheduler, the default value is 1

func WithPodMaxBackoffSeconds added in v1.17.0

func WithPodMaxBackoffSeconds(podMaxBackoffSeconds int64) Option

WithPodMaxBackoffSeconds sets podMaxBackoffSeconds for Scheduler, the default value is 10

func WithPreemptionDisabled added in v1.13.0

func WithPreemptionDisabled(disablePreemption bool) Option

WithPreemptionDisabled sets disablePreemption for Scheduler, the default value is false

type PluginFactoryArgs

type PluginFactoryArgs struct {
	PodLister                      algorithm.PodLister
	ServiceLister                  corelisters.ServiceLister
	ControllerLister               corelisters.ReplicationControllerLister
	ReplicaSetLister               appslisters.ReplicaSetLister
	StatefulSetLister              appslisters.StatefulSetLister
	PDBLister                      policylisters.PodDisruptionBudgetLister
	NodeInfo                       predicates.NodeInfo
	CSINodeInfo                    predicates.CSINodeInfo
	PVInfo                         predicates.PersistentVolumeInfo
	PVCInfo                        predicates.PersistentVolumeClaimInfo
	StorageClassInfo               predicates.StorageClassInfo
	VolumeBinder                   *volumebinder.VolumeBinder
	HardPodAffinitySymmetricWeight int32
}

PluginFactoryArgs are passed to all plugin factory functions.

type PredicateMetadataProducerFactory added in v1.17.0

type PredicateMetadataProducerFactory func(PluginFactoryArgs) predicates.PredicateMetadataProducer

PredicateMetadataProducerFactory produces PredicateMetadataProducer from the given args.

type PriorityConfigFactory added in v1.17.0

type PriorityConfigFactory struct {
	Function          PriorityFunctionFactory
	MapReduceFunction PriorityFunctionFactory2
	Weight            int64
}

PriorityConfigFactory produces a PriorityConfig from the given function and weight

type PriorityFunctionFactory added in v1.17.0

type PriorityFunctionFactory func(PluginFactoryArgs) priorities.PriorityFunction

PriorityFunctionFactory produces a PriorityConfig from the given args. DEPRECATED Use Map-Reduce pattern for priority functions.

type PriorityFunctionFactory2

PriorityFunctionFactory2 produces map & reduce priority functions from a given args. FIXME: Rename to PriorityFunctionFactory.

type PriorityMetadataProducerFactory added in v1.17.0

type PriorityMetadataProducerFactory func(PluginFactoryArgs) priorities.PriorityMetadataProducer

PriorityMetadataProducerFactory produces PriorityMetadataProducer from the given args.

type Scheduler

type Scheduler struct {
	// It is expected that changes made via SchedulerCache will be observed
	// by NodeLister and Algorithm.
	SchedulerCache internalcache.Cache

	Algorithm core.ScheduleAlgorithm
	GetBinder func(pod *v1.Pod) Binder

	// Framework runs scheduler plugins at configured extension points.
	Framework framework.Framework

	// 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() *framework.PodInfo

	// WaitForCacheSync waits for scheduler cache to populate.
	// It returns true if it was successful, false if the controller should shutdown.
	WaitForCacheSync func() bool

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

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

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

	// VolumeBinder handles PVC/PV binding for the pod.
	VolumeBinder *volumebinder.VolumeBinder

	// Disable pod preemption or not.
	DisablePreemption bool

	// SchedulingQueue holds pods to be scheduled
	SchedulingQueue internalqueue.SchedulingQueue
	// 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 added in v1.13.0

func New(client clientset.Interface,
	informerFactory informers.SharedInformerFactory,
	podInformer coreinformers.PodInformer,
	recorder events.EventRecorder,
	schedulerAlgorithmSource kubeschedulerconfig.SchedulerAlgorithmSource,
	stopCh <-chan struct{},
	opts ...Option) (*Scheduler, error)

New returns a Scheduler

func NewFromConfig added in v1.10.0

func NewFromConfig(config *Config) *Scheduler

NewFromConfig returns a new scheduler using the provided Config.

func (*Scheduler) Cache added in v1.12.0

func (sched *Scheduler) Cache() internalcache.Cache

Cache returns the cache in scheduler for test to check the data in scheduler.

func (*Scheduler) Run added in v1.10.0

func (sched *Scheduler) Run(ctx context.Context)

Run begins watching and scheduling. It waits for cache to be synced, then starts scheduling and blocked until the context is done.

type Snapshot added in v1.17.0

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

Snapshot is used to store current state of registered predicates and priorities.

func RegisteredPredicatesAndPrioritiesSnapshot added in v1.17.0

func RegisteredPredicatesAndPrioritiesSnapshot() *Snapshot

RegisteredPredicatesAndPrioritiesSnapshot returns a snapshot of current registered predicates and priorities.

Directories

Path Synopsis
Package algorithm contains a generic Scheduler interface and several implementations.
Package algorithm contains a generic Scheduler interface and several implementations.
api
Package api contains scheduler API objects.
Package api contains scheduler API objects.
v1
Package v1 contains scheduler API objects.
Package v1 contains scheduler API objects.
apis
extender/v1
Package v1 contains scheduler API objects.
Package v1 contains scheduler API objects.
framework
internal

Jump to

Keyboard shortcuts

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