Documentation ¶
Index ¶
- Constants
- func CheckPodsSchedulableOnNode(context *context.AutoscalingContext, pods []*apiv1.Pod, nodeGroupId string, ...) map[*apiv1.Pod]*simulator.PredicateError
- func ConfigurePredicateCheckerForLoop(unschedulablePods []*apiv1.Pod, schedulablePods []*apiv1.Pod, ...)
- func FilterOutExpendableAndSplit(unschedulableCandidates []*apiv1.Pod, expendablePodsPriorityCutoff int) ([]*apiv1.Pod, []*apiv1.Pod)
- func FilterOutExpendablePods(pods []*apiv1.Pod, expendablePodsPriorityCutoff int) []*apiv1.Pod
- func FilterOutNodesFromNotAutoscaledGroups(nodes []*apiv1.Node, cloudProvider cloudprovider.CloudProvider) ([]*apiv1.Node, errors.AutoscalerError)
- func FilterOutSchedulable(unschedulableCandidates []*apiv1.Pod, nodes []*apiv1.Node, ...) []*apiv1.Pod
- func GetNodeInfoFromTemplate(nodeGroup cloudprovider.NodeGroup, daemonsets []*appsv1.DaemonSet, ...) (*schedulercache.NodeInfo, errors.AutoscalerError)
- func GetNodeInfosForGroups(nodes []*apiv1.Node, cloudProvider cloudprovider.CloudProvider, ...) (map[string]*schedulercache.NodeInfo, errors.AutoscalerError)
- func NewScaleTestAutoscalingContext(options config.AutoscalingOptions, fakeClient kube_client.Interface, ...) context.AutoscalingContext
- func ScaleUp(context *context.AutoscalingContext, ...) (*status.ScaleUpStatus, errors.AutoscalerError)
- func UpdateClusterStateMetrics(csr *clusterstate.ClusterStateRegistry)
- func UpdateEmptyClusterStateMetrics()
- type Autoscaler
- type AutoscalerOptions
- type NodeDeleteStatus
- type ScaleDown
- func (sd *ScaleDown) CleanUp(timestamp time.Time)
- func (sd *ScaleDown) CleanUpUnneededNodes()
- func (sd *ScaleDown) GetCandidatesForScaleDown() []*apiv1.Node
- func (sd *ScaleDown) SoftTaintUnneededNodes(allNodes []*apiv1.Node) (errors []error)
- func (sd *ScaleDown) TryToScaleDown(allNodes []*apiv1.Node, pods []*apiv1.Pod, ...) (*status.ScaleDownStatus, errors.AutoscalerError)
- func (sd *ScaleDown) UpdateUnneededNodes(nodes []*apiv1.Node, nodesToCheck []*apiv1.Node, pods []*apiv1.Pod, ...) errors.AutoscalerError
- type StaticAutoscaler
Constants ¶
const ( // MaxKubernetesEmptyNodeDeletionTime is the maximum time needed by Kubernetes to delete an empty node. MaxKubernetesEmptyNodeDeletionTime = 3 * time.Minute // MaxCloudProviderNodeDeletionTime is the maximum time needed by cloud provider to delete a node. MaxCloudProviderNodeDeletionTime = 5 * time.Minute // MaxPodEvictionTime is the maximum time CA tries to evict a pod before giving up. MaxPodEvictionTime = 2 * time.Minute // EvictionRetryTime is the time after CA retries failed pod eviction. EvictionRetryTime = 10 * time.Second // PodEvictionHeadroom is the extra time we wait to catch situations when the pod is ignoring SIGTERM and // is killed with SIGKILL after MaxGracefulTerminationTime PodEvictionHeadroom = 30 * time.Second )
const (
// ReschedulerTaintKey is the name of the taint created by rescheduler.
ReschedulerTaintKey = "CriticalAddonsOnly"
)
const (
// ScaleDownDisabledKey is the name of annotation marking node as not eligible for scale down.
ScaleDownDisabledKey = "cluster-autoscaler.kubernetes.io/scale-down-disabled"
)
Variables ¶
This section is empty.
Functions ¶
func CheckPodsSchedulableOnNode ¶
func CheckPodsSchedulableOnNode(context *context.AutoscalingContext, pods []*apiv1.Pod, nodeGroupId string, nodeInfo *schedulercache.NodeInfo) map[*apiv1.Pod]*simulator.PredicateError
CheckPodsSchedulableOnNode checks if pods can be scheduled on the given node.
func ConfigurePredicateCheckerForLoop ¶
func ConfigurePredicateCheckerForLoop(unschedulablePods []*apiv1.Pod, schedulablePods []*apiv1.Pod, predicateChecker *simulator.PredicateChecker)
ConfigurePredicateCheckerForLoop can be run to update predicateChecker configuration based on current state of the cluster.
func FilterOutExpendableAndSplit ¶
func FilterOutExpendableAndSplit(unschedulableCandidates []*apiv1.Pod, expendablePodsPriorityCutoff int) ([]*apiv1.Pod, []*apiv1.Pod)
FilterOutExpendableAndSplit filters out expendable pods and splits into:
- waiting for lower priority pods preemption
- other pods.
func FilterOutExpendablePods ¶
FilterOutExpendablePods filters out expendable pods.
func FilterOutNodesFromNotAutoscaledGroups ¶
func FilterOutNodesFromNotAutoscaledGroups(nodes []*apiv1.Node, cloudProvider cloudprovider.CloudProvider) ([]*apiv1.Node, errors.AutoscalerError)
FilterOutNodesFromNotAutoscaledGroups return subset of input nodes for which cloud provider does not return autoscaled node group.
func FilterOutSchedulable ¶
func FilterOutSchedulable(unschedulableCandidates []*apiv1.Pod, nodes []*apiv1.Node, allScheduled []*apiv1.Pod, podsWaitingForLowerPriorityPreemption []*apiv1.Pod, predicateChecker *simulator.PredicateChecker, expendablePodsPriorityCutoff int) []*apiv1.Pod
FilterOutSchedulable checks whether pods from <unschedulableCandidates> marked as unschedulable by Scheduler actually can't be scheduled on any node and filter out the ones that can. It takes into account pods that are bound to node and will be scheduled after lower priority pod preemption.
func GetNodeInfoFromTemplate ¶
func GetNodeInfoFromTemplate(nodeGroup cloudprovider.NodeGroup, daemonsets []*appsv1.DaemonSet, predicateChecker *simulator.PredicateChecker) (*schedulercache.NodeInfo, errors.AutoscalerError)
GetNodeInfoFromTemplate returns NodeInfo object built base on TemplateNodeInfo returned by NodeGroup.TemplateNodeInfo().
func GetNodeInfosForGroups ¶
func GetNodeInfosForGroups(nodes []*apiv1.Node, cloudProvider cloudprovider.CloudProvider, listers kube_util.ListerRegistry, daemonsets []*appsv1.DaemonSet, predicateChecker *simulator.PredicateChecker) (map[string]*schedulercache.NodeInfo, errors.AutoscalerError)
GetNodeInfosForGroups finds NodeInfos for all node groups used to manage the given nodes. It also returns a node group to sample node mapping. TODO(mwielgus): This returns map keyed by url, while most code (including scheduler) uses node.Name for a key.
TODO(mwielgus): Review error policy - sometimes we may continue with partial errors.
func NewScaleTestAutoscalingContext ¶
func NewScaleTestAutoscalingContext(options config.AutoscalingOptions, fakeClient kube_client.Interface, listers kube_util.ListerRegistry, provider cloudprovider.CloudProvider) context.AutoscalingContext
NewScaleTestAutoscalingContext creates a new test autoscaling context for scaling tests.
func ScaleUp ¶
func ScaleUp(context *context.AutoscalingContext, processors *ca_processors.AutoscalingProcessors, clusterStateRegistry *clusterstate.ClusterStateRegistry, unschedulablePods []*apiv1.Pod, nodes []*apiv1.Node, daemonSets []*appsv1.DaemonSet, nodeInfos map[string]*schedulercache.NodeInfo) (*status.ScaleUpStatus, errors.AutoscalerError)
ScaleUp tries to scale the cluster up. Return true if it found a way to increase the size, false if it didn't and error if an error occurred. Assumes that all nodes in the cluster are ready and in sync with instance groups.
func UpdateClusterStateMetrics ¶
func UpdateClusterStateMetrics(csr *clusterstate.ClusterStateRegistry)
UpdateClusterStateMetrics updates metrics related to cluster state
func UpdateEmptyClusterStateMetrics ¶
func UpdateEmptyClusterStateMetrics()
UpdateEmptyClusterStateMetrics updates metrics related to empty cluster's state. TODO(aleksandra-malinowska): use long unregistered value from ClusterStateRegistry.
Types ¶
type Autoscaler ¶
type Autoscaler interface { // RunOnce represents an iteration in the control-loop of CA RunOnce(currentTime time.Time) errors.AutoscalerError // ExitCleanUp is a clean-up performed just before process termination. ExitCleanUp() }
Autoscaler is the main component of CA which scales up/down node groups according to its configuration The configuration can be injected at the creation of an autoscaler
func NewAutoscaler ¶
func NewAutoscaler(opts AutoscalerOptions) (Autoscaler, errors.AutoscalerError)
NewAutoscaler creates an autoscaler of an appropriate type according to the parameters
type AutoscalerOptions ¶
type AutoscalerOptions struct { config.AutoscalingOptions KubeClient kube_client.Interface AutoscalingKubeClients *context.AutoscalingKubeClients CloudProvider cloudprovider.CloudProvider PredicateChecker *simulator.PredicateChecker ExpanderStrategy expander.Strategy EstimatorBuilder estimator.EstimatorBuilder Processors *ca_processors.AutoscalingProcessors Backoff backoff.Backoff }
AutoscalerOptions is the whole set of options for configuring an autoscaler
type NodeDeleteStatus ¶
NodeDeleteStatus tells whether a node is being deleted right now.
func (*NodeDeleteStatus) AddNodeDeleteResult ¶
func (n *NodeDeleteStatus) AddNodeDeleteResult(nodeName string, result error)
AddNodeDeleteResult adds a node delete result to the result map.
func (*NodeDeleteStatus) DrainNodeDeleteResults ¶
func (n *NodeDeleteStatus) DrainNodeDeleteResults() map[string]error
DrainNodeDeleteResults returns the whole result map and replaces it with a new empty one.
func (*NodeDeleteStatus) IsDeleteInProgress ¶
func (n *NodeDeleteStatus) IsDeleteInProgress() bool
IsDeleteInProgress returns true if a node is being deleted.
func (*NodeDeleteStatus) SetDeleteInProgress ¶
func (n *NodeDeleteStatus) SetDeleteInProgress(status bool)
SetDeleteInProgress sets deletion process status
type ScaleDown ¶
type ScaleDown struct {
// contains filtered or unexported fields
}
ScaleDown is responsible for maintaining the state needed to perform unneeded node removals.
func NewScaleDown ¶
func NewScaleDown(context *context.AutoscalingContext, clusterStateRegistry *clusterstate.ClusterStateRegistry) *ScaleDown
NewScaleDown builds new ScaleDown object.
func (*ScaleDown) CleanUpUnneededNodes ¶
func (sd *ScaleDown) CleanUpUnneededNodes()
CleanUpUnneededNodes clears the list of unneeded nodes.
func (*ScaleDown) GetCandidatesForScaleDown ¶
GetCandidatesForScaleDown gets candidates for scale down.
func (*ScaleDown) SoftTaintUnneededNodes ¶
SoftTaintUnneededNodes manage soft taints of unneeded nodes.
func (*ScaleDown) TryToScaleDown ¶
func (sd *ScaleDown) TryToScaleDown(allNodes []*apiv1.Node, pods []*apiv1.Pod, pdbs []*policyv1.PodDisruptionBudget, currentTime time.Time) (*status.ScaleDownStatus, errors.AutoscalerError)
TryToScaleDown tries to scale down the cluster. It returns a result inside a ScaleDownStatus indicating if any node was removed and error if such occurred.
func (*ScaleDown) UpdateUnneededNodes ¶
func (sd *ScaleDown) UpdateUnneededNodes( nodes []*apiv1.Node, nodesToCheck []*apiv1.Node, pods []*apiv1.Pod, timestamp time.Time, pdbs []*policyv1.PodDisruptionBudget) errors.AutoscalerError
UpdateUnneededNodes calculates which nodes are not needed, i.e. all pods can be scheduled somewhere else, and updates unneededNodes map accordingly. It also computes information where pods can be rescheduled and node utilization level. Timestamp is the current timestamp. The computations are made only for the nodes managed by CA.
type StaticAutoscaler ¶
type StaticAutoscaler struct { // AutoscalingContext consists of validated settings and options for this autoscaler *context.AutoscalingContext // contains filtered or unexported fields }
StaticAutoscaler is an autoscaler which has all the core functionality of a CA but without the reconfiguration feature
func NewStaticAutoscaler ¶
func NewStaticAutoscaler( opts config.AutoscalingOptions, predicateChecker *simulator.PredicateChecker, autoscalingKubeClients *context.AutoscalingKubeClients, processors *ca_processors.AutoscalingProcessors, cloudProvider cloudprovider.CloudProvider, expanderStrategy expander.Strategy, estimatorBuilder estimator.EstimatorBuilder, backoff backoff.Backoff) *StaticAutoscaler
NewStaticAutoscaler creates an instance of Autoscaler filled with provided parameters
func (*StaticAutoscaler) ExitCleanUp ¶
func (a *StaticAutoscaler) ExitCleanUp()
ExitCleanUp performs all necessary clean-ups when the autoscaler's exiting.
func (*StaticAutoscaler) RunOnce ¶
func (a *StaticAutoscaler) RunOnce(currentTime time.Time) errors.AutoscalerError
RunOnce iterates over node groups and scales them up/down if necessary