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

package scheduler

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


Package Files

eventhandlers.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"

func AddAllEventHandlers Uses

func AddAllEventHandlers(
    sched *Scheduler,
    schedulerName string,
    nodeInformer coreinformers.NodeInformer,
    podInformer coreinformers.PodInformer,
    pvInformer coreinformers.PersistentVolumeInformer,
    pvcInformer coreinformers.PersistentVolumeClaimInformer,
    serviceInformer coreinformers.ServiceInformer,
    storageClassInformer storageinformersv1.StorageClassInformer,
    csiNodeInformer storageinformersv1beta1.CSINodeInformer,

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

type Option Uses

type Option func(*schedulerOptions)

Option configures a Scheduler

func WithBindTimeoutSeconds Uses

func WithBindTimeoutSeconds(bindTimeoutSeconds int64) Option

WithBindTimeoutSeconds sets bindTimeoutSeconds for Scheduler, the default value is 100

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

func WithPreemptionDisabled(disablePreemption bool) Option

WithPreemptionDisabled sets disablePreemption for Scheduler, the default value is false

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) factory.Binder
    // PodConditionUpdater is used only in case of scheduling errors. If we succeed
    // with scheduling, PodScheduled condition will be updated in apiserver in /bind
    // handler so that binding and setting PodCondition it is atomic.
    PodConditionUpdater factory.PodConditionUpdater
    // PodPreemptor is used to evict pods and update 'NominatedNode' field of
    // the preemptor pod.
    PodPreemptor factory.PodPreemptor
    // 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() *v1.Pod

    // 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(*v1.Pod, 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

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,
    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,
    recorder events.EventRecorder,
    schedulerAlgorithmSource kubeschedulerconfig.SchedulerAlgorithmSource,
    stopCh <-chan struct{},
    registry framework.Registry,
    plugins *kubeschedulerconfig.Plugins,
    pluginConfig []kubeschedulerconfig.PluginConfig,
    opts ...func(o *schedulerOptions)) (*Scheduler, error)

New returns a Scheduler

func NewFromConfig Uses

func NewFromConfig(config *factory.Config) *Scheduler

NewFromConfig returns a new scheduler using the provided Config.

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

Run begins watching and scheduling. It waits for cache to be synced, then starts a goroutine and returns immediately.


algorithmPackage algorithm contains a generic Scheduler interface and several implementations.
apiPackage api contains scheduler API objects.
api/v1Package v1 contains scheduler API objects.
factoryPackage factory can set up a scheduler.

Package scheduler imports 33 packages (graph) and is imported by 23 packages. Updated 2019-09-21. Refresh now. Tools for package owners.