An implementation of the Kubernetes Custom Metrics API and External Metrics API for AWS CloudWatch metrics.
This adapter allows you to scale your Kubernetes deployment using the Horizontal Pod Autoscaler (HPA) with metrics from AWS CloudWatch.
This adapter requires your node groups to have the following permissions to access metric data from Amazon CloudWatch.
cloudwatch:GetMetricData
You can create an IAM policy using this template and attach it to your node group role.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"cloudwatch:GetMetricData"
],
"Resource": "*"
}
]
}
Requires a Kubernetes cluster with Metric Server deployed.
Now, deploy the CRD and adapter
using the Helm charts in the /charts
directory:
$ helm repo add k8s-cloudwatch-adapter https://gitlab.com/api/v4/projects/45916012/packages/helm/stable
$ helm install k8s-cloudwatch-adapter-crd .k8s-cloudwatch-adapter/k8s-cloudwatch-adapter-crd \
> --namespace custom-metrics \
> --create-namespace
NAME: k8s-cloudwatch-adapter-crd
LAST DEPLOYED: Mon May 8 11:36:53 2023
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
$ helm install k8s-cloudwatch-adapter k8s-cloudwatch-adapter/k8s-cloudwatch-adapter --namespace custom-metrics
NAME: k8s-cloudwatch-adapter
LAST DEPLOYED: Mon May 8 13:20:17 2023
NAMESPACE: custom-metrics
STATUS: deployed
REVISION: 1
TEST SUITE: None
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": [
]
}
There is a sample SQS application provided in this repository for you to test how the adapter works. Refer to this guide.
This library is licensed under the Apache 2.0 License. Contributions are welcomed!
Report any non-security issues in the Github Issue Tracker.
Please see CONTRIBUTING.md for information on reporting security issues.