predictive-horizontal-pod-autoscaler

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: Apache-2.0

README

Build codecov GoDoc Go Report Card License

Predictive Horizontal Pod Autoscaler

Very early pre-release

This is a Custom Pod Autoscaler; aiming to have identical functionality to the Horizontal Pod Autoscaler, however with added predictive elements.

This uses the Horizontal Pod Autoscaler Custom Pod Autoscaler extensively to provide most functionality for the Horizontal Pod Autoscaler parts.

This runs as a Custom Pod Autoscaler, which allows creation of custom autoscalers to run in a Kubernetes cluster; this project was made as an example of what is possible.

How does it work?

This project works by calculating the number of replicas a resource should have, then storing these values and using statistical models against them to produce predictions for the future. These predictions are compared and can be used instead of the raw replica count calculated by the HPA logic.

Usage

If you want to deploy this onto your cluster, you first need to install the Custom Pod Autoscaler Operator, follow the installation guide for instructions for installing the operator.

Once the Custom Pod Autoscaler Operator is installed, you can now use this project, see the /example folder for some samples.

Metrics

You can specify which metrics to scale on using the same YAML you would use for the Horizontal Pod Autoscaler; by putting it into the metrics option:

- name: metrics
    value: |
    - type: Resource
      resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 50

See the Horizontal Pod Autoscaler Custom Pod Autoscaler for more information.

Models
Linear Regression

At the minute there is only a single type of predictive model available; Linear Regression. There are plans to add in more useful and complex prediction models, such as ARIMA or Holt-Winters. You can specify the model to use in the predictiveConfig option in the deployment YAML:

- name: predictiveConfig
    value: |
    models:
    - type: Linear
      name: LinearPrediction
      perInterval: 1
      linear:
        lookAhead: 10
        storedValues: 6
      decisionType: "maximum"

For a more detailed example, see either example in the /example folder.

Developing this project

Environment

Developing this project requires these dependencies:

  • Go >= 1.13
  • Golint
  • Docker
Commands
  • make - builds the Predictive HPA binary.
  • make docker - builds the Predictive HPA image.
  • make lint - lints the code.
  • make unittest - runs the unit tests
  • make vendor - generates a vendor folder.

Directories

Path Synopsis
cmd
predictive-horizontal-pod-autoscaler
Predictive Horizontal Pod Autoscaler provides executable Predictive Horizontal Pod Autoscaler logic, which can be built into a Custom Pod Autoscaler.
Predictive Horizontal Pod Autoscaler provides executable Predictive Horizontal Pod Autoscaler logic, which can be built into a Custom Pod Autoscaler.
Package config provides configuration options for the Predictive Horizontal Pod Autoscaler
Package config provides configuration options for the Predictive Horizontal Pod Autoscaler
Package prediction provides a framework for using models to make predictions based on historical evaluations
Package prediction provides a framework for using models to make predictions based on historical evaluations
Package stored provides interfacing methods for updating/retrieving data from the local sqlite3 database
Package stored provides interfacing methods for updating/retrieving data from the local sqlite3 database
migrate
Package migrate handles applying migrations to the sqlite3 db for storing evaluations
Package migrate handles applying migrations to the sqlite3 db for storing evaluations

Jump to

Keyboard shortcuts

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