custom-pod-autoscaler

command module
v2.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

README

Build go.dev Go Report Card Documentation Status License

This project is supported by:

Custom Pod Autoscaler

Custom Pod Autoscalers (CPAs) are custom Kubernetes autoscalers. This project is part of a framework that lets you quickly and easily build your own CPAs without having to deal with complex Kubernetes interactions using the tools and language of your choice.

What is this project?

This project is part of the Custom Pod Autoscaler Framework (CPAF) which is a set of tools to help you easily build your own CPAs. This project is the core of the CPAF, providing a program which runs inside your CPA to manage Kubernetes interactions and custom user logic interactions.

A Custom Pod Autoscaler can be created by using this project, extending the Docker base images provided and inserting your own logic; see the examples for more information.

Features

  • Supports any language, environment and framework; the only requirement is it must be startable by a shell command or HTTP request.
  • Supports all configuration options of the Horizontal Pod Autoscaler (downscale stabilisation, sync period etc.)
  • Allows fast and easy prototyping and development.
  • Abstracts away all complicated Kubernetes API interactions.
  • Exposes a HTTP REST API for integration with wider systems/manual intervention.
  • Can write autoscalers with limited Kubernetes API or lifecycle knowledge.
  • Configuration at build time or deploy time.
  • Allows scaling to and from zero.
  • Can be configured without master node access, can be configured on managed providers such as EKS or GKE.
  • Supports Kubernetes metrics that the Horizontal Pod Autoscaler uses, can be configured using a similar syntax and used in custom scaling decisions.
  • Supports Argo Rollouts.

Why would I use it?

Kubernetes provides the Horizontal Pod Autoscaler, which allows automatic scaling of the number of replicas in a resource (Deployment, ReplicationController, ReplicaSet, StatefulSet) based on metrics that you feed it. Mostly the metrics used are CPU/memory load, which is sufficient for most applications. You can specify custom metrics to feed into it through the metrics API also.

The limitation in the Horizontal Pod Autoscaler is that it has a hard-coded algorithm for assessing these metrics:

desiredReplicas = ceil[currentReplicas * ( currentMetricValue / desiredMetricValue )]

If you need more flexibility in your scaling, beyond this algorithm, Horizontal Pod Autoscaler doesn't meet your needs, you need to write your own scaling logic.

How does it work?

This project is a program that abstracts away complex Kubernetes interactions and handles interacting with custom user logic you can provide to determine how the autoscaler should operate.

When developing a Custom Pod Autoscaler you define logic for two stages:

  • Metric gathering - collecting or generating metrics; can be calling metrics APIs, running calculations locally, making HTTP requests.
  • Evaluating metrics - taking these gathered metrics and using them to decide how many replicas a resource should have.

These two pieces of logic are all the custom logic required to build a Custom Pod Autoscaler, the program will handle all Kubernetes API interactions for scaling/retrieving resources.

Getting started

Check out this getting started guide for a quick start for developers.

More information

See the wiki for more information, such as guides and references.

What other projects are in the Custom Pod Autoscaler Framework?

The Custom Pod Autoscaler Operator is the other part of the Custom Pod Autoscaler Framework, it is an operator that handles provisioning Kubernetes resources for your CPA.

Developing this project

See the contribution guidelines.

Documentation

Overview

Custom Pod Autoscaler is the core program that runs inside a Custom Pod Autoscaler Image. The program handles interactions with the Kubernetes API, manages triggering Custom Pod Autoscaler User Logic through shell commands, exposes a simple HTTP REST API for viewing metrics and evaluations, and handles parsing user configuration to specify polling intervals, Kubernetes namespaces, command timeouts etc. The Custom Pod Autoscaler must be run inside a Kubernetes cluster.

Directories

Path Synopsis
api
v1
Package config contains the definitions for any configuration that the Custom Pod Autoscaler supports.
Package config contains the definitions for any configuration that the Custom Pod Autoscaler supports.
internal
api/v1
Package v1 provides routing and endpoints for the Custom Pod Autoscaler HTTP REST API version 1.
Package v1 provides routing and endpoints for the Custom Pod Autoscaler HTTP REST API version 1.
autoscaler
Package autoscaler provides methods for scaling a resource - by triggering metric gathering, feeding these metrics to an evaluation and using this evaluation to scale the resource.
Package autoscaler provides methods for scaling a resource - by triggering metric gathering, feeding these metrics to an evaluation and using this evaluation to scale the resource.
confload
Package confload handles loading in configuration - parsing YAML and environment variable input into a Custom Pod Autoscaler configuration struct.
Package confload handles loading in configuration - parsing YAML and environment variable input into a Custom Pod Autoscaler configuration struct.
evaluatecalc
Package evaluatecalc provides functionality for managing evaluating, calling external evaluation logic through shell commands with relevant data piped to them.
Package evaluatecalc provides functionality for managing evaluating, calling external evaluation logic through shell commands with relevant data piped to them.
execute
Package execute abstracts methods, providing a standardised way to trigger methods and provide values
Package execute abstracts methods, providing a standardised way to trigger methods and provide values
execute/http
Package http handles interactions over HTTP
Package http handles interactions over HTTP
execute/shell
Package shell handles interactions with the OS shell
Package shell handles interactions with the OS shell
fake
Package fake provides stubs for testing relevant to the Custom Pod Autoscaler packages
Package fake provides stubs for testing relevant to the Custom Pod Autoscaler packages
metricget
Package metricget provides functionality for managing gathering metrics, calling external metric gathering logic through shell commands with relevant data piped to them.
Package metricget provides functionality for managing gathering metrics, calling external metric gathering logic through shell commands with relevant data piped to them.
scaling
Package scaling abstracts interactions with the Kubernetes scale API, providing a consistent way to scale resources that are supported by the Custom Pod Autoscaler.
Package scaling abstracts interactions with the Kubernetes scale API, providing a consistent way to scale resources that are supported by the Custom Pod Autoscaler.
Package k8smetric provides the definitions for data generated by the Kubernetes Metric Gathering functionality
Package k8smetric provides the definitions for data generated by the Kubernetes Metric Gathering functionality
value
Package value represents a computed value for a metric, can be either a raw value or an average value
Package value represents a computed value for a metric, can be either a raw value or an average value

Jump to

Keyboard shortcuts

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