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 ValidateNodeGroup(nodegroup NodeGroupOptions) []error
- type Client
- type Controller
- type NodeGroupLister
- type NodeGroupOptions
- type NodeGroupState
- type Opts
Constants ¶
const DefaultNodeGroup = "default"
DefaultNodeGroup is used for any pods that don't have a node selector defined
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 ValidateNodeGroup ¶
func ValidateNodeGroup(nodegroup NodeGroupOptions) []error
ValidateNodeGroup is a safety check to validate that a nodegroup has valid options
Types ¶
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
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
NewController creates a new controller with the specified options
func (*Controller) RunForever ¶
func (c *Controller) RunForever(runImmediately bool)
RunForever starts the autoscaler process and runs once every ScanInterval. blocks thread
func (*Controller) RunOnce ¶
func (c *Controller) RunOnce()
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) TryRemoveTaintedNodes ¶
func (c *Controller) TryRemoveTaintedNodes(opts scaleOpts) (int, error)
TryRemoveTaintedNodes attempts to remove nodes are tainted and empty or 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"` 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"` // 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) 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
type NodeGroupState ¶
type NodeGroupState struct { Opts NodeGroupOptions *NodeGroupLister NodeInfoMap map[string]*cache.NodeInfo CloudProviderNodeGroup cloudprovider.NodeGroup // 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