controller

package
v1.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2019 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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, 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

type Controller struct {
	Client *Client
	Opts   Opts
	// contains filtered or unexported fields
}

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) 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"`

	TaintEffect v1.TaintEffect `json:"taint_effect,omitempty" yaml:"taint_effect,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 {
	*NodeGroupLister
	Opts        NodeGroupOptions
	NodeInfoMap map[string]*cache.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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL