Documentation ¶
Index ¶
- Variables
- func RequireNoScheduleTaint(ctx context.Context, kubeClient client.Client, addTaint bool, ...) error
- type Cluster
- func (c *Cluster) ConsolidationState() time.Time
- func (c *Cluster) DeleteDaemonSet(key types.NamespacedName)
- func (c *Cluster) DeleteNode(name string)
- func (c *Cluster) DeleteNodeClaim(name string)
- func (c *Cluster) DeletePod(podKey types.NamespacedName)
- func (c *Cluster) ForEachNode(f func(n *StateNode) bool)
- func (c *Cluster) ForPodsWithAntiAffinity(fn func(p *v1.Pod, n *v1.Node) bool)
- func (c *Cluster) GetDaemonSetPod(daemonset *appsv1.DaemonSet) *v1.Pod
- func (c *Cluster) IsNodeNominated(providerID string) bool
- func (c *Cluster) MarkForDeletion(providerIDs ...string)
- func (c *Cluster) MarkUnconsolidated() time.Time
- func (c *Cluster) Nodes() StateNodes
- func (c *Cluster) NominateNodeForPod(ctx context.Context, providerID string)
- func (c *Cluster) Reset()
- func (c *Cluster) Synced(ctx context.Context) (synced bool)
- func (c *Cluster) UnmarkForDeletion(providerIDs ...string)
- func (c *Cluster) UpdateDaemonSet(ctx context.Context, daemonset *appsv1.DaemonSet) error
- func (c *Cluster) UpdateNode(ctx context.Context, node *v1.Node) error
- func (c *Cluster) UpdateNodeClaim(nodeClaim *v1beta1.NodeClaim)
- func (c *Cluster) UpdatePod(ctx context.Context, pod *v1.Pod) error
- type StateNode
- func (in *StateNode) Allocatable() v1.ResourceList
- func (in *StateNode) Annotations() map[string]string
- func (in *StateNode) Available() v1.ResourceList
- func (in *StateNode) Capacity() v1.ResourceList
- func (in *StateNode) DaemonSetLimits() v1.ResourceList
- func (in *StateNode) DaemonSetRequests() v1.ResourceList
- func (in *StateNode) DeepCopy() *StateNode
- func (in *StateNode) DeepCopyInto(out *StateNode)
- func (in *StateNode) HostName() string
- func (in *StateNode) HostPortUsage() *scheduling.HostPortUsage
- func (in *StateNode) Initialized() bool
- func (in *StateNode) Labels() map[string]string
- func (in *StateNode) Managed() bool
- func (in *StateNode) MarkedForDeletion() bool
- func (in *StateNode) Name() string
- func (in *StateNode) Nominate(ctx context.Context)
- func (in *StateNode) Nominated() bool
- func (in *StateNode) PodLimits() v1.ResourceList
- func (in *StateNode) PodRequests() v1.ResourceList
- func (in *StateNode) Pods(ctx context.Context, c client.Client) ([]*v1.Pod, error)
- func (in *StateNode) ProviderID() string
- func (in *StateNode) Registered() bool
- func (in *StateNode) ReschedulablePods(ctx context.Context, c client.Client) ([]*v1.Pod, error)
- func (in *StateNode) Taints() []v1.Taint
- func (in *StateNode) VolumeUsage() *scheduling.VolumeUsage
- type StateNodes
Constants ¶
This section is empty.
Variables ¶
var ( ClusterStateNodesCount = prometheus.NewGauge( prometheus.GaugeOpts{ Namespace: metrics.Namespace, Subsystem: stateSubsystem, Name: "node_count", Help: "Current count of nodes in cluster state", }, ) ClusterStateSynced = prometheus.NewGauge( prometheus.GaugeOpts{ Namespace: metrics.Namespace, Subsystem: stateSubsystem, Name: "synced", Help: "Returns 1 if cluster state is synced and 0 otherwise. Synced checks that nodeclaims and nodes that are stored in the APIServer have the same representation as Karpenter's cluster state", }, ) )
Functions ¶
func RequireNoScheduleTaint ¶
func RequireNoScheduleTaint(ctx context.Context, kubeClient client.Client, addTaint bool, nodes ...*StateNode) error
RequireNoScheduleTaint will add/remove the karpenter.sh/disruption:NoSchedule taint from the candidates. This is used to enforce no taints at the beginning of disruption, and to add/remove taints while executing a disruption action. nolint:gocyclo
Types ¶
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
Cluster maintains cluster state that is often needed but expensive to compute.
func NewCluster ¶
func NewCluster(clk clock.Clock, client client.Client, cp cloudprovider.CloudProvider) *Cluster
func (*Cluster) ConsolidationState ¶
ConsolidationState returns a timestamp of the last time that the cluster state with respect to consolidation changed. If nothing changes, this timestamp resets after five minutes to force watchers that use this to defer work to occasionally revalidate that nothing external (e.g. an instance type becoming available) has changed that now makes it possible for them to operate. Time was chosen as the type here as it allows comparisons using the built-in monotonic clock.
func (*Cluster) DeleteDaemonSet ¶
func (c *Cluster) DeleteDaemonSet(key types.NamespacedName)
func (*Cluster) DeleteNode ¶
func (*Cluster) DeleteNodeClaim ¶
func (*Cluster) DeletePod ¶
func (c *Cluster) DeletePod(podKey types.NamespacedName)
func (*Cluster) ForEachNode ¶
ForEachNode calls the supplied function once per node object that is being tracked. It is not safe to store the state.StateNode object, it should be only accessed from within the function provided to this method.
func (*Cluster) ForPodsWithAntiAffinity ¶
ForPodsWithAntiAffinity calls the supplied function once for each pod with required anti affinity terms that is currently bound to a node. The pod returned may not be up-to-date with respect to status, however since the anti-affinity terms can't be modified, they will be correct.
func (*Cluster) GetDaemonSetPod ¶
func (*Cluster) IsNodeNominated ¶
IsNodeNominated returns true if the given node was expected to have a pod bound to it during a recent scheduling batch
func (*Cluster) MarkForDeletion ¶
TODO remove this when v1alpha5 APIs are deprecated. With v1beta1 APIs Karpenter relies on the existence of the karpenter.sh/disruption taint to know when a node is marked for deletion. MarkForDeletion marks the node as pending deletion in the internal cluster state
func (*Cluster) MarkUnconsolidated ¶
MarkUnconsolidated marks the cluster state as being unconsolidated. This should be called in any situation where something in the cluster has changed such that the cluster may have moved from a non-consolidatable to a consolidatable state.
func (*Cluster) Nodes ¶
func (c *Cluster) Nodes() StateNodes
Nodes creates a DeepCopy of all state nodes. NOTE: This is very inefficient so this should only be used when DeepCopying is absolutely necessary
func (*Cluster) NominateNodeForPod ¶
NominateNodeForPod records that a node was the target of a pending pod during a scheduling batch
func (*Cluster) Synced ¶
Synced validates that the NodeClaims and the Nodes that are stored in the apiserver have the same representation in the cluster state. This is to ensure that our view of the cluster is as close to correct as it can be when we begin to perform operations utilizing the cluster state as our source of truth
func (*Cluster) UnmarkForDeletion ¶
TODO remove this when v1alpha5 APIs are deprecated. With v1beta1 APIs Karpenter relies on the existence of the karpenter.sh/disruption taint to know when a node is marked for deletion. UnmarkForDeletion removes the marking on the node as a node the controller intends to delete
func (*Cluster) UpdateDaemonSet ¶
func (*Cluster) UpdateNodeClaim ¶
type StateNode ¶
type StateNode struct { Node *v1.Node NodeClaim *v1beta1.NodeClaim // contains filtered or unexported fields }
StateNode is a cached version of a node in the cluster that maintains state which is expensive to compute every time it's needed. This currently contains node utilization across all the allocatable resources, but will soon be used to compute topology information. +k8s:deepcopy-gen=true nolint: revive
func (*StateNode) Allocatable ¶
func (in *StateNode) Allocatable() v1.ResourceList
func (*StateNode) Annotations ¶
func (*StateNode) Available ¶
func (in *StateNode) Available() v1.ResourceList
Available is allocatable minus anything allocated to pods.
func (*StateNode) Capacity ¶
func (in *StateNode) Capacity() v1.ResourceList
func (*StateNode) DaemonSetLimits ¶
func (in *StateNode) DaemonSetLimits() v1.ResourceList
func (*StateNode) DaemonSetRequests ¶
func (in *StateNode) DaemonSetRequests() v1.ResourceList
func (*StateNode) DeepCopy ¶
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StateNode.
func (*StateNode) DeepCopyInto ¶
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*StateNode) HostPortUsage ¶
func (in *StateNode) HostPortUsage() *scheduling.HostPortUsage
func (*StateNode) Initialized ¶
func (*StateNode) MarkedForDeletion ¶
func (*StateNode) PodLimits ¶
func (in *StateNode) PodLimits() v1.ResourceList
func (*StateNode) PodRequests ¶
func (in *StateNode) PodRequests() v1.ResourceList
func (*StateNode) Pods ¶
Pods gets the pods assigned to the Node based on the kubernetes api-server bindings
func (*StateNode) ProviderID ¶
ProviderID is the key that is used to map this StateNode If the Node and NodeClaim have a providerID, this should map to a real providerID If the Node does not have a providerID, this will map to the node name
func (*StateNode) Registered ¶
func (*StateNode) ReschedulablePods ¶ added in v0.34.0
ReschedulablePods gets the pods assigned to the Node that are reschedulable based on the kubernetes api-server bindings
func (*StateNode) VolumeUsage ¶
func (in *StateNode) VolumeUsage() *scheduling.VolumeUsage
type StateNodes ¶
type StateNodes []*StateNode
StateNodes is a typed version of a list of *Node nolint: revive
func (StateNodes) Active ¶
func (n StateNodes) Active() StateNodes
Active filters StateNodes that are not in a MarkedForDeletion state
func (StateNodes) Deleting ¶
func (n StateNodes) Deleting() StateNodes
Deleting filters StateNodes that are in a MarkedForDeletion state
func (StateNodes) Pods ¶
Pods gets the pods assigned to all StateNodes based on the kubernetes api-server bindings