wavefront-kubernetes-adapter

This repository provides a Wavefront Kubernetes HPA (Horizontal Pod Autoscaler) adapter that implements the custom metrics (custom.metrics.k8s.io/v1beta1
) and external metrics (external.metrics.k8s.io/v1beta1
) APIs. The adapter can be used with the autoscaling/v2
HPA in Kubernetes 1.9+.
Prerequisites
- Kubernetes 1.9+
- The aggregation layer needs to be enabled in your Kubernetes cluster prior to deploying the Wavefront adapter.
Introduction
See the introduction for an overview of the functionality provided by this adapter.
Configuration
The adapter takes the standard Kubernetes generic API server arguments.
Additionally, the following arguments are specific to this adapter:
wavefront-url
: Wavefront URL of the form https://INSTANCE.wavefront.com
wavefront-token
: Wavefront API token with permissions to query for points
wavefront-metric-prefix
: Metrics under the prefix are exposed in the custom metrics API. Defaults to heapster
.
metrics-relist-interval
: The interval at which to fetch the list of metrics from Wavefront. Defaults to 10 minutes.
external-metrics-config
: Optional configuration file driving the external metrics API. If omitted, the external metrics API will not be supported.
Installation
- Clone this repo.
- Edit the
wavefront-url
and wavefront-token
properties in deploy/manifests/custom-metrics-apiserver-deployment.yaml
.
- Optionally, edit the
deploy/manifests/custom-metrics-config-map.yaml
and modify the external metrics you wish to export.
- Finally run
kubectl apply -f deploy/manifests
to deploy the adapter in your Kubernetes cluster.
To verify the installation, run kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jq .
. You should get the list of supported metrics similar to:
{
"kind": "APIResourceList",
"apiVersion": "v1",
"groupVersion": "custom.metrics.k8s.io/v1beta1",
"resources": [
{
"name": "nodes/cpu.node_reservation",
"singularName": "",
"namespaced": false,
"kind": "MetricValueList",
"verbs": [
"get"
]
},
{
"name": "pods/network.rx_errors_rate",
"singularName": "",
"namespaced": true,
"kind": "MetricValueList",
"verbs": [
"get"
]
},
{
"name": "pods/network.tx_rate",
"singularName": "",
"namespaced": true,
"kind": "MetricValueList",
"verbs": [
"get"
]
},
{
"name": "pods/cpu.request",
"singularName": "",
"namespaced": true,
"kind": "MetricValueList",
"verbs": [
"get"
]
}
]
}
You can similarly run kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1" | jq .
to verify the external metrics API.
HPA Autoscaling
See the sample configurations under hpa-examples on how to autoscale deployments based on metrics under the custom or external metrics APIs.
Run kubectl describe hpa example-hpa-custom-metrics
to verify the autoscaling works.