wI2L / kubectl-vpa-recommendation

kubectl plugin to compare VPA recommendations to actual resources requests
MIT License
35 stars 3 forks source link
autoscaling kubectl kubectl-plugin kubectl-plugins verticalpodautoscaler vpa

kubectl vpa-recommendation

A kubectl plugin to show the differences between the recommendations of a VerticalPodAutoscaler and the actual resources requests of the targeted controller's pod(s).

The plugin is compatible with Kubernetes servers starting from version 1.16, which have the autoscaling.k8s.io/v1 API group installed. See the other prerequisites for using VPAs on your cluster.

Installation

With Krew

Follow these instructions to install krew. Then run the following commands:

$ kubectl krew install vpa-recommendation
$ kubectl vpa-recommendation --help

Manual download

Head to the releases page to download an existing release for your OS/arch, and add the path to the binary to your $PATH.

Build from source

:warning: The plugin requires Go 1.17+ to build.

To build the plugin yourself from the source, use the following commands:

$ git clone git@github.com:wI2L/kubectl-vpa-recommendation.git
$ cd kubectl-vpa-recommendation
$ make build

It creates a single binary file for the host machine platform/architecture in the dist/ folder. Move it somewhere within your $PATH, such as $GOPATH/bin. You can then invoke it directly (kubectl-vpa-recommendation), or via kubectl (kubectl vpa-recommendation).

Usage

How to interpret the output?

The columns % CPU DIFF and % MEMORY DIFF represents the percentage of increase/decrease for the request in terms of the recommendation.

For example, if a request value is set to 4 CPU (4000m), and the recommendation is only 1 CPU (1000m), the difference printed is +300%. On the contrary, if the request (125m) is lower than the recommendation (250m), the difference is then -50%. As a rule of thumb, you can think of positive values as over commitment and negative values as under commitment.

Demo

The following examples were produced from a brand-new Kubernetes cluster created with k3d. The VerticalPodAutoscaler resources were automatically created by the goldilocks operator.

Single namespace

example1

Wide output (all namespaces)

example2

Options

Apart from the flags defined by the genericclioptions package and some logging flags, the following options are available with the plugin:

To view the full list of available options, use the following command:

$ kubectl vpa-recommendation --help

Limitations

License

This plugin is licensed under the MIT license. See the LICENSE file.