scheduling

package
v0.35.8 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 26 Imported by: 20

Documentation

Index

Constants

View Source
const IsDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class"

Variables

View Source
var AllowUndefinedWellKnownLabels = func(options CompatibilityOptions) CompatibilityOptions {
	options.AllowUndefined = v1beta1.WellKnownLabels
	return options
}
View Source
var KnownEphemeralTaints = []v1.Taint{
	{Key: v1.TaintNodeNotReady, Effect: v1.TaintEffectNoSchedule},
	{Key: v1.TaintNodeUnreachable, Effect: v1.TaintEffectNoSchedule},
	{Key: cloudproviderapi.TaintExternalCloudProvider, Effect: v1.TaintEffectNoSchedule, Value: "true"},
}

KnownEphemeralTaints are taints that are expected to be added to a node while it's initializing If the node is a Karpenter-managed node, we don't consider these taints while the node is uninitialized since we expect these taints to eventually be removed

Functions

func DiscoverDefaultStorageClassName

func DiscoverDefaultStorageClassName(ctx context.Context, kubeClient client.Client) (string, error)

func HasPreferredNodeAffinity

func HasPreferredNodeAffinity(p *v1.Pod) bool

HasPreferredNodeAffinity returns true if the pod has a preferred node affinity term

func ResetDefaultStorageClass

func ResetDefaultStorageClass()

ResetDefaultStorageClass is intended to be called from unit tests to reset the default storage class

Types

type CompatibilityOptions added in v0.34.0

type CompatibilityOptions struct {
	AllowUndefined sets.Set[string]
}

type HostPort

type HostPort struct {
	IP       net.IP
	Port     int32
	Protocol v1.Protocol
}

+k8s:deepcopy-gen=true

func GetHostPorts

func GetHostPorts(pod *v1.Pod) []HostPort

func (*HostPort) DeepCopy

func (in *HostPort) DeepCopy() *HostPort

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostPort.

func (*HostPort) DeepCopyInto

func (in *HostPort) DeepCopyInto(out *HostPort)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (HostPort) Matches

func (p HostPort) Matches(rhs HostPort) bool

func (HostPort) String

func (p HostPort) String() string

type HostPortUsage

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

HostPortUsage tracks HostPort usage within a node. On a node, each <hostIP, hostPort, protocol> used by pods bound to the node must be unique. We need to track this to keep an accurate concept of what pods can potentially schedule together. +k8s:deepcopy-gen=true

func NewHostPortUsage

func NewHostPortUsage() *HostPortUsage

func (*HostPortUsage) Add

func (u *HostPortUsage) Add(usedBy *v1.Pod, ports []HostPort)

Add adds a port to the HostPortUsage

func (*HostPortUsage) Conflicts

func (u *HostPortUsage) Conflicts(usedBy *v1.Pod, ports []HostPort) error

func (*HostPortUsage) DeepCopy

func (in *HostPortUsage) DeepCopy() *HostPortUsage

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostPortUsage.

func (*HostPortUsage) DeepCopyInto

func (in *HostPortUsage) DeepCopyInto(out *HostPortUsage)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*HostPortUsage) DeletePod

func (u *HostPortUsage) DeletePod(key types.NamespacedName)

DeletePod deletes all host port usage from the HostPortUsage that were created by the pod with the given name.

type Requirement

type Requirement struct {
	Key string

	MinValues *int
	// contains filtered or unexported fields
}

Requirement is an efficient represenatation of v1.NodeSelectorRequirement

func NewRequirement

func NewRequirement(key string, operator v1.NodeSelectorOperator, values ...string) *Requirement

func NewRequirementWithFlexibility added in v0.35.0

func NewRequirementWithFlexibility(key string, operator v1.NodeSelectorOperator, minValues *int, values ...string) *Requirement

NewRequirementWithFlexibility constructs new requirement from the combination of key, values, minValues and the operator that connects the keys and values.

func (*Requirement) Any

func (r *Requirement) Any() string

func (*Requirement) Has

func (r *Requirement) Has(value string) bool

Has returns true if the requirement allows the value

func (*Requirement) Insert

func (r *Requirement) Insert(items ...string)

func (*Requirement) Intersection

func (r *Requirement) Intersection(requirement *Requirement) *Requirement

Intersection constraints the Requirement from the incoming requirements nolint:gocyclo

func (*Requirement) Len

func (r *Requirement) Len() int

func (*Requirement) NodeSelectorRequirement

func (r *Requirement) NodeSelectorRequirement() v1beta1.NodeSelectorRequirementWithMinValues

func (*Requirement) Operator

func (r *Requirement) Operator() v1.NodeSelectorOperator

func (*Requirement) String

func (r *Requirement) String() string

func (*Requirement) Values

func (r *Requirement) Values() []string

type Requirements

type Requirements map[string]*Requirement

Requirements are an efficient set representation under the hood. Since its underlying types are slices and maps, this type should not be used as a pointer.

func NewLabelRequirements

func NewLabelRequirements(labels map[string]string) Requirements

NewLabelRequirements constructs requirements from labels

func NewNodeSelectorRequirements

func NewNodeSelectorRequirements(requirements ...v1.NodeSelectorRequirement) Requirements

NewRequirements constructs requirements from NodeSelectorRequirements

func NewNodeSelectorRequirementsWithMinValues added in v0.35.0

func NewNodeSelectorRequirementsWithMinValues(requirements ...v1beta1.NodeSelectorRequirementWithMinValues) Requirements

NewRequirements constructs requirements from NodeSelectorRequirementWithMinValues

func NewPodRequirements

func NewPodRequirements(pod *v1.Pod) Requirements

NewPodRequirements constructs requirements from a pod and treats any preferred requirements as required.

func NewRequirements

func NewRequirements(requirements ...*Requirement) Requirements

func NewStrictPodRequirements

func NewStrictPodRequirements(pod *v1.Pod) Requirements

NewStrictPodRequirements constructs requirements from a pod and only includes true requirements (not preferences).

func (Requirements) Add

func (r Requirements) Add(requirements ...*Requirement)

Add requirements to provided requirements. Mutates existing requirements

func (Requirements) Compatible

func (r Requirements) Compatible(requirements Requirements, options ...functional.Option[CompatibilityOptions]) (errs error)

Compatible ensures the provided requirements can loosely be met.

func (Requirements) Get

func (r Requirements) Get(key string) *Requirement

func (Requirements) Has

func (r Requirements) Has(key string) bool

func (Requirements) HasMinValues added in v0.35.0

func (r Requirements) HasMinValues() bool

func (Requirements) Intersects

func (r Requirements) Intersects(requirements Requirements) (errs error)

Intersects returns errors if the requirements don't have overlapping values, undefined keys are allowed

func (Requirements) Keys

func (r Requirements) Keys() sets.Set[string]

Keys returns unique set of the label keys from the requirements

func (Requirements) Labels

func (r Requirements) Labels() map[string]string

func (Requirements) NodeSelectorRequirements

func (r Requirements) NodeSelectorRequirements() []v1beta1.NodeSelectorRequirementWithMinValues

func (Requirements) String

func (r Requirements) String() string

func (Requirements) Values

func (r Requirements) Values() []*Requirement

type Taints

type Taints []v1.Taint

Taints is a decorated alias type for []v1.Taint

func (Taints) Merge

func (ts Taints) Merge(with Taints) Taints

Merge merges in taints with the passed in taints.

func (Taints) Tolerates

func (ts Taints) Tolerates(pod *v1.Pod) (errs error)

Tolerates returns true if the pod tolerates all taints.

type VolumeUsage

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

VolumeUsage tracks volume limits on a per node basis. The number of volumes that can be mounted varies by instance type. We need to be aware and track the mounted volume usage to inform our awareness of which pods can schedule to which nodes. +k8s:deepcopy-gen=true

func NewVolumeUsage

func NewVolumeUsage() *VolumeUsage

func (*VolumeUsage) Add

func (v *VolumeUsage) Add(pod *v1.Pod, volumes Volumes)

func (*VolumeUsage) AddLimit

func (v *VolumeUsage) AddLimit(storageDriver string, value int)

func (*VolumeUsage) DeepCopy

func (in *VolumeUsage) DeepCopy() *VolumeUsage

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VolumeUsage.

func (*VolumeUsage) DeepCopyInto

func (in *VolumeUsage) DeepCopyInto(out *VolumeUsage)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*VolumeUsage) DeletePod

func (v *VolumeUsage) DeletePod(key types.NamespacedName)

func (*VolumeUsage) ExceedsLimits

func (v *VolumeUsage) ExceedsLimits(vols Volumes) error

type Volumes

type Volumes map[string]sets.Set[string]

+k8s:deepcopy-gen=true

func GetVolumes

func GetVolumes(ctx context.Context, kubeClient client.Client, pod *v1.Pod) (Volumes, error)

func (Volumes) Add

func (u Volumes) Add(provisioner string, pvcID string)

func (Volumes) DeepCopy

func (in Volumes) DeepCopy() Volumes

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Volumes.

func (Volumes) DeepCopyInto

func (in Volumes) DeepCopyInto(out *Volumes)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (Volumes) Insert

func (u Volumes) Insert(volumes Volumes)

func (Volumes) Union

func (u Volumes) Union(vol Volumes) Volumes

Jump to

Keyboard shortcuts

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