Skip to content

clickfunnels2/newrelic-k8s-metrics-adapter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Community Plus header

newrelic-k8s-metrics-adapter

The newrelic-k8s-metrics-adapter implements the external.metrics.k8s.io API to support the use of external metrics based New Relic NRQL queries.

During installation, a set of metrics can be configured to be available for Horizontal Pod Autoscalers to be used. Once deployed, the metrics values are fetched from the configured New Relic account using the NerdGraph API and the configured NRQL query.

The adapter uses the Custom Metrics Adapter Server Boilerplate as a base code to implement the external metric api server.

Installation

This project has the newrelic-k8s-metrics-adapter Helm Chart in charts/newrelic-k8s-metrics-adapter and can also be installed through the nri-bundle chart in newrelic helm charts repo.

For further information regarding the installation refer to the official docs and to the README.md and the values.yaml of the chart.

Getting Started

In order to start using the adapter, please start by installing and configuring the adapter using the provided Helm Chart. After this, metrics will be available for consumption by Horizontal Pod Autoscaler using the configured metric names. For further information regarding the usage of the adapter refer to the official docs.

Develop, Test and Run Locally

For the development process kind and tilt tools are used.

Building

To build the image:

GOOS=linux make image

To build the binary:

GOOS=linux make build

Configure Tilt

If you want to use a kind cluster for testing, configure Tilt using the command below:

cat <<EOF > tilt_option.json
{
  "default_registry": "localhost:5000"
}
EOF

If you want to use existing Kubernetes cluster, create tilt_option.json file with content similar to below:

{
  "default_registry": "quay.io/<your username>",
  "allowed_contexts": "<kubeconfig context to use>"
}

Creating kind cluster

If you want to use a local kind cluster for testing, create it with command below:

make kind-up

Run

If you use a kind cluster, simply run:

make tilt-up

If you deploy on external cluster, run the command below, pointing TILT_KUBECONFIG to your kubeconfig file:

TILT_KUBECONFIG=~/.kube/config make tilt-down

Now, when you make changes to the code, the metrics adapter binary will be built locally, copied to the Pod, and then executed.

Testing

In order to run unit tests run:

make test

In order to run integration and e2e tests run:

make test-integration
make test-e2e

Notice that in order to run both integration tests and e2e is required to configure access to a New Relic account. This can be done either via environment variable directly or by putting required environment variables into .env file, which will be read by Makefile and they will be used for other commands.

.env example content looks like following:

NEWRELIC_API_KEY=NRAK-XXX
NEWRELIC_ACCOUNT_ID=1
#NEWRELIC_REGION=EU
NEWRELIC_CLUSTER_NAME=my-cluster

Also in order to run e2e tests, you will need a working environment available with the newrelic-k8s-metrics-adapter running. Both installing the newrelic-k8s-metrics-adapter chart or spinning up the environment with make tilt-up are possible options.

It is also possible to run such tests against any cluster you have access to by setting the environment variable TEST_KUBECONFIG=/your/kube/config/path.

Support

Contribute

We encourage your contributions to improve newrelic-k8s-metrics-adapter! Keep in mind that when you submit your pull request, you'll need to sign the CLA via the click-through using CLA-Assistant. You only have to sign the CLA one time per project.

If you have any questions, or to execute our corporate CLA (which is required if your contribution is on behalf of a company), drop us an email at [email protected].

A note about vulnerabilities

As noted in our security policy, New Relic is committed to the privacy and security of our customers and their data. We believe that providing coordinated disclosure by security researchers and engaging with the security community are important means to achieve our security goals.

If you believe you have found a security vulnerability in this project or any of New Relic's products or websites, we welcome and greatly appreciate you reporting it to New Relic through HackerOne.

If you would like to contribute to this project, review these guidelines.

To all contributors, we thank you! Without your contribution, this project would not be what it is today.

License

The newrelic-k8s-metrics-adapter is licensed under the Apache 2.0 License.

The newrelic-k8s-metrics-adapter also uses source code from third-party libraries. You can find full details on which libraries are used, and the terms under which they are licensed in the third-party notices document.

About

This repository hosts the NewRelic Kubernetes metrics adapter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 77.7%
  • Starlark 7.1%
  • Makefile 6.7%
  • Mustache 3.3%
  • Shell 2.6%
  • Python 1.4%
  • Dockerfile 1.2%