Documentation
¶
Overview ¶
Package autoscaler implements logic to poll the k8s apiserver for cluster info, and update the resources of a deployment based on current size.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoScaler ¶
type AutoScaler struct {
// contains filtered or unexported fields
}
AutoScaler determines the number of replicas to run
func NewAutoScaler ¶
func NewAutoScaler(c *options.AutoScalerConfig) (*AutoScaler, error)
NewAutoScaler returns a new AutoScaler
func (*AutoScaler) Run ¶
func (s *AutoScaler) Run()
Run periodically counts the number of nodes and cores, estimates the expected number of replicas, compares them to the actual replicas, and updates the target resource with the expected replicas if necessary.
type ContainerScaleConfig ¶
type ContainerScaleConfig struct { Requests map[string]ResourceScaleConfig Limits map[string]ResourceScaleConfig }
ContainmerScaleConfig holds per-container per-resource configs.
func (ContainerScaleConfig) DeepCopy ¶
func (csc ContainerScaleConfig) DeepCopy() ContainerScaleConfig
func (ContainerScaleConfig) String ¶
func (csc ContainerScaleConfig) String() string
type ResourceScaleConfig ¶
type ResourceScaleConfig struct { // The baseline quantity required. Base *resource.Quantity // The maximum allowed quantity. Max *resource.Quantity // The amount of additional resources to grow by. If this is too // fine-grained, the resizing action will happen too frequently. Step *resource.Quantity // The number of cores required to trigger an increase. CoresPerStep *int // The number of nodes required to trigger an increase. NodesPerStep *int }
ResourceScaleConfig holds the coefficients for a single resource scaling function. The final result will be the base plus the larger of the by-cores scaling and the by-nodes scaling, bounded by the max value.
Example:
Base = 10 Max = 100 Step = 2 CoresPerStep = 4 NodesPerStep = 2 The core and node counts are rounded up to the next whole step. If we find 64 cores and 4 nodes we get scalars of: by-cores: 10 + (2 * (round(64, 4)/4)) = 10 + 32 = 42 by-nodes: 10 + (2 * (round(4, 2)/2)) = 10 + 4 = 14 The larger is by-cores, and it is less than Max, so the final value is 42. If we find 3 cores and 3 nodes we get scalars of: by-cores: 10 + (2 * (round(3, 4)/4)) = 10 + 2 = 12 by-nodes: 10 + (2 * (round(3, 2)/2)) = 10 + 4 = 14
func (ResourceScaleConfig) DeepCopy ¶
func (rsc ResourceScaleConfig) DeepCopy() ResourceScaleConfig
func (ResourceScaleConfig) String ¶
func (rsc ResourceScaleConfig) String() string
type ScaleConfig ¶
type ScaleConfig map[string]ContainerScaleConfig
ScaleConfig maps container names to per-container configs.
func (ScaleConfig) DeepCopy ¶
func (sc ScaleConfig) DeepCopy() ScaleConfig
func (ScaleConfig) String ¶
func (sc ScaleConfig) String() string