/custom-pod-autoscaler

Custom Pod Autoscaler base, allows creation of Custom Pod Autoscalers

Primary LanguageGoApache License 2.0Apache-2.0

Build codecov GoDoc Go Report Card License

Custom Pod Autoscaler

This is the Custom Pod Autoscaler (CPA) code and base images.

The CPA is part of the Custom Pod Autoscaler Framework.

What is it?

A Custom Pod Autoscaler is a Kubernetes autoscaler that runs on custom logic. Custom Pod Autoscalers are designed to be similar to the Kubernetes Horizontal Pod Autoscaler. 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.

How does it work?

A Custom Pod Autoscaler has a base program that interacts with user-defined scaling logic through shell commands, piping relevant information into them. 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 base program will handle all Kubernetes API interactions for scaling/retrieving resources. This logic just needs to communicate back to the base program by writing the output of its results to standard out.

Developing your own Custom Pod Autoscaler

Custom Pod Autoscalers are Docker images that are designed to run in a Kubernetes cluster, you can build your own either by extending one of the Docker images provided, or by taking the CPA binary and inserting it into your own Docker image. Custom Pod Autoscaler logic can be implemented in any language, the only requirement is that the program must be able to read piped in values from standard in, and be able to communicate back through standard error/out.

Docker images provided:

  • custompodautoscaler/python - Image set up to run Python 3 scripts
  • custompodautoscaler/alpine - Minimal alpine image.

CPA binaries are distributed in GitHub Releases as an asset, inside custom-pod-autoscaler.tar.gz.

See the examples for more information.

Installing a Custom Pod Autoscaler

The easiest way to install a CPA is using the Custom Pod Autoscaler Operator, follow the installation guide for instructions for installing the operator.

Developing this project

Environment

Developing this project requires these dependencies:

  • Go >= 1.13
  • Golint
  • Docker

Commands

  • make - builds the CPA binary.
  • make docker - builds the CPA base images.
  • make lint - lints the code.
  • make unittest - runs the unit tests.
  • make vendor - generates a vendor folder.