This HPA adapter can be used to horizontally autoscale your Kubernetes Pods based on metrics available within Operations for Applications.
By default, the Kubernetes HorizontalPodAutoscaler controller fetches metrics from a series of APIs. This adapter implements the APIs detailed below.
For the custom metrics API, this adapter provides all Kubernetes metrics collected using the Operations for Applications Kubernetes Metrics Collector.
This can be configured using the wavefront-metric-prefix
adapter property. See metrics.md for the list of metrics provided through this API.
Use the external metrics API described below if you want to use non-Kubernetes metrics or Kubernetes metrics collected using a different mechanism than the Operations for Applications Kubernetes Metrics Collector.
The external metrics API allows you to autoscale on any arbitrary metric available in Operations for Applications.
Metrics can be specified via annotations on HPAs or via a static configuration file.
Annotations are metadata you attach to Kubernetes objects.
The adapter can dynamically discover HPAs and source external metrics via annotations. The annotations should be of the form wavefront.com.external.metric/<metric_name>: '<ts query>'
. For example:
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: example-app
annotations:
wavefront.com.external.metric/sqs_queue_size: 'align(5m, avg(ts("aws.sqs.approximatenumberofmessagesvisible", QueueName="app-queue")))'
spec:
minReplicas: 1
maxReplicas: 5
metrics:
- type: External
external:
metricName: sqs_queue_size
targetAverageValue: 248000m
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: example-app
Note: The external metric names should be globally unique.
To specify external metrics via a configuration file:
- Deploy a Kubernetes ConfigMap listing the metrics you want to autoscale on.
- Configure the
external-metrics-config
adapter property based on the ConfigMap and redeploy the adapter. - Deploy an HPA based on an external metric.
Refer to the autoscaling spec for more details on configuring HPAs based on the custom or external metrics APIs.