Keda.sh event driven based autoscaler. That watches your source and scale your app based on strategies. Keda is just like HPA (Horizontal Pod Autoscaler; Which is scale based on metrics).

Keda supports

Fundamental

Keda has two core components.

  1. Agent (Operator)
  1. Metrics

Installation

# Add chart
helm repo add kedacore https://kedacore.github.io/charts

# Install keda in keda namespace
# Keda will install operator, and metrics api-server
helm -n keda install keda kedacore/keda

# Verification (Make sure you will find *.keda.sh resources)
kubectl get crd
# triggerauthentications.keda.sh - Namespace based authn
# scaledobjects.keda.sh - Scaling Deployments / Statefulset
# scaledjobs.keda.sh - Scaling Jobs
# clustertriggerauthentications.keda.sh - Cluster based authn

Usage

We are using simple hello-world container, and creating the job per SQS message.

apiVersion: v1
kind: Secret
metadata:
  name: keda-secrets
  namespace: keda-test
data:
  AWS_ACCESS_KEY_ID: ENCODED_ACCESS_KEY
  AWS_SECRET_ACCESS_KEY: ENCODED_SECRET_KEY
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
  name: keda-trigger-auth-aws-credentials
  namespace: keda-test
spec:
  secretTargetRef:
  - parameter: awsAccessKeyID  
    name: keda-secrets            
    key: AWS_ACCESS_KEY_ID        
  - parameter: awsSecretAccessKey 
    name: keda-secrets            
    key: AWS_SECRET_ACCESS_KEY   
apiVersion: keda.sh/v1alpha1
kind: ScaledJob
metadata:
  name: hello-world
  namespace: keda-test
spec:
  jobTargetRef:
    template:
      spec:
        containers:
        - name: hello-world
          image: hello-world
        restartPolicy: Never
    backoffLimit: 4  
  pollingInterval: 10 # Interval of queue length
  maxReplicaCount: 30 
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 2
  triggers:
  - type: aws-sqs-queue
    authenticationRef:
      name: keda-trigger-auth-aws-credentials
    metadata:
      queueURL: https://sqs.ap-south-1.amazonaws.com/409546876326/keda-test
      queueLength: "1" # Number of worker per based on length
      awsRegion: "ap-south-1"

<aside> ⚠️

This article was written around 2022. This may be subject to change.

</aside>