Documentation
¶
Index ¶
- Variables
- func AdjustedPrice(instanceTypePrice float64, change string) float64
- func IgnoreNodeClaimNotFoundError(err error) error
- func IsInsufficientCapacityError(err error) bool
- func IsNodeClaimNotFoundError(err error) bool
- func IsNodeClassNotReadyError(err error) bool
- func IsUnevaluatedNodePoolError(err error) bool
- type CloudProvider
- type CreateError
- type DriftReason
- type InstanceType
- func (i *InstanceType) Allocatable() corev1.ResourceList
- func (i *InstanceType) ApplyCapacityOverlay(updatedCapacity corev1.ResourceList)
- func (in *InstanceType) DeepCopy() *InstanceType
- func (in *InstanceType) DeepCopyInto(out *InstanceType)
- func (i *InstanceType) IsCapacityOverlayApplied() bool
- func (i *InstanceType) IsPricingOverlayApplied() bool
- type InstanceTypeOverhead
- type InstanceTypes
- func (its InstanceTypes) Compatible(requirements scheduling.Requirements) InstanceTypes
- func (its InstanceTypes) OrderByPrice(reqs scheduling.Requirements) InstanceTypes
- func (its InstanceTypes) SatisfiesMinValues(requirements scheduling.Requirements) (minNeededInstanceTypes int, unsatisfiableMinValues map[string]int, err error)
- func (its InstanceTypes) Truncate(ctx context.Context, requirements scheduling.Requirements, maxItems int) (InstanceTypes, error)
- type InsufficientCapacityError
- type NodeClaimNotFoundError
- type NodeClassNotReadyError
- type Offering
- func (o *Offering) ApplyPriceOverlay(UpdatedPrice string)
- func (o *Offering) CapacityType() string
- func (in *Offering) DeepCopy() *Offering
- func (in *Offering) DeepCopyInto(out *Offering)
- func (o *Offering) IsPriceOverlaid() bool
- func (o *Offering) ReservationID() string
- func (o *Offering) Zone() string
- type Offerings
- func (ofs Offerings) Available() Offerings
- func (ofs Offerings) Cheapest() *Offering
- func (ofs Offerings) Compatible(reqs scheduling.Requirements) Offerings
- func (in Offerings) DeepCopy() Offerings
- func (in Offerings) DeepCopyInto(out *Offerings)
- func (ofs Offerings) HasCompatible(reqs scheduling.Requirements) bool
- func (ofs Offerings) MostExpensive() *Offering
- func (ofs Offerings) WorstLaunchPrice(reqs scheduling.Requirements) float64
- type RepairPolicy
- type UnevaluatedNodePoolError
Constants ¶
This section is empty.
Variables ¶
var ( SpotRequirement = scheduling.NewRequirements(scheduling.NewRequirement(v1.CapacityTypeLabelKey, corev1.NodeSelectorOpIn, v1.CapacityTypeSpot)) OnDemandRequirement = scheduling.NewRequirements(scheduling.NewRequirement(v1.CapacityTypeLabelKey, corev1.NodeSelectorOpIn, v1.CapacityTypeOnDemand)) ReservedRequirement = scheduling.NewRequirements(scheduling.NewRequirement(v1.CapacityTypeLabelKey, corev1.NodeSelectorOpIn, v1.CapacityTypeReserved)) // ReservationIDLabel is a label injected into a reserved offering's requirements which is used to uniquely identify a // reservation. For example, a reservation could be shared across multiple NodePools, and the value encoded in this // requirement is used to inform the scheduler that a reservation for one should affect the other. ReservationIDLabel string // ReservedCapacityLabels is the set of additional labels that are associated with reserved offerings. Each reserved // offering should define a requirement for these labels, and all other offerings should define a DoesNotExist requirement. ReservedCapacityLabels = sets.New[string]() )
Functions ¶
func AdjustedPrice ¶ added in v1.7.0
func IsUnevaluatedNodePoolError ¶ added in v1.9.0
Types ¶
type CloudProvider ¶
type CloudProvider interface {
// Create launches a NodeClaim with the given resource requests and requirements and returns a hydrated
// NodeClaim back with resolved NodeClaim labels for the launched NodeClaim
Create(context.Context, *v1.NodeClaim) (*v1.NodeClaim, error)
// Delete removes a NodeClaim from the cloudprovider by its provider id. Delete should return
// NodeClaimNotFoundError if the cloudProvider instance is already terminated and nil if deletion was triggered.
// Karpenter will keep retrying until Delete returns a NodeClaimNotFound error.
Delete(context.Context, *v1.NodeClaim) error
// Get retrieves a NodeClaim from the cloudprovider by its provider id
Get(context.Context, string) (*v1.NodeClaim, error)
// List retrieves all NodeClaims from the cloudprovider
List(context.Context) ([]*v1.NodeClaim, error)
// GetInstanceTypes returns instance types supported by the cloudprovider.
// Availability of types or zone may vary by nodepool or over time. Regardless of
// availability, the GetInstanceTypes method should always return all instance types,
// even those with no offerings available.
GetInstanceTypes(context.Context, *v1.NodePool) ([]*InstanceType, error)
// IsDrifted returns whether a NodeClaim has drifted from the provisioning requirements
// it is tied to.
IsDrifted(context.Context, *v1.NodeClaim) (DriftReason, error)
// RepairPolicy is for CloudProviders to define a set Unhealthy condition for Karpenter
// to monitor on the node.
RepairPolicies() []RepairPolicy
// Name returns the CloudProvider implementation name.
Name() string
// GetSupportedNodeClasses returns CloudProvider NodeClass that implements status.Object
// NOTE: It returns a list where the first element should be the default NodeClass
GetSupportedNodeClasses() []status.Object
}
CloudProvider interface is implemented by cloud providers to support provisioning.
type CreateError ¶ added in v1.1.0
type CreateError struct {
ConditionReason string
ConditionMessage string
// contains filtered or unexported fields
}
CreateError is an error type returned by CloudProviders when instance creation fails
func NewCreateError ¶ added in v1.1.0
func NewCreateError(err error, reason, message string) *CreateError
func (*CreateError) Error ¶ added in v1.2.1
func (e *CreateError) Error() string
func (*CreateError) Unwrap ¶ added in v1.2.1
func (e *CreateError) Unwrap() error
type DriftReason ¶
type DriftReason string
type InstanceType ¶
type InstanceType struct {
// Name of the instance type, must correspond to corev1.LabelInstanceTypeStable
Name string
// Requirements returns a flexible set of properties that may be selected
// for scheduling. Must be defined for every well known label, even if empty.
Requirements scheduling.Requirements
// Note that though this is an array it is expected that all the Offerings are unique from one another
Offerings Offerings
// Resources are the full resource capacities for this instance type
Capacity corev1.ResourceList
// Overhead is the amount of resource overhead expected to be used by kubelet and any other system daemons outside
// of Kubernetes.
Overhead *InstanceTypeOverhead
// contains filtered or unexported fields
}
InstanceType describes the properties of a potential node (either concrete attributes of an instance of this type or supported options in the case of arrays) +k8s:deepcopy-gen=true
func (*InstanceType) Allocatable ¶
func (i *InstanceType) Allocatable() corev1.ResourceList
func (*InstanceType) ApplyCapacityOverlay ¶ added in v1.7.0
func (i *InstanceType) ApplyCapacityOverlay(updatedCapacity corev1.ResourceList)
func (*InstanceType) DeepCopy ¶ added in v1.7.0
func (in *InstanceType) DeepCopy() *InstanceType
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceType.
func (*InstanceType) DeepCopyInto ¶ added in v1.7.0
func (in *InstanceType) DeepCopyInto(out *InstanceType)
Since we have a no copy the sync.Once field, we need to maintain a custom DeepCopyInto function.
func (*InstanceType) IsCapacityOverlayApplied ¶ added in v1.7.0
func (i *InstanceType) IsCapacityOverlayApplied() bool
func (*InstanceType) IsPricingOverlayApplied ¶ added in v1.7.0
func (i *InstanceType) IsPricingOverlayApplied() bool
type InstanceTypeOverhead ¶
type InstanceTypeOverhead struct {
// KubeReserved returns the default resources allocated to kubernetes system daemons by default
KubeReserved corev1.ResourceList
// SystemReserved returns the default resources allocated to the OS system daemons by default
SystemReserved corev1.ResourceList
// EvictionThreshold returns the resources used to maintain a hard eviction threshold
EvictionThreshold corev1.ResourceList
}
+k8s:deepcopy-gen=true
func (*InstanceTypeOverhead) DeepCopy ¶ added in v1.7.0
func (in *InstanceTypeOverhead) DeepCopy() *InstanceTypeOverhead
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InstanceTypeOverhead.
func (*InstanceTypeOverhead) DeepCopyInto ¶ added in v1.7.0
func (in *InstanceTypeOverhead) DeepCopyInto(out *InstanceTypeOverhead)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (InstanceTypeOverhead) Total ¶
func (i InstanceTypeOverhead) Total() corev1.ResourceList
type InstanceTypes ¶
type InstanceTypes []*InstanceType
func (InstanceTypes) Compatible ¶ added in v0.34.0
func (its InstanceTypes) Compatible(requirements scheduling.Requirements) InstanceTypes
Compatible returns the list of instanceTypes based on the supported capacityType and zones in the requirements
func (InstanceTypes) OrderByPrice ¶
func (its InstanceTypes) OrderByPrice(reqs scheduling.Requirements) InstanceTypes
func (InstanceTypes) SatisfiesMinValues ¶ added in v0.37.0
func (its InstanceTypes) SatisfiesMinValues(requirements scheduling.Requirements) (minNeededInstanceTypes int, unsatisfiableMinValues map[string]int, err error)
SatisfiesMinValues validates whether the InstanceTypes satisfies the minValues requirements It returns the minimum number of needed instance types to satisfy the minValues requirement, and if min values isn't satisfied, a map containing the keys which don't satisfy min values and an error that indicates whether the InstanceTypes satisfy the passed-in requirements This minNeededInstanceTypes value is dependent on the ordering of instance types, so relying on this value in a deterministic way implies that the instance types are sorted ahead of using this method For example: Requirements:
- key: node.kubernetes.io/instance-type operator: In values: ["c4.large","c4.xlarge","c5.large","c5.xlarge","m4.large","m4.xlarge"] minValues: 3
- key: karpenter.kwok.sh/instance-family operator: In values: ["c4","c5","m4"] minValues: 3
InstanceTypes: ["c4.large","c5.xlarge","m4.2xlarge"], it PASSES the requirements
we get the map as : {
node.kubernetes.io/instance-type: ["c4.large","c5.xlarge","m4.2xlarge"],
karpenter.k8s.aws/instance-family: ["c4","c5","m4"]
}
so it returns 3 and a nil error to indicate a minimum of 3 instance types were required to fulfill the minValues requirements
And if InstanceTypes: ["c4.large","c4.xlarge","c5.2xlarge"], it FAILS the requirements
we get the map as : {
node.kubernetes.io/instance-type: ["c4.large","c4.xlarge","c5.2xlarge"],
karpenter.k8s.aws/instance-family: ["c4","c5"] // minimum requirement failed for this.
}
so it returns 3 and a non-nil error to indicate that the instance types weren't able to fulfill the minValues requirements
func (InstanceTypes) Truncate ¶ added in v0.37.0
func (its InstanceTypes) Truncate(ctx context.Context, requirements scheduling.Requirements, maxItems int) (InstanceTypes, error)
Truncate truncates the InstanceTypes based on the passed-in requirements It returns an error if it isn't possible to truncate the instance types on maxItems without violating minValues
type InsufficientCapacityError ¶
type InsufficientCapacityError struct {
// contains filtered or unexported fields
}
InsufficientCapacityError is an error type returned by CloudProviders when a launch fails due to a lack of capacity from NodeClaim requirements
func NewInsufficientCapacityError ¶
func NewInsufficientCapacityError(err error) *InsufficientCapacityError
func (*InsufficientCapacityError) Error ¶
func (e *InsufficientCapacityError) Error() string
func (*InsufficientCapacityError) Unwrap ¶ added in v1.2.1
func (e *InsufficientCapacityError) Unwrap() error
type NodeClaimNotFoundError ¶
type NodeClaimNotFoundError struct {
// contains filtered or unexported fields
}
NodeClaimNotFoundError is an error type returned by CloudProviders when the reason for failure is NotFound
func NewNodeClaimNotFoundError ¶
func NewNodeClaimNotFoundError(err error) *NodeClaimNotFoundError
func (*NodeClaimNotFoundError) Error ¶
func (e *NodeClaimNotFoundError) Error() string
func (*NodeClaimNotFoundError) Unwrap ¶ added in v1.2.1
func (e *NodeClaimNotFoundError) Unwrap() error
type NodeClassNotReadyError ¶
type NodeClassNotReadyError struct {
// contains filtered or unexported fields
}
NodeClassNotReadyError is an error type returned by CloudProviders when a NodeClass that is used by the launch process doesn't have all its resolved fields
func NewNodeClassNotReadyError ¶
func NewNodeClassNotReadyError(err error) *NodeClassNotReadyError
func (*NodeClassNotReadyError) Error ¶
func (e *NodeClassNotReadyError) Error() string
func (*NodeClassNotReadyError) Unwrap ¶ added in v1.2.1
func (e *NodeClassNotReadyError) Unwrap() error
type Offering ¶
type Offering struct {
Requirements scheduling.Requirements
Price float64
Available bool
ReservationCapacity int
// contains filtered or unexported fields
}
An Offering describes where an InstanceType is available to be used, with the expectation that its properties may be tightly coupled (e.g. the availability of an instance type in some zone is scoped to a capacity type) and these properties are captured with labels in Requirements. Requirements are required to contain the keys v1.CapacityTypeLabelKey and corev1.LabelTopologyZone. +k8s:deepcopy-gen=true
func (*Offering) ApplyPriceOverlay ¶ added in v1.7.0
func (*Offering) CapacityType ¶
func (*Offering) DeepCopy ¶ added in v1.7.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Offering.
func (*Offering) DeepCopyInto ¶ added in v1.7.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*Offering) IsPriceOverlaid ¶ added in v1.7.0
func (*Offering) ReservationID ¶ added in v1.2.1
type Offerings ¶
type Offerings []*Offering
+k8s:deepcopy-gen=true
func (Offerings) Compatible ¶ added in v0.34.0
func (ofs Offerings) Compatible(reqs scheduling.Requirements) Offerings
Compatible returns the offerings based on the passed requirements
func (Offerings) DeepCopy ¶ added in v1.7.0
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Offerings.
func (Offerings) DeepCopyInto ¶ added in v1.7.0
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (Offerings) HasCompatible ¶ added in v1.0.0
func (ofs Offerings) HasCompatible(reqs scheduling.Requirements) bool
HasCompatible returns whether there is a compatible offering based on the passed requirements
func (Offerings) MostExpensive ¶ added in v0.37.0
MostExpensive returns the most expensive offering from the return offerings
func (Offerings) WorstLaunchPrice ¶ added in v1.0.0
func (ofs Offerings) WorstLaunchPrice(reqs scheduling.Requirements) float64
WorstLaunchPrice gets the worst-case launch price from the offerings that are offered on an instance type. Only offerings for the capacity type we will launch with are considered. The following precedence order is used to determine which capacity type is used: reserved, spot, on-demand.
type RepairPolicy ¶ added in v1.1.0
type RepairPolicy struct {
// ConditionType of unhealthy state that is found on the node
ConditionType corev1.NodeConditionType
// ConditionStatus condition when a node is unhealthy
ConditionStatus corev1.ConditionStatus
// TolerationDuration is the duration the controller will wait
// before force terminating nodes that are unhealthy.
TolerationDuration time.Duration
}
type UnevaluatedNodePoolError ¶ added in v1.9.0
type UnevaluatedNodePoolError struct {
// contains filtered or unexported fields
}
UnevaluatedNodePoolError is an error when the NodePool isn't ready for evaluation
func NewUnevaluatedNodePoolError ¶ added in v1.9.0
func NewUnevaluatedNodePoolError(nodePoolName string) *UnevaluatedNodePoolError
func (*UnevaluatedNodePoolError) Error ¶ added in v1.9.0
func (e *UnevaluatedNodePoolError) Error() string