kubernetes: github.com/erimatnor/kubernetes/pkg/scheduler Index | Files

package scheduler

import "github.com/erimatnor/kubernetes/pkg/scheduler"

Package scheduler contains a generic Scheduler interface and several implementations.

Index

Package Files

doc.go generic_scheduler.go listers.go predicates.go priorities.go scheduler.go spreading.go types.go

func CheckPodsExceedingCapacity Uses

func CheckPodsExceedingCapacity(pods []*api.Pod, capacity api.ResourceList) (fitting []*api.Pod, notFitting []*api.Pod)

func MapPodsToMachines Uses

func MapPodsToMachines(lister PodLister) (map[string][]*api.Pod, error)

MapPodsToMachines obtains a list of pods and pivots that list into a map where the keys are host names and the values are the list of pods running on that host.

func NoDiskConflict Uses

func NoDiskConflict(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

NoDiskConflict evaluates if a pod can fit due to the volumes it requests, and those that are already mounted. Some times of volumes are mounted onto node machines. For now, these mounts are exclusive so if there is already a volume mounted on that node, another pod can't schedule there. This is GCE specific for now. TODO: migrate this into some per-volume specific code?

func PodFitsHost Uses

func PodFitsHost(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

func PodFitsPorts Uses

func PodFitsPorts(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

func PodMatchesNodeLabels Uses

func PodMatchesNodeLabels(pod *api.Pod, node *api.Node) bool

type ClientNodeInfo Uses

type ClientNodeInfo struct {
    *client.Client
}

func (ClientNodeInfo) GetNodeInfo Uses

func (nodes ClientNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)

type FailedPredicateMap Uses

type FailedPredicateMap map[string]util.StringSet

type FakeMinionLister Uses

type FakeMinionLister api.NodeList

FakeMinionLister implements MinionLister on a []string for test purposes.

func (FakeMinionLister) List Uses

func (f FakeMinionLister) List() (api.NodeList, error)

List returns minions as a []string.

type FakePodLister Uses

type FakePodLister []*api.Pod

FakePodLister implements PodLister on an []api.Pods for test purposes.

func (FakePodLister) List Uses

func (f FakePodLister) List(s labels.Selector) (selected []*api.Pod, err error)

List returns []*api.Pod matching a query.

type FakeServiceLister Uses

type FakeServiceLister []api.Service

FakeServiceLister implements ServiceLister on []api.Service for test purposes.

func (FakeServiceLister) GetPodServices Uses

func (f FakeServiceLister) GetPodServices(pod *api.Pod) (services []api.Service, err error)

GetPodServices gets the services that have the selector that match the labels on the given pod

func (FakeServiceLister) List Uses

func (f FakeServiceLister) List() (api.ServiceList, error)

FakeServiceLister returns api.ServiceList, the list of all services.

type FitError Uses

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

func (*FitError) Error Uses

func (f *FitError) Error() string

implementation of the error interface

type FitPredicate Uses

type FitPredicate func(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

FitPredicate is a function that indicates if a pod fits into an existing node.

func NewNodeLabelPredicate Uses

func NewNodeLabelPredicate(info NodeInfo, labels []string, presence bool) FitPredicate

func NewResourceFitPredicate Uses

func NewResourceFitPredicate(info NodeInfo) FitPredicate

func NewSelectorMatchPredicate Uses

func NewSelectorMatchPredicate(info NodeInfo) FitPredicate

func NewServiceAffinityPredicate Uses

func NewServiceAffinityPredicate(podLister PodLister, serviceLister ServiceLister, nodeInfo NodeInfo, labels []string) FitPredicate

type HostPriority Uses

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

HostPriority represents the priority of scheduling to a particular host, lower priority is better.

type HostPriorityList Uses

type HostPriorityList []HostPriority

func BalancedResourceAllocation Uses

func BalancedResourceAllocation(pod *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)

BalancedResourceAllocation favors nodes with balanced resource usage rate. BalancedResourceAllocation should **NOT** be used alone, and **MUST** be used together with LeastRequestedPriority. It calculates the difference between the cpu and memory fracion of capacity, and prioritizes the host based on how close the two metrics are to each other. Detail: score = 10 - abs(cpuFraction-memoryFraction)*10. The algorithm is partly inspired by: "Wei Huang et al. An Energy Efficient Virtual Machine Placement Algorithm with Balanced Resource Utilization"

func EqualPriority Uses

func EqualPriority(_ *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)

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

func LeastRequestedPriority Uses

func LeastRequestedPriority(pod *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)

LeastRequestedPriority is a priority function that favors nodes with fewer requested resources. It calculates the percentage of memory and CPU requested by pods scheduled on the node, and prioritizes based on the minimum of the average of the fraction of requested to capacity. Details: (Sum(requested cpu) / Capacity + Sum(requested memory) / Capacity) * 50

func (HostPriorityList) Len Uses

func (h HostPriorityList) Len() int

func (HostPriorityList) Less Uses

func (h HostPriorityList) Less(i, j int) bool

func (HostPriorityList) Swap Uses

func (h HostPriorityList) Swap(i, j int)

type MinionLister Uses

type MinionLister interface {
    List() (list api.NodeList, err error)
}

MinionLister interface represents anything that can list minions for a scheduler.

type NodeInfo Uses

type NodeInfo interface {
    GetNodeInfo(nodeID string) (*api.Node, error)
}

type NodeLabelChecker Uses

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

func (*NodeLabelChecker) CheckNodeLabelPresence Uses

func (n *NodeLabelChecker) CheckNodeLabelPresence(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

CheckNodeLabelPresence checks whether all of the specified labels exists on a minion or not, regardless of their value If "presence" is false, then returns false if any of the requested labels matches any of the minion's labels, otherwise returns true. If "presence" is true, then returns false if any of the requested labels does not match any of the minion's labels, otherwise returns true.

Consider the cases where the minions are placed in regions/zones/racks and these are identified by labels In some cases, it is required that only minions that are part of ANY of the defined regions/zones/racks be selected

Alternately, eliminating minions that have a certain label, regardless of value, is also useful A minion may have a label with "retiring" as key and the date as the value and it may be desirable to avoid scheduling new pods on this minion

type NodeLabelPrioritizer Uses

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

func (*NodeLabelPrioritizer) CalculateNodeLabelPriority Uses

func (n *NodeLabelPrioritizer) CalculateNodeLabelPriority(pod *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)

CalculateNodeLabelPriority checks whether a particular label exists on a minion or not, regardless of its value. If presence is true, prioritizes minions that have the specified label, regardless of value. If presence is false, prioritizes minions that do not have the specified label.

type NodeSelector Uses

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

func (*NodeSelector) PodSelectorMatches Uses

func (n *NodeSelector) PodSelectorMatches(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

type PodLister Uses

type PodLister interface {
    // TODO: make this exactly the same as client's Pods(ns).List() method, by returning a api.PodList
    List(labels.Selector) ([]*api.Pod, error)
}

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

type PriorityConfig Uses

type PriorityConfig struct {
    Function PriorityFunction
    Weight   int
}

type PriorityFunction Uses

type PriorityFunction func(pod *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)

func NewNodeLabelPriority Uses

func NewNodeLabelPriority(label string, presence bool) PriorityFunction

func NewServiceAntiAffinityPriority Uses

func NewServiceAntiAffinityPriority(serviceLister ServiceLister, label string) PriorityFunction

func NewServiceSpreadPriority Uses

func NewServiceSpreadPriority(serviceLister ServiceLister) PriorityFunction

type ResourceFit Uses

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

func (*ResourceFit) PodFitsResources Uses

func (r *ResourceFit) PodFitsResources(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

PodFitsResources calculates fit based on requested, rather than used resources

type Scheduler Uses

type Scheduler interface {
    Schedule(*api.Pod, MinionLister) (selectedMachine string, err error)
}

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

func NewGenericScheduler Uses

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

type ServiceAffinity Uses

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

func (*ServiceAffinity) CheckServiceAffinity Uses

func (s *ServiceAffinity) CheckServiceAffinity(pod *api.Pod, existingPods []*api.Pod, node string) (bool, error)

CheckServiceAffinity ensures that only the minions that match the specified labels are considered for scheduling. The set of labels to be considered are provided to the struct (ServiceAffinity). The pod is checked for the labels and any missing labels are then checked in the minion that hosts the service pods (peers) for the given pod.

We add an implicit selector requiring some particular value V for label L to a pod, if: - L is listed in the ServiceAffinity object that is passed into the function - the pod does not have any NodeSelector for L - some other pod from the same service is already scheduled onto a minion that has value V for label L

type ServiceAntiAffinity Uses

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

func (*ServiceAntiAffinity) CalculateAntiAffinityPriority Uses

func (s *ServiceAntiAffinity) CalculateAntiAffinityPriority(pod *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)

CalculateAntiAffinityPriority spreads pods by minimizing the number of pods belonging to the same service on machines with the same value for a particular label. The label to be considered is provided to the struct (ServiceAntiAffinity).

type ServiceLister Uses

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

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

type ServiceSpread Uses

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

func (*ServiceSpread) CalculateSpreadPriority Uses

func (s *ServiceSpread) CalculateSpreadPriority(pod *api.Pod, podLister PodLister, minionLister MinionLister) (HostPriorityList, error)

CalculateSpreadPriority spreads pods by minimizing the number of pods belonging to the same service on the same machine.

type StaticNodeInfo Uses

type StaticNodeInfo struct {
    *api.NodeList
}

func (StaticNodeInfo) GetNodeInfo Uses

func (nodes StaticNodeInfo) GetNodeInfo(nodeID string) (*api.Node, error)

Package scheduler imports 11 packages (graph). Updated 2017-05-11. Refresh now. Tools for package owners.