Skip to content

Kubernets Alpha provider to deploy Keda scaled-object (deployment only atm)

Notifications You must be signed in to change notification settings

asaphe/terraform-keda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Keda

This module should run as part of a deployment to ensure a scaledobject has been created.

Version

  • Terraform version 1.0.0
  • Kubernetes provider - enable experimental manifest

Provider section

provider "kubernetes" {
  experiments {manifest_resource = true}

  host                   = data.aws_eks_cluster.eks.endpoint
  cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks.certificate_authority[0].data)
  token                  = data.aws_eks_cluster_auth.auth.token
}

Supports

  • scaledObject for a deployment

    Job is not supported at this time

Examples (Final YAML version)

A scaled object based on Kafka lag and CPU utilization (advanced behavior is set to match the application requirements)

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: router
  namespace: default
  labels:
    name: router-scaledobject
spec:
  scaleTargetRef:
    kind: Deployment
    name: router
  pollingInterval: 30
  cooldownPeriod: 300
  minReplicaCount: 2
  maxReplicaCount: 8
  advanced:
    restoreToOriginalReplicaCount: true
    horizontalPodAutoscalerConfig:
      behavior:
        scaleDown:
          stabilizationWindowSeconds: 900 # consider past 15min
          policies:
          - type: Percent
            value: 50
            periodSeconds: 60
          - type: Pods
            value: 2
            periodSeconds: 60
          selectPolicy: Min
  triggers:
  - type: kafka
    metadata:
      bootstrapServers: kafka-brokers.dev.example.com:9092
      consumerGroup: router_app
      topic: router_2
      lagThreshold: "10000"
  - type: cpu
    metadata:
      type: Utilization
      value: "95"

A scaled object based on a Prometheus metric (notice the query uses sum)

apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: keda-test-scaledobject
  namespace: default
spec:
  scaleTargetRef:
    deploymentName: kedademo
  triggers:
  - type: prometheus
    metadata:
      serverAddress: http://prometheus.svc:9090
      metricName: custom_metric_counter_total_by_pod
      threshold: '3'
      query: sum(custom_metric_counter_total_by_pod{namespace!="",pod!=""})

About

Kubernets Alpha provider to deploy Keda scaled-object (deployment only atm)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages