Using KEDA autoscaler with groundcover
groundcover can be used as a Promethues datasource for KEDA autoscaler. Any metric stored in groundcover can be queried and used to automatically make decisions about scaling your infrastructure or deployments.
In the following example we will be controlling the replica count of a Kubernetes deployment. This common example can be extended and used to query any type of metrics, and we suggest experimenting with it to fit your own use cases.
Preparing to query the groundcover Prometheus datasource
groundcover exposes APIs to query data stored in the platform from outside the UI. In our case we will be using the Prometheus
endpoint:
https://ds.groundcover.com/datasources/prometheus
Querying the groundcover datasources APIs requires setting up a dedicated apikey for the authentication. If you haven't done this already, please follow these steps before proceeding.
We will be referring to this apikey below as ds-api-key
.
Setting up KEDA authentication with groundcover
KEDA requires access to the ds-api-key so it can add it to the Prometheus requests. We will set up two Kubernetes object for this purpose - a Secret object and a ClusterTriggerAuthentication object.
Defining the Secret object
We will be using a simple static Secret object, but any type can be used, including external secrets. Make sure to replace the <ds-api-key>
placeholder with the api key previously created.
Defining the ClusterTriggerAuthentication object
Now that we have the secret object defined, we need to tell KEDA how to use it. groundcover requires the ds-api-key to appear as an additional header in the requests to our datasources, and that's exactly what we will define below.
Defining the auto-scaled object
Now that we have set up KEDA to properly authenticate with groundcover, we can define our first auto-scaling behavior.
We will be defining a Prometheus
trigger, querying the groundcover_kube_deployment_status_replicas_ready
which indicates the amount of ready replicas for our deployment. Note that we apply the deployment="example"
filter, to query the metric specifically for our example deployment.
Last updated