algorithm

package
v1.12.1-lite7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package algorithm contains a generic Scheduler interface and several implementations.

Index

Constants

View Source
const (
	// TaintNodeNotReady will be added when node is not ready
	// and feature-gate for TaintBasedEvictions flag is enabled,
	// and removed when node becomes ready.
	TaintNodeNotReady = "node.kubernetes.io/not-ready"

	// DeprecatedTaintNodeNotReady is the deprecated version of TaintNodeNotReady.
	// It is deprecated since 1.9
	DeprecatedTaintNodeNotReady = "node.alpha.kubernetes.io/notReady"

	// TaintNodeUnreachable will be added when node becomes unreachable
	// (corresponding to NodeReady status ConditionUnknown)
	// and feature-gate for TaintBasedEvictions flag is enabled,
	// and removed when node becomes reachable (NodeReady status ConditionTrue).
	TaintNodeUnreachable = "node.kubernetes.io/unreachable"

	// DeprecatedTaintNodeUnreachable is the deprecated version of TaintNodeUnreachable.
	// It is deprecated since 1.9
	DeprecatedTaintNodeUnreachable = "node.alpha.kubernetes.io/unreachable"

	// TaintNodeUnschedulable will be added when node becomes unschedulable
	// and feature-gate for TaintNodesByCondition flag is enabled,
	// and removed when node becomes scheduable.
	TaintNodeUnschedulable = "node.kubernetes.io/unschedulable"

	// TaintNodeOutOfDisk will be added when node becomes out of disk
	// and feature-gate for TaintNodesByCondition flag is enabled,
	// and removed when node has enough disk.
	TaintNodeOutOfDisk = "node.kubernetes.io/out-of-disk"

	// TaintNodeMemoryPressure will be added when node has memory pressure
	// and feature-gate for TaintNodesByCondition flag is enabled,
	// and removed when node has enough memory.
	TaintNodeMemoryPressure = "node.kubernetes.io/memory-pressure"

	// TaintNodeDiskPressure will be added when node has disk pressure
	// and feature-gate for TaintNodesByCondition flag is enabled,
	// and removed when node has enough disk.
	TaintNodeDiskPressure = "node.kubernetes.io/disk-pressure"

	// TaintNodeNetworkUnavailable will be added when node's network is unavailable
	// and feature-gate for TaintNodesByCondition flag is enabled,
	// and removed when network becomes ready.
	TaintNodeNetworkUnavailable = "node.kubernetes.io/network-unavailable"

	// TaintNodePIDPressure will be added when node has pid pressure
	// and feature-gate for TaintNodesByCondition flag is enabled,
	// and removed when node has enough disk.
	TaintNodePIDPressure = "node.kubernetes.io/pid-pressure"

	// TaintExternalCloudProvider sets this taint on a node to mark it as unusable,
	// when kubelet is started with the "external" cloud provider, until a controller
	// from the cloud-controller-manager intitializes this node, and then removes
	// the taint
	TaintExternalCloudProvider = "node.cloudprovider.kubernetes.io/uninitialized"

	// TaintNodeShutdown when node is shutdown in external cloud provider
	TaintNodeShutdown = "node.cloudprovider.kubernetes.io/shutdown"

	// NodeFieldSelectorKeyNodeName ('metadata.name') uses this as node field selector key
	// when selecting node by node's name.
	NodeFieldSelectorKeyNodeName = api.ObjectNameField
)

Variables

View Source
var NodeFieldSelectorKeys = map[string]func(*v1.Node) string{
	NodeFieldSelectorKeyNodeName: func(n *v1.Node) string { return n.Name },
}

NodeFieldSelectorKeys is a map that: the key are node field selector keys; the values are the functions to get the value of the node field.

Functions

func EmptyPriorityMetadataProducer

func EmptyPriorityMetadataProducer(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo) interface{}

EmptyPriorityMetadataProducer returns a no-op PriorityMetadataProducer type.

Types

type ControllerLister

type ControllerLister interface {
	// Lists all the replication controllers
	List(labels.Selector) ([]*v1.ReplicationController, error)
	// Gets the services for the given pod
	GetPodControllers(*v1.Pod) ([]*v1.ReplicationController, error)
}

ControllerLister interface represents anything that can produce a list of ReplicationController; the list is consumed by a scheduler.

type EmptyControllerLister

type EmptyControllerLister struct{}

EmptyControllerLister implements ControllerLister on []v1.ReplicationController returning empty data

func (EmptyControllerLister) GetPodControllers

func (f EmptyControllerLister) GetPodControllers(pod *v1.Pod) (controllers []*v1.ReplicationController, err error)

GetPodControllers returns nil

func (EmptyControllerLister) List

List returns nil

type EmptyReplicaSetLister

type EmptyReplicaSetLister struct{}

EmptyReplicaSetLister implements ReplicaSetLister on []extensions.ReplicaSet returning empty data

func (EmptyReplicaSetLister) GetPodReplicaSets

func (f EmptyReplicaSetLister) GetPodReplicaSets(pod *v1.Pod) (rss []*apps.ReplicaSet, err error)

GetPodReplicaSets returns nil

type EmptyStatefulSetLister

type EmptyStatefulSetLister struct{}

EmptyStatefulSetLister implements StatefulSetLister on []apps.StatefulSet returning empty data.

func (EmptyStatefulSetLister) GetPodStatefulSets

func (f EmptyStatefulSetLister) GetPodStatefulSets(pod *v1.Pod) (sss []*apps.StatefulSet, err error)

GetPodStatefulSets of EmptyStatefulSetLister returns nil.

type FitPredicate

type FitPredicate func(pod *v1.Pod, meta PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []PredicateFailureReason, error)

FitPredicate is a function that indicates if a pod fits into an existing node. The failure information is given by the error.

type NodeLister

type NodeLister interface {
	// We explicitly return []*v1.Node, instead of v1.NodeList, to avoid
	// performing expensive copies that are unneeded.
	List() ([]*v1.Node, error)
}

NodeLister interface represents anything that can list nodes for a scheduler.

type PodLister

type PodLister interface {
	// We explicitly return []*v1.Pod, instead of v1.PodList, to avoid
	// performing expensive copies that are unneeded.
	List(labels.Selector) ([]*v1.Pod, error)
	// This is similar to "List()", but the returned slice does not
	// contain pods that don't pass `podFilter`.
	FilteredList(podFilter schedulercache.PodFilter, selector labels.Selector) ([]*v1.Pod, error)
}

PodLister interface represents anything that can list pods for a scheduler.

type PredicateFailureReason

type PredicateFailureReason interface {
	GetReason() string
}

PredicateFailureReason interface represents the failure reason of a predicate.

type PredicateMetadata

type PredicateMetadata interface {
	ShallowCopy() PredicateMetadata
	AddPod(addedPod *v1.Pod, nodeInfo *schedulercache.NodeInfo) error
	RemovePod(deletedPod *v1.Pod) error
}

PredicateMetadata interface represents anything that can access a predicate metadata.

func EmptyPredicateMetadataProducer

func EmptyPredicateMetadataProducer(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo) PredicateMetadata

EmptyPredicateMetadataProducer returns a no-op MetadataProducer type.

type PredicateMetadataProducer

type PredicateMetadataProducer func(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo) PredicateMetadata

PredicateMetadataProducer is a function that computes predicate metadata for a given pod.

type PriorityConfig

type PriorityConfig struct {
	Name   string
	Map    PriorityMapFunction
	Reduce PriorityReduceFunction
	// TODO: Remove it after migrating all functions to
	// Map-Reduce pattern.
	Function PriorityFunction
	Weight   int
}

PriorityConfig is a config used for a priority function.

type PriorityFunction

type PriorityFunction func(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo, nodes []*v1.Node) (schedulerapi.HostPriorityList, error)

PriorityFunction is a function that computes scores for all nodes. DEPRECATED Use Map-Reduce pattern for priority functions.

type PriorityMapFunction

type PriorityMapFunction func(pod *v1.Pod, meta interface{}, nodeInfo *schedulercache.NodeInfo) (schedulerapi.HostPriority, error)

PriorityMapFunction is a function that computes per-node results for a given node. TODO: Figure out the exact API of this method. TODO: Change interface{} to a specific type.

type PriorityMetadataProducer

type PriorityMetadataProducer func(pod *v1.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo) interface{}

PriorityMetadataProducer is a function that computes metadata for a given pod. This is now used for only for priority functions. For predicates please use PredicateMetadataProducer.

type PriorityReduceFunction

type PriorityReduceFunction func(pod *v1.Pod, meta interface{}, nodeNameToInfo map[string]*schedulercache.NodeInfo, result schedulerapi.HostPriorityList) error

PriorityReduceFunction is a function that aggregated per-node results and computes final scores for all nodes. TODO: Figure out the exact API of this method. TODO: Change interface{} to a specific type.

type ReplicaSetLister

type ReplicaSetLister interface {
	// Gets the replicasets for the given pod
	GetPodReplicaSets(*v1.Pod) ([]*apps.ReplicaSet, error)
}

ReplicaSetLister interface represents anything that can produce a list of ReplicaSet; the list is consumed by a scheduler.

type ScheduleAlgorithm

type ScheduleAlgorithm interface {
	Schedule(*v1.Pod, NodeLister) (selectedMachine string, err error)
	// Preempt receives scheduling errors for a pod and tries to create room for
	// the pod by preempting lower priority pods if possible.
	// It returns the node where preemption happened, a list of preempted pods, a
	// list of pods whose nominated node name should be removed, and error if any.
	Preempt(*v1.Pod, NodeLister, error) (selectedNode *v1.Node, preemptedPods []*v1.Pod, cleanupNominatedPods []*v1.Pod, err error)
	// Predicates() returns a pointer to a map of predicate functions. This is
	// exposed for testing.
	Predicates() map[string]FitPredicate
	// Prioritizers returns a slice of priority config. This is exposed for
	// testing.
	Prioritizers() []PriorityConfig
}

ScheduleAlgorithm is an interface implemented by things that know how to schedule pods onto machines.

type SchedulerExtender

type SchedulerExtender interface {
	// Filter based on extender-implemented predicate functions. The filtered list is
	// expected to be a subset of the supplied list. failedNodesMap optionally contains
	// the list of failed nodes and failure reasons.
	Filter(pod *v1.Pod,
		nodes []*v1.Node, nodeNameToInfo map[string]*schedulercache.NodeInfo,
	) (filteredNodes []*v1.Node, failedNodesMap schedulerapi.FailedNodesMap, err error)

	// Prioritize based on extender-implemented priority functions. The returned scores & weight
	// are used to compute the weighted score for an extender. The weighted scores are added to
	// the scores computed  by Kubernetes scheduler. The total scores are used to do the host selection.
	Prioritize(pod *v1.Pod, nodes []*v1.Node) (hostPriorities *schedulerapi.HostPriorityList, weight int, err error)

	// Bind delegates the action of binding a pod to a node to the extender.
	Bind(binding *v1.Binding) error

	// IsBinder returns whether this extender is configured for the Bind method.
	IsBinder() bool

	// IsInterested returns true if at least one extended resource requested by
	// this pod is managed by this extender.
	IsInterested(pod *v1.Pod) bool

	// ProcessPreemption returns nodes with their victim pods processed by extender based on
	// given:
	//   1. Pod to schedule
	//   2. Candidate nodes and victim pods (nodeToVictims) generated by previous scheduling process.
	//   3. nodeNameToInfo to restore v1.Node from node name if extender cache is enabled.
	// The possible changes made by extender may include:
	//   1. Subset of given candidate nodes after preemption phase of extender.
	//   2. A different set of victim pod for every given candidate node after preemption phase of extender.
	ProcessPreemption(
		pod *v1.Pod,
		nodeToVictims map[*v1.Node]*schedulerapi.Victims,
		nodeNameToInfo map[string]*schedulercache.NodeInfo,
	) (map[*v1.Node]*schedulerapi.Victims, error)

	// SupportsPreemption returns if the scheduler extender support preemption or not.
	SupportsPreemption() bool

	// IsIgnorable returns true indicates scheduling should not fail when this extender
	// is unavailable. This gives scheduler ability to fail fast and tolerate non-critical extenders as well.
	IsIgnorable() bool
}

SchedulerExtender is an interface for external processes to influence scheduling decisions made by Kubernetes. This is typically needed for resources not directly managed by Kubernetes.

type ServiceLister

type ServiceLister interface {
	// Lists all the services
	List(labels.Selector) ([]*v1.Service, error)
	// Gets the services for the given pod
	GetPodServices(*v1.Pod) ([]*v1.Service, error)
}

ServiceLister interface represents anything that can produce a list of services; the list is consumed by a scheduler.

type StatefulSetLister

type StatefulSetLister interface {
	// Gets the StatefulSet for the given pod.
	GetPodStatefulSets(*v1.Pod) ([]*apps.StatefulSet, error)
}

StatefulSetLister interface represents anything that can produce a list of StatefulSet; the list is consumed by a scheduler.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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