kubernetes: k8s.io/kubernetes/pkg/scheduler Index | Files | Directories

package scheduler

import "k8s.io/kubernetes/pkg/scheduler"


Package Files

algorithm_factory.go eventhandlers.go factory.go scheduler.go


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"
const (
    // DefaultProvider defines the default algorithm provider name.
    DefaultProvider = "DefaultProvider"

func AddAllEventHandlers Uses

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 Uses

func ApplyPredicatesAndPriorities(s *Snapshot)

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

func GetCSINodeLister Uses

func GetCSINodeLister(informerFactory informers.SharedInformerFactory) storagelisters.CSINodeLister

GetCSINodeLister returns CSINode lister from the given informer factory. Returns nil if CSINodeInfo feature is disabled.

func GetPodDisruptionBudgetLister Uses

func GetPodDisruptionBudgetLister(informerFactory informers.SharedInformerFactory) policylisters.PodDisruptionBudgetLister

GetPodDisruptionBudgetLister returns pdb lister from the given informer factory. Returns nil if PodDisruptionBudget feature is disabled.

func InsertPredicateKeyToAlgoProvider Uses

func InsertPredicateKeyToAlgoProvider(providerName, key string) error

InsertPredicateKeyToAlgoProvider insert a fit predicate key to algorithmProvider.

func InsertPredicateKeyToAlgorithmProviderMap Uses

func InsertPredicateKeyToAlgorithmProviderMap(key string)

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

func InsertPriorityKeyToAlgorithmProviderMap Uses

func InsertPriorityKeyToAlgorithmProviderMap(key string)

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

func IsFitPredicateRegistered Uses

func IsFitPredicateRegistered(name string) bool

IsFitPredicateRegistered is useful for testing providers.

func IsPriorityFunctionRegistered Uses

func IsPriorityFunctionRegistered(name string) bool

IsPriorityFunctionRegistered is useful for testing providers.

func ListAlgorithmProviders Uses

func ListAlgorithmProviders() string

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

func ListRegisteredFitPredicates Uses

func ListRegisteredFitPredicates() []string

ListRegisteredFitPredicates returns the registered fit predicates.

func ListRegisteredPriorityFunctions Uses

func ListRegisteredPriorityFunctions() []string

ListRegisteredPriorityFunctions returns the registered priority functions.

func MakeDefaultErrorFunc Uses

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 Uses

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

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

func RegisterAlgorithmProvider Uses

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

RegisterAlgorithmProvider registers a new algorithm provider with the algorithm registry.

func RegisterCustomFitPredicate Uses

func RegisterCustomFitPredicate(policy schedulerapi.PredicatePolicy, pluginArgs *plugins.ConfigProducerArgs) string

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

func RegisterCustomPriorityFunction Uses

func RegisterCustomPriorityFunction(policy schedulerapi.PriorityPolicy, configProducerArgs *plugins.ConfigProducerArgs) string

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

func RegisterFitPredicate Uses

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 Uses

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 Uses

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

func RegisterPredicateMetadataProducerFactory(f PredicateMetadataProducerFactory)

RegisterPredicateMetadataProducerFactory registers a MetadataProducer.

func RegisterPriorityConfigFactory Uses

func RegisterPriorityConfigFactory(name string, pcf PriorityConfigFactory) string

RegisterPriorityConfigFactory registers a priority config factory with its name.

func RegisterPriorityMapReduceFunction Uses

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 Uses

func RegisterPriorityMetadataProducerFactory(f PriorityMetadataProducerFactory)

RegisterPriorityMetadataProducerFactory registers a PriorityMetadataProducerFactory.

func RemoveFitPredicate Uses

func RemoveFitPredicate(name string)

RemoveFitPredicate removes a fit predicate from factory.

func RemovePredicateKeyFromAlgoProvider Uses

func RemovePredicateKeyFromAlgoProvider(providerName, key string) error

RemovePredicateKeyFromAlgoProvider removes a fit predicate key from algorithmProvider.

func RemovePredicateKeyFromAlgorithmProviderMap Uses

func RemovePredicateKeyFromAlgorithmProviderMap(key string)

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

type AlgorithmFactoryArgs Uses

type AlgorithmFactoryArgs struct {
    SharedLister                   schedulerlisters.SharedLister
    InformerFactory                informers.SharedInformerFactory
    VolumeBinder                   *volumebinder.VolumeBinder
    HardPodAffinitySymmetricWeight int32

AlgorithmFactoryArgs are passed to all factory functions.

type AlgorithmProviderConfig Uses

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

AlgorithmProviderConfig is used to store the configuration of algorithm providers.

func GetAlgorithmProvider Uses

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

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

type Binder Uses

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

Binder knows how to write a binding.

type Configurator Uses

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 (*Configurator) Create Uses

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

Create creates a scheduler with the default algorithm provider.

func (*Configurator) CreateFromConfig Uses

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

CreateFromConfig creates a scheduler from the configuration file

func (*Configurator) CreateFromKeys Uses

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

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

func (*Configurator) CreateFromProvider Uses

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

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

func (*Configurator) GetHardPodAffinitySymmetricWeight Uses

func (c *Configurator) GetHardPodAffinitySymmetricWeight() int32

GetHardPodAffinitySymmetricWeight is exposed for testing.

type FitPredicateFactory Uses

type FitPredicateFactory func(AlgorithmFactoryArgs) predicates.FitPredicate

FitPredicateFactory produces a FitPredicate from the given args.

type Option Uses

type Option func(*schedulerOptions)

Option configures a Scheduler

func WithAlgorithmSource Uses

func WithAlgorithmSource(source schedulerapi.SchedulerAlgorithmSource) Option

WithAlgorithmSource sets schedulerAlgorithmSource for Scheduler, the default is a source with DefaultProvider.

func WithBindTimeoutSeconds Uses

func WithBindTimeoutSeconds(bindTimeoutSeconds int64) Option

WithBindTimeoutSeconds sets bindTimeoutSeconds for Scheduler, the default value is 100

func WithFrameworkConfigProducerRegistry Uses

func WithFrameworkConfigProducerRegistry(registry *frameworkplugins.ConfigProducerRegistry) Option

WithFrameworkConfigProducerRegistry sets the framework plugin producer registry.

func WithFrameworkDefaultRegistry Uses

func WithFrameworkDefaultRegistry(registry framework.Registry) Option

WithFrameworkDefaultRegistry sets the framework's default registry. This is only used in integration tests.

func WithFrameworkOutOfTreeRegistry Uses

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 Uses

func WithFrameworkPluginConfig(pluginConfig []schedulerapi.PluginConfig) Option

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

func WithFrameworkPlugins Uses

func WithFrameworkPlugins(plugins *schedulerapi.Plugins) Option

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

func WithHardPodAffinitySymmetricWeight Uses

func WithHardPodAffinitySymmetricWeight(hardPodAffinitySymmetricWeight int32) Option

WithHardPodAffinitySymmetricWeight sets hardPodAffinitySymmetricWeight for Scheduler, the default value is 1

func WithName Uses

func WithName(schedulerName string) Option

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

func WithPercentageOfNodesToScore Uses

func WithPercentageOfNodesToScore(percentageOfNodesToScore int32) Option

WithPercentageOfNodesToScore sets percentageOfNodesToScore for Scheduler, the default value is 50

func WithPodInitialBackoffSeconds Uses

func WithPodInitialBackoffSeconds(podInitialBackoffSeconds int64) Option

WithPodInitialBackoffSeconds sets podInitialBackoffSeconds for Scheduler, the default value is 1

func WithPodMaxBackoffSeconds Uses

func WithPodMaxBackoffSeconds(podMaxBackoffSeconds int64) Option

WithPodMaxBackoffSeconds sets podMaxBackoffSeconds for Scheduler, the default value is 10

func WithPreemptionDisabled Uses

func WithPreemptionDisabled(disablePreemption bool) Option

WithPreemptionDisabled sets disablePreemption for Scheduler, the default value is false

type PredicateMetadataProducerFactory Uses

type PredicateMetadataProducerFactory func(AlgorithmFactoryArgs) predicates.MetadataProducer

PredicateMetadataProducerFactory produces MetadataProducer from the given args.

type PriorityConfigFactory Uses

type PriorityConfigFactory struct {
    MapReduceFunction PriorityFunctionFactory
    Weight            int64

PriorityConfigFactory produces a PriorityConfig from the given function and weight

type PriorityFunctionFactory Uses

type PriorityFunctionFactory func(AlgorithmFactoryArgs) (priorities.PriorityMapFunction, priorities.PriorityReduceFunction)

PriorityFunctionFactory produces map & reduce priority functions from a given args.

type PriorityMetadataProducerFactory Uses

type PriorityMetadataProducerFactory func(AlgorithmFactoryArgs) priorities.MetadataProducer

PriorityMetadataProducerFactory produces MetadataProducer from the given args.

type Scheduler Uses

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

    // 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      schedulerapi.Plugins
    PluginConfig []schedulerapi.PluginConfig
    // 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 Uses

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

New returns a Scheduler

func (*Scheduler) Cache Uses

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

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

func (*Scheduler) Run Uses

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 Uses

type Snapshot struct {
    // contains filtered or unexported fields

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

func RegisteredPredicatesAndPrioritiesSnapshot Uses

func RegisteredPredicatesAndPrioritiesSnapshot() *Snapshot

RegisteredPredicatesAndPrioritiesSnapshot returns a snapshot of current registered predicates and priorities.


algorithmPackage algorithm contains a generic Scheduler interface and several implementations.
apis/extender/v1Package v1 contains scheduler API objects.

Package scheduler imports 52 packages (graph) and is imported by 31 packages. Updated 2019-11-18. Refresh now. Tools for package owners.