Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions vertical-pod-autoscaler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Getting started](#getting-started)
- [Components and Architecture](#components-and-architecture)
- [Features and Known limitations](#features-and-known-limitations)
- [Development and testing](#development-and-testing)
- [Related links](#related-links)

## Intro
Expand Down Expand Up @@ -51,6 +52,10 @@ You can also read about the [features](./docs/features.md) and [known limitation
> * When the admission-controller tries to set a container-level limit higher than the pod-level limit, the operation is prohibited, and the pod will not be created.
> * When the admission-controller tries to set the newly recommended container-level requests, their total value cannot exceed the pod-level request or limit. For example, if the pod-level memory request is 100Mi, but the newly recommended total of container-level requests is 250Mi, the pod will fail to be created.

## Development and testing

Have a look at the [Development and testing](./docs/development-and-testing.md) page for more information about developing on the VPA.

## Related links

- [Design proposal](https://github.com/kubernetes/design-proposals-archive/blob/main/autoscaling/vertical-pod-autoscaler.md)
Expand Down
43 changes: 43 additions & 0 deletions vertical-pod-autoscaler/docs/development-and-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Development and testing

## Contents

- [Development and testing](#development-and-testing)
- [Introduction](#introduction)
- [Running e2e tests](#running-e2e-tests)
- [Feature gates](#feature-gates)
- [Parallelism](#parallelism)
- [External Metrics Tests](#external-metrics-tests)

## Introduction

This project contains various scripts and tools to aid in the development of the three VPA components.

## Running e2e tests

The VPA contains some e2e tests that test how each component interacts with Pods and VPA resources inside a real Kubernetes cluster.

They can be run using the `./hack/run-e2e-locally.sh` helper script. Please note that this script will delete any existing [kind](https://kind.sigs.k8s.io) cluster running on the local machine before creating a fresh cluster for executing the tests.

### Feature gates

By default, the e2e test suite only runs feature-gated tests for features that are enabled by default (typically beta and GA). Alpha features, which are disabled by default, are not tested.

Setting the environment variable `ENABLE_ALL_FEATURE_GATES=true` will enable all feature gates and run all feature-gated tests.

### Parallelism

By default, the e2e tests create 4 worker processes, each one running its own test. This can be changed by setting the `NUMPROC=<workers>` variable.

### External Metrics Tests

The external metrics tests (`recommender-externalmetrics`, available in `run-e2e-locally.sh` and `deploy-for-e2e-locally.sh`)
use a stack of 4 additional programs to support testing:

1. `hack/emit-metrics.py` to generate random CPU and RAM metrics for every pod in the local cluster.
2. Prometheus Pushgateway to accept metrics from `hack/emit-metrics`.
3. Prometheus to store the metrics accepted by the Pushgateway.
4. Prometheus Adapter to provide an External Metrics interface to Prometheus.

The External Metrics tests run by configuring a `recommender` to use the External Metrics interface
from the Prometheus Adapter. With that configuration, it runs the standard `recommender` test suite.
37 changes: 0 additions & 37 deletions vertical-pod-autoscaler/hack/local-cluster.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
# Running Integration Tests locally

Included in parallel with `run-e2e.sh` and `deploy-for-e2e.sh` are two alternate versions
with `-locally` as part of their names. They use Kubernetes in Docker (`kind`) to run a local
cluster in Docker. Using them will require `docker` and `kind` in your `PATH`.

## External Metrics Tests

The external metrics tests (`recommender-externalmetrics`, available on the `-locally` variants)
use a stack of 4 additional programs to support testing:

1. `hack/emit-metrics.py` to generate random CPU and RAM metrics for every pod in the local cluster.
2. Prometheus Pushgateway to accept metrics from `hack/emit-metrics`.
3. Prometheus to store the metrics accepted by the Pushgateway.
4. Prometheus Adapter to provide an External Metrics interface to Prometheus.

The External Metrics tests run by configuring a `recommender` to use the External Metrics interface
from the Prometheus Adapter. With that configuration, it runs the standard `recommender` test suite.

## Non-recommender tests

The `recommender` and `recommender-externalmetrics` test work locally, but none of the others do;
they require more Makefile work.

# Configuration Notes

To support the regular `recommender` tests locally, we've added the stock Kubernetes Metrics Server.
Unfortunately, it doesn't work with TLS turned on. The metrics server is being run in insecure mode
to work around this. This only runs in the local `kind` case, not in a real cluster.

# RBAC Changes

The local test cases support running the `recommender` with external metrics. This requires
additional permissions we don't want to automatically enable for all customers via the
configuration given in `deploy/vpa-rbac.yaml`. The scripts use a context diff `hack/e2e/vpa-rbac.diff`
to enable those permission when running locally.

# Quick Integration Tests

`run-integration-locally.sh` is a quicker way to integration test compared to `run-e2e-locally.sh`. Only used for simple tests.