Skip to content

An implementation of Kubernetes Custom Metrics API for NewRelic metrics

License

Notifications You must be signed in to change notification settings

KrishnaNagam/k8s-newrelic-adapter

 
 

Repository files navigation

docker image size image layers image pulls

Kubernetes Custom Metrics Adapter for NewRelic

An implementation of the Kubernetes Custom Metrics API and External Metrics API for NewRelic metrics.

This adapter allows you to scale your Kubernetes deployment using the Horizontal Pod Autoscaler (HPA) with metrics from NewRelic.

Prerequsites

This adapter requires the following to access metric data from Amazon NewRelic.

  • Account ID - Change NEW_RELIC_ACCOUNT_ID in deploy/adapter.yaml to your NewRelic Account ID
  • Personal API Token - Create a secret called newrelic with The key api_key (The key should be encode to base64)
apiVersion: v1
kind: Secret
metadata:
  name: newrelic
  namespace: custom-metrics
type: Opaque
data:
  api_key: 1234=

You can get The personal API token from Here.

Deploy

Requires a Kubernetes cluster with Metric Server deployed, Amazon EKS cluster is fine too.

Now deploy the adapter to your Kubernetes cluster.

$ kubectl apply -f https://raw.githubusercontent.com/kuperiu/k8s-newrelic-adapter/master/deploy/adapter.yaml
namespace/custom-metrics created
clusterrolebinding.rbac.authorization.k8s.io/k8s-newrelic-adapter:system:auth-delegator created
rolebinding.rbac.authorization.k8s.io/k8s-newrelic-adapter-auth-reader created
deployment.apps/k8s-newrelic-adapter created
clusterrolebinding.rbac.authorization.k8s.io/k8s-newrelic-adapter-resource-reader created
serviceaccount/k8s-newrelic-adapter created
service/k8s-newrelic-adapter created
apiservice.apiregistration.k8s.io/v1beta1.external.metrics.k8s.io created
clusterrole.rbac.authorization.k8s.io/k8s-newrelic-adapter:external-metrics-reader created
clusterrole.rbac.authorization.k8s.io/k8s-newrelic-adapter-resource-reader created
clusterrolebinding.rbac.authorization.k8s.io/k8s-newrelic-adapter:external-metrics-reader created
customresourcedefinition.apiextensions.k8s.io/externalmetrics.metrics.newrelic created
clusterrole.rbac.authorization.k8s.io/k8s-newrelic-adapter:crd-metrics-reader created
clusterrolebinding.rbac.authorization.k8s.io/k8s-newrelic-adapter:crd-metrics-reader created

This creates a new namespace custom-metrics and deploys the necessary ClusterRole, Service Account, Role Binding, along with the deployment of the adapter.

Verifying the deployment

Next you can query the APIs to see if the adapter is deployed correctly by running:

$ kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1" | jq .
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "external.metrics.k8s.io/v1beta1",
  "resources": [
  ]
}

Deploying The sample application

There is a sample application provided in this repository for you to test how the adapter works. Refer to this guide

License

This library is licensed under the Apache 2.0 License.

Issues

Report any issues in the Github Issues

About

An implementation of Kubernetes Custom Metrics API for NewRelic metrics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 91.8%
  • Shell 4.4%
  • Smarty 1.9%
  • Makefile 1.7%
  • Dockerfile 0.2%