Using KEDA autoscaler with groundcover

groundcover can be used as a Prometheus datasource for KEDA autoscaler. Any metric stored in groundcover can be queried and used to automatically make decisions about scaling your infrastructure.

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.

Prometheus Endpoint for KEDA

groundcover provides a Prometheus-compatible API endpoint that can be used with KEDA:

URL: https://app.groundcover.com/api/prometheus Authentication: Bearer token

groundcover exposes APIs to query data stored in the platform from outside the UI. For KEDA integration, we use the Prometheus-compatible API endpoint: https://app.groundcover.com/api/prometheus

API Key Setup

Querying the groundcover API requires setting up a dedicated API key for authentication. API keys provide secure, programmatic access to the API on behalf of a service account and inherit that account's permissions.

For detailed information about creating and managing API keys, see the API Keys documentation.

Key points:

  • Only Admins can create API keys

  • Keys are shown only once during creation - store them securely

  • API keys authenticate using Bearer token format

  • Keys inherit permissions from their parent service account

We will be referring to this API key below as api-key.

Setting up KEDA Authentication with groundcover

KEDA requires access to the api-key so it can add it to the Prometheus requests as a Bearer token. We will set up two Kubernetes objects 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 <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 api-key to be used as a Bearer token in the Authorization header.

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 metric which indicates the amount of ready replicas for our deployment. Note that we apply the deployment="bookapi" filter, to query the metric specifically for our example deployment.

Testing Your KEDA Configuration

Validate Metrics Query

Test your PromQL query before deploying:

Check KEDA Logs

Monitor KEDA controller logs to ensure proper authentication and metric retrieval:

Verify Scaling Behavior

Test scaling by generating load or manually adjusting metric values and observing pod scaling.

Last updated