Documentation
¶
Index ¶
- Constants
- func BuildNodeGroupsState(opts nodeGroupsStateOpts) map[string]*NodeGroupState
- func NewNodeLabelFilterFunc(labelKey, labelValue string) k8s.NodeFilterFunc
- func NewPodAffinityFilterFunc(labelKey, labelValue string) k8s.PodFilterFunc
- func NewPodDefaultFilterFunc() k8s.PodFilterFunc
- func TryDeleteNodes(c *Controller, opts scaleOpts, toBeDeleted []*v1.Node) (int, error)
- func ValidateNodeGroup(nodegroup NodeGroupOptions) []error
- type AWSNodeGroupOptions
- type Client
- type Controller
- func (c *Controller) RunForever(runImmediately bool) error
- func (c *Controller) RunOnce() error
- func (c *Controller) ScaleDown(opts scaleOpts) (int, error)
- func (c *Controller) ScaleUp(opts scaleOpts) (int, error)
- func (c *Controller) TryRemoveForceTaintedNodes(opts scaleOpts) (int, error)
- func (c *Controller) TryRemoveTaintedNodes(opts scaleOpts, healthyNodesAllowedToBeRemoved bool) (int, error)
- type NodeGroupLister
- type NodeGroupOptions
- func (n *NodeGroupOptions) HardDeleteGracePeriodDuration() time.Duration
- func (n *NodeGroupOptions) MaxNodeAgeDuration() time.Duration
- func (n *NodeGroupOptions) ScaleUpCoolDownPeriodDuration() time.Duration
- func (n *NodeGroupOptions) SoftDeleteGracePeriodDuration() time.Duration
- func (n *NodeGroupOptions) UnhealthyNodeGracePeriodDuration() time.Duration
- type NodeGroupState
- type Opts
Constants ¶
const DefaultNodeGroup = "default"
DefaultNodeGroup is used for any pods that don't have a node selector defined
const ( // NodeEscalatorIgnoreAnnotation is the key of an annotation on a node that signifies it should be ignored from ASG deletion // value does not matter, can be used for reason, as long as not empty // if set, the node wil not be deleted. However it still can be tainted and factored into calculations NodeEscalatorIgnoreAnnotation = "atlassian.com/no-delete" )
Variables ¶
This section is empty.
Functions ¶
func BuildNodeGroupsState ¶
func BuildNodeGroupsState(opts nodeGroupsStateOpts) map[string]*NodeGroupState
BuildNodeGroupsState builds a node group state
func NewNodeLabelFilterFunc ¶
func NewNodeLabelFilterFunc(labelKey, labelValue string) k8s.NodeFilterFunc
NewNodeLabelFilterFunc creates a new NodeFilterFunc based on filtering by node labels
func NewPodAffinityFilterFunc ¶
func NewPodAffinityFilterFunc(labelKey, labelValue string) k8s.PodFilterFunc
NewPodAffinityFilterFunc creates a new PodFilterFunc based on filtering by label selectors
func NewPodDefaultFilterFunc ¶
func NewPodDefaultFilterFunc() k8s.PodFilterFunc
NewPodDefaultFilterFunc creates a new PodFilterFunc that includes pods that do not have a selector
func TryDeleteNodes ¶ added in v1.16.0
func TryDeleteNodes(c *Controller, opts scaleOpts, toBeDeleted []*v1.Node) (int, error)
func ValidateNodeGroup ¶
func ValidateNodeGroup(nodegroup NodeGroupOptions) []error
ValidateNodeGroup is a safety check to validate that a nodegroup has valid options
Types ¶
type AWSNodeGroupOptions ¶ added in v1.7.0
type AWSNodeGroupOptions struct {
LaunchTemplateID string `json:"launch_template_id,omitempty" yaml:"launch_template_id,omitempty"`
LaunchTemplateVersion string `json:"launch_template_version,omitempty" yaml:"launch_template_version,omitempty"`
FleetInstanceReadyTimeout string `json:"fleet_instance_ready_timeout,omitempty" yaml:"fleet_instance_ready_timeout,omitempty"`
Lifecycle string `json:"lifecycle,omitempty" yaml:"lifecycle,omitempty"`
InstanceTypeOverrides []string `json:"instance_type_overrides,omitempty" yaml:"instance_type_overrides,omitempty"`
ResourceTagging bool `json:"resource_tagging,omitempty" yaml:"resource_tagging,omitempty"`
// contains filtered or unexported fields
}
AWSNodeGroupOptions represents a nodegroup running on a cluster that is using the AWS cloud provider
func (*AWSNodeGroupOptions) FleetInstanceReadyTimeoutDuration ¶ added in v1.7.0
func (n *AWSNodeGroupOptions) FleetInstanceReadyTimeoutDuration() time.Duration
FleetInstanceReadyTimeoutDuration lazily returns/parses the fleetInstanceReadyTimeout string into a duration
type Client ¶
type Client struct {
kubernetes.Interface
Listers map[string]*NodeGroupLister
// contains filtered or unexported fields
}
Client provides a wrapper around a k8s client that includes anything needed by the controller for listing nodegroup pods and nodes based on a filter
func NewClient ¶
func NewClient(k8sClient kubernetes.Interface, nodegroups []NodeGroupOptions, stopCache <-chan struct{}) (*Client, error)
NewClient creates a new client wrapper over the k8sclient with some pod and node listers It will wait for the cache to sync before returning
type Controller ¶
Controller contains the core logic of the Autoscaler
func NewController ¶
func NewController(opts Opts, stopChan <-chan struct{}) (*Controller, error)
NewController creates a new controller with the specified options
func (*Controller) RunForever ¶
func (c *Controller) RunForever(runImmediately bool) error
RunForever starts the autoscaler process and runs once every ScanInterval. blocks thread it always returns a non-nil error
func (*Controller) RunOnce ¶
func (c *Controller) RunOnce() error
RunOnce performs the main autoscaler logic once
func (*Controller) ScaleDown ¶
func (c *Controller) ScaleDown(opts scaleOpts) (int, error)
ScaleDown performs the taint and remove node logic
func (*Controller) ScaleUp ¶
func (c *Controller) ScaleUp(opts scaleOpts) (int, error)
ScaleUp performs the untaint and increase cloud provider node group logic
func (*Controller) TryRemoveForceTaintedNodes ¶ added in v1.16.0
func (c *Controller) TryRemoveForceTaintedNodes(opts scaleOpts) (int, error)
TryRemoveForceTaintedNodes attempts to remove nodes that are * Tainted with force remove and empty
func (*Controller) TryRemoveTaintedNodes ¶
func (c *Controller) TryRemoveTaintedNodes(opts scaleOpts, healthyNodesAllowedToBeRemoved bool) (int, error)
TryRemoveTaintedNodes attempts to remove nodes are * tainted and empty * have passed their grace period
type NodeGroupLister ¶
type NodeGroupLister struct {
// Pod lister
Pods k8s.PodLister
// Node lister
Nodes k8s.NodeLister
}
NodeGroupLister is just a light wrapper around a pod lister and node lister Used for grouping a nodegroup and their listers
func NewDefaultNodeGroupLister ¶
func NewDefaultNodeGroupLister(allPodsLister v1lister.PodLister, allNodesLister v1lister.NodeLister, nodeGroup NodeGroupOptions) *NodeGroupLister
NewDefaultNodeGroupLister creates a new group from the backing lister and nodegroup filter with the default filter
func NewNodeGroupLister ¶
func NewNodeGroupLister(allPodsLister v1lister.PodLister, allNodesLister v1lister.NodeLister, nodeGroup NodeGroupOptions) *NodeGroupLister
NewNodeGroupLister creates a new group from the backing lister and nodegroup filter
type NodeGroupOptions ¶
type NodeGroupOptions struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
LabelKey string `json:"label_key,omitempty" yaml:"label_key,omitempty"`
LabelValue string `json:"label_value,omitempty" yaml:"label_value,omitempty"`
CloudProviderGroupName string `json:"cloud_provider_group_name,omitempty" yaml:"cloud_provider_group_name,omitempty"`
MinNodes int `json:"min_nodes,omitempty" yaml:"min_nodes,omitempty"`
MaxNodes int `json:"max_nodes,omitempty" yaml:"max_nodes,omitempty"`
DryMode bool `json:"dry_mode,omitempty" yaml:"dry_mode,omitempty"`
ScaleOnStarve bool `json:"scale_on_starve,omitempty" yaml:"scale_on_starve,omitempty"`
TaintUpperCapacityThresholdPercent int `json:"taint_upper_capacity_threshold_percent,omitempty" yaml:"taint_upper_capacity_threshold_percent,omitempty"`
TaintLowerCapacityThresholdPercent int `json:"taint_lower_capacity_threshold_percent,omitempty" yaml:"taint_lower_capacity_threshold_percent,omitempty"`
ScaleUpThresholdPercent int `json:"scale_up_threshold_percent,omitempty" yaml:"scale_up_threshold_percent,omitempty"`
SlowNodeRemovalRate int `json:"slow_node_removal_rate,omitempty" yaml:"slow_node_removal_rate,omitempty"`
FastNodeRemovalRate int `json:"fast_node_removal_rate,omitempty" yaml:"fast_node_removal_rate,omitempty"`
SoftDeleteGracePeriod string `json:"soft_delete_grace_period,omitempty" yaml:"soft_delete_grace_period,omitempty"`
HardDeleteGracePeriod string `json:"hard_delete_grace_period,omitempty" yaml:"soft_delete_grace_period,omitempty"`
ScaleUpCoolDownPeriod string `json:"scale_up_cool_down_period,omitempty" yaml:"scale_up_cool_down_period,omitempty"`
TaintEffect v1.TaintEffect `json:"taint_effect,omitempty" yaml:"taint_effect,omitempty"`
AWS AWSNodeGroupOptions `json:"aws" yaml:"aws"`
MaxNodeAge string `json:"max_node_age,omitempty" yaml:"max_node_age,omitempty"`
// UnhealthyNodeGracePeriod is the duration to wait before testing if a node
// can be considered unhealthy.
UnhealthyNodeGracePeriod string `json:"unhealthy_node_grace_period,omitempty" yaml:"unhealthy_node_grace_period,omitempty"`
// HealthCheckNewestNodesPercent is the percentage of newest nodes to check
// for an unhealthy state. The number of instances checked is rounded up
// from the strict percentage supplied. E.g. if 50 is given and there is
// only one instance found, 1 will be used rather than 0.
HealthCheckNewestNodesPercent int `json:"health_check_newest_nodes_percent,omitempty" yaml:"health_check_newest_nodes_percent,omitempty"`
// MaxUnhealthyNodesPercentage is the maximum percentage of unhealthy nodes
// allowed in the nodegroup at any given time.
MaxUnhealthyNodesPercent int `json:"max_unhealthy_nodes_percent,omitempty" yaml:"max_unhealthy_nodes_percent,omitempty"`
// contains filtered or unexported fields
}
NodeGroupOptions represents a nodegroup running on our cluster We differentiate nodegroups by their node label
func UnmarshalNodeGroupOptions ¶
func UnmarshalNodeGroupOptions(reader io.Reader) ([]NodeGroupOptions, error)
UnmarshalNodeGroupOptions decodes the yaml or json reader into a struct
func (*NodeGroupOptions) HardDeleteGracePeriodDuration ¶
func (n *NodeGroupOptions) HardDeleteGracePeriodDuration() time.Duration
HardDeleteGracePeriodDuration lazily returns/parses the hardDeleteGracePeriodDuration string into a duration
func (*NodeGroupOptions) MaxNodeAgeDuration ¶ added in v1.15.0
func (n *NodeGroupOptions) MaxNodeAgeDuration() time.Duration
func (*NodeGroupOptions) ScaleUpCoolDownPeriodDuration ¶
func (n *NodeGroupOptions) ScaleUpCoolDownPeriodDuration() time.Duration
ScaleUpCoolDownPeriodDuration lazily returns/parses the scaleUpCoolDownPeriod string into a duration
func (*NodeGroupOptions) SoftDeleteGracePeriodDuration ¶
func (n *NodeGroupOptions) SoftDeleteGracePeriodDuration() time.Duration
SoftDeleteGracePeriodDuration lazily returns/parses the softDeleteGracePeriod string into a duration
func (*NodeGroupOptions) UnhealthyNodeGracePeriodDuration ¶ added in v1.16.0
func (n *NodeGroupOptions) UnhealthyNodeGracePeriodDuration() time.Duration
UnhealthyNodeGracePeriodDuration lazily returns/parses the unhealthyNodeGracePeriod string into a duration
type NodeGroupState ¶
type NodeGroupState struct {
*NodeGroupLister
Opts NodeGroupOptions
NodeInfoMap map[string]*k8s.NodeInfo
// contains filtered or unexported fields
}
NodeGroupState contains everything about a node group in the current state of the application
type Opts ¶
type Opts struct {
K8SClient kubernetes.Interface
NodeGroups []NodeGroupOptions
CloudProviderBuilder cloudprovider.Builder
ScanInterval time.Duration
DryMode bool
}
Opts provide the Controller with config for runtime