scheduling

package
v0.0.0-...-d7985ca Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoredForTopology

func IgnoredForTopology(p *v1.Pod) bool

func InstanceTypeList

func InstanceTypeList(instanceTypeOptions []*cloudprovider.InstanceType) string

func TopologyListOptions

func TopologyListOptions(namespace string, labelSelector *metav1.LabelSelector) *client.ListOptions

Types

type ExistingNode

type ExistingNode struct {
	*state.Node

	Pods []*v1.Pod
	// contains filtered or unexported fields
}

func NewExistingNode

func NewExistingNode(n *state.Node, topology *Topology, daemonResources v1.ResourceList) *ExistingNode

func (*ExistingNode) Add

func (n *ExistingNode) Add(ctx context.Context, pod *v1.Pod) error

type Machine

type Machine struct {
	MachineTemplate

	Pods []*v1.Pod
	// contains filtered or unexported fields
}

Machine is a set of constraints, compatible pods, and possible instance types that could fulfill these constraints. This will be turned into one or more actual node instances within the cluster after bin packing.

func NewMachine

func NewMachine(machineTemplate *MachineTemplate, topology *Topology, daemonResources v1.ResourceList, instanceTypes []*cloudprovider.InstanceType) *Machine

func (*Machine) Add

func (m *Machine) Add(ctx context.Context, pod *v1.Pod) error

func (*Machine) FinalizeScheduling

func (m *Machine) FinalizeScheduling()

FinalizeScheduling is called once all scheduling has completed and allows the node to perform any cleanup necessary before its requirements are used for instance launching

func (*Machine) String

func (m *Machine) String() string

type MachineTemplate

type MachineTemplate struct {
	ProvisionerName     string
	InstanceTypeOptions cloudprovider.InstanceTypes
	Provider            *v1alpha5.Provider
	ProviderRef         *v1alpha5.ProviderRef
	Annotations         map[string]string
	Labels              map[string]string
	Taints              scheduling.Taints
	StartupTaints       scheduling.Taints
	Requirements        scheduling.Requirements
	Requests            v1.ResourceList
	Kubelet             *v1alpha5.KubeletConfiguration
}

MachineTemplate encapsulates the fields required to create a node and mirrors the fields in Provisioner. These structs are maintained separately in order for fields like Requirements to be able to be stored more efficiently.

func NewMachineTemplate

func NewMachineTemplate(provisioner *v1alpha5.Provisioner) *MachineTemplate

func (*MachineTemplate) ToMachine

func (i *MachineTemplate) ToMachine(owner *v1alpha5.Provisioner) *v1alpha5.Machine

func (*MachineTemplate) ToNode

func (i *MachineTemplate) ToNode() *v1.Node

type Preferences

type Preferences struct {
	// ToleratePreferNoSchedule controls if preference relaxation adds a toleration for PreferNoSchedule taints.  This only
	// helps if there is a corresponding taint, so we don't always add it.
	ToleratePreferNoSchedule bool
}

func (*Preferences) Relax

func (p *Preferences) Relax(ctx context.Context, pod *v1.Pod) bool

type Queue

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

Queue is a queue of pods that is scheduled. It's used to attempt to schedule pods as long as we are making progress in scheduling. This is sometimes required to maintain zonal topology spreads with constrained pods, and can satisfy pod affinities that occur in a batch of pods if there are enough constraints provided.

func NewQueue

func NewQueue(pods ...*v1.Pod) *Queue

NewQueue constructs a new queue given the input pods, sorting them to optimize for bin-packing into nodes.

func (*Queue) List

func (q *Queue) List() []*v1.Pod

func (*Queue) Pop

func (q *Queue) Pop() (*v1.Pod, bool)

Pop returns the next pod or false if no longer making progress

func (*Queue) Push

func (q *Queue) Push(pod *v1.Pod, relaxed bool)

Push a pod onto the queue, counting each time a pod is immediately requeued. This is used to detect staleness.

type Scheduler

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

func NewScheduler

func NewScheduler(ctx context.Context, kubeClient client.Client, machines []*MachineTemplate,
	provisioners []v1alpha5.Provisioner, cluster *state.Cluster, stateNodes []*state.Node, topology *Topology,
	instanceTypes map[string][]*cloudprovider.InstanceType, daemonSetPods []*v1.Pod,
	recorder events.Recorder, opts SchedulerOptions) *Scheduler

func (*Scheduler) Solve

func (s *Scheduler) Solve(ctx context.Context, pods []*v1.Pod) ([]*Machine, []*ExistingNode, error)

type SchedulerOptions

type SchedulerOptions struct {
	// SimulationMode if true will prevent recording of the pod nomination decisions as events
	SimulationMode bool
}

SchedulerOptions can be used to control the scheduling, these options are currently only used during consolidation.

type Topology

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

func NewTopology

func NewTopology(ctx context.Context, kubeClient client.Client, cluster *state.Cluster, domains map[string]utilsets.String, pods []*v1.Pod) (*Topology, error)

func (*Topology) AddRequirements

func (t *Topology) AddRequirements(podRequirements, nodeRequirements scheduling.Requirements, p *v1.Pod) (scheduling.Requirements, error)

AddRequirements tightens the input requirements by adding additional requirements that are being enforced by topology spreads affinities, anti-affinities or inverse anti-affinities. The nodeHostname is the hostname that we are currently considering placing the pod on. It returns these newly tightened requirements, or an error in the case of a set of requirements that cannot be satisfied.

func (*Topology) Record

func (t *Topology) Record(p *v1.Pod, requirements scheduling.Requirements)

Record records the topology changes given that pod p schedule on a node with the given requirements

func (*Topology) Register

func (t *Topology) Register(topologyKey string, domain string)

Register is used to register a domain as available across topologies for the given topology key.

func (*Topology) Update

func (t *Topology) Update(ctx context.Context, p *v1.Pod) error

Update unregisters the pod as the owner of all affinities and then creates any new topologies based on the pod spec registered the pod as the owner of all associated affinities, new or old. This allows Update() to be called after relaxation of a preference to properly break the topology <-> owner relationship so that the preferred topology will no longer influence scheduling.

type TopologyGroup

type TopologyGroup struct {
	// Hashed Fields
	Key  string
	Type TopologyType
	// contains filtered or unexported fields
}

TopologyGroup is used to track pod counts that match a selector by the topology domain (e.g. SELECT COUNT(*) FROM pods GROUP BY(topology_ke

func NewTopologyGroup

func NewTopologyGroup(topologyType TopologyType, topologyKey string, pod *v1.Pod, namespaces utilsets.String, labelSelector *metav1.LabelSelector, maxSkew int32, domains utilsets.String) *TopologyGroup

func (*TopologyGroup) AddOwner

func (t *TopologyGroup) AddOwner(key types.UID)

func (*TopologyGroup) Counts

func (t *TopologyGroup) Counts(pod *v1.Pod, requirements scheduling.Requirements) bool

Counts returns true if the pod would count for the topology, given that it schedule to a node with the provided requirements

func (*TopologyGroup) Get

func (t *TopologyGroup) Get(pod *v1.Pod, podDomains, nodeDomains *scheduling.Requirement) *scheduling.Requirement

func (*TopologyGroup) Hash

func (t *TopologyGroup) Hash() uint64

Hash is used so we can track single topologies that affect multiple groups of pods. If a deployment has 100x pods with self anti-affinity, we track that as a single topology with 100 owners instead of 100x topologies.

func (*TopologyGroup) IsOwnedBy

func (t *TopologyGroup) IsOwnedBy(key types.UID) bool

func (*TopologyGroup) Record

func (t *TopologyGroup) Record(domains ...string)

func (*TopologyGroup) Register

func (t *TopologyGroup) Register(domains ...string)

Register ensures that the topology is aware of the given domain names.

func (*TopologyGroup) RemoveOwner

func (t *TopologyGroup) RemoveOwner(key types.UID)

type TopologyNodeFilter

type TopologyNodeFilter []scheduling.Requirements

TopologyNodeFilter is used to determine if a given actual node or scheduling node matches the pod's node selectors and required node affinity terms. This is used with topology spread constraints to determine if the node should be included for topology counting purposes. This is only used with topology spread constraints as affinities/anti-affinities always count across all nodes. A nil or zero-value TopologyNodeFilter behaves well and the filter returns true for all nodes.

func MakeTopologyNodeFilter

func MakeTopologyNodeFilter(p *v1.Pod) TopologyNodeFilter

func (TopologyNodeFilter) Matches

func (t TopologyNodeFilter) Matches(node *v1.Node) bool

Matches returns true if the TopologyNodeFilter doesn't prohibit node from the participating in the topology

func (TopologyNodeFilter) MatchesRequirements

func (t TopologyNodeFilter) MatchesRequirements(requirements scheduling.Requirements) bool

MatchesRequirements returns true if the TopologyNodeFilter doesn't prohibit a node with the requirements from participating in the topology. This method allows checking the requirements from a scheduling.Machine to see if the node we will soon create participates in this topology.

type TopologyType

type TopologyType byte
const (
	TopologyTypeSpread TopologyType = iota
	TopologyTypePodAffinity
	TopologyTypePodAntiAffinity
)

func (TopologyType) String

func (t TopologyType) String() string

Jump to

Keyboard shortcuts

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