Skip to main content

KEDA External Scaler

The Sawmills implementation provides a powerful bridge between OpenTelemetry (OTel) and KEDA, enabling dynamic scaling based on OTel metrics. This implementation offers a flexible and efficient way to scale your applications based on custom metrics collected through OpenTelemetry.

Architecture Overview

The implementation consists of three main components:
  1. Receiver: Implements the OTLP Receiver specification, running a gRPC server (default port 4317) that receives and processes incoming metrics.
  2. In-Memory Metric Storage: A high-performance in-memory storage system that maintains recent metric measurements for each metric vector. Key features include:
    • Automatic cleanup of stale measurements
    • Label-based querying support
    • Optimized for real-time metric processing
  3. External Scaler: Implements the KEDA External Scaler contract, running a gRPC server (default port 4318) that queries the metric storage and communicates with the KEDA operator.

Installation

Prerequisites

  • Kubernetes cluster
  • KEDA installed
  • Helm 3.x

Step 1: Install KEDA

helm repo add kedacore https://kedacore.github.io/charts
helm repo update
helm upgrade -i keda kedacore/keda --namespace keda --create-namespace

Step 2: Configure Sawmills Collector with KEDA Scaler

Create a values.yaml file with the following configuration to enable KEDA scaler and external scaling:
managedCharts:
  sawmills-collector:
    # Enable KEDA-based autoscaling
    keda:
      enabled: true
      minReplicas: 1
      maxReplicas: 10
      pollingInterval: 30
      cooldownPeriod: 300
      scaling:
        external:
          enabled: true
          metricType: Value
          metadata:
            scalerAddress: "sawmills-collector-keda-otel-scaler.sawmills.svc.cluster.local:4418"
            query: "histogram_quantile(0.95, sum(rate(http_server_duration_bucket[2m])) by (le))"
            targetValue: "2000"

    # Enable KEDA scaler component
    kedaScaler:
      enabled: true