Terraform module deploys KEDA (Kubernetes Event-driven Autoscaling) into a Kubernetes cluster. KEDA allows for fine-grained autoscaling (including to/from zero) for event-driven Kubernetes workloads. KEDA serves as a Kubernetes Metrics Server and allows users to define autoscaling rules using a dedicated Kubernetes custom resource definition.
The module simplifies the deployment and configuration of KEDA, enabling event-driven autoscaling for your Kubernetes workloads.
Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:
shellterraform login solutions.corewide.com
Initialize mandatory providers:
Copy and paste into your Terraform configuration and insert the variables:
hclmodule "tf_k8s_keda" {
source = "solutions.corewide.com/kubernetes/tf-k8s-keda/helm"
version = "~> 2.1.0"
# specify module inputs here or try one of the examples below
...
}
Initialize the setup:
shellterraform init
Corewide DevOps team strictly follows Semantic Versioning
Specification
to
provide our clients with products that have predictable upgrades between versions. We
recommend
pinning
patch versions of our modules using pessimistic
constraint operator (~>) to prevent breaking changes during upgrades.
To get new features during the upgrades (without breaking compatibility), use
~> 2.1 and run
terraform init -upgrade
For the safest setup, use strict pinning with version = "2.1.0"
|
Module
35% off
|
$292
|
| TOTAL | $292 |
Terraform module deploys KEDA (Kubernetes Event-driven Autoscaling) into a Kubernetes cluster. KEDA allows for fine-grained autoscaling (including to/from zero) for event-driven Kubernetes workloads. KEDA serves as a Kubernetes Metrics Server and allows users to define autoscaling rules using a dedicated Kubernetes custom resource definition.
The module simplifies the deployment and configuration of KEDA, enabling event-driven autoscaling for your Kubernetes workloads.
All notable changes to this project are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
http_addon input2.20.0 and newer)2.15.2 to 2.20.2) and application (from 2.15.0 to 2.20.2) versions3.03.1custom_values variable to be supplied as a single block with all subparameters instead of a map(Last version compatible with Helm and Kubernetes Terraform providers version 2.0)
First stable version
v1.x to v2.xModule from v2.0 has several adjustments that require attention:
```hcl
terraform {
required_providers {
helm = {
source = "hashicorp/helm"
version = "~> 3.1"
}
text kubernetes = {
source = "hashicorp/kubernetes"
version = "~> 3.0"
}
}
}
```
Upgrade project dependencies:
bash
terraform init --upgrade
custom_values input must be supplied as a single map with all sub-parameters instead of a map of Helm set array entities:```hcl
module "keda" {
...
# From v1.x format
custom_values = {
"logging.operator.level" = "debug"
}
scdoc# To v2.0 format
custom_values = {
logging = {
operator = {
level = "debug"
}
}
}
}
```
Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
v2.0.x to v2.1.xModule from v2.1 uses KEDA Helm chart and application version 2.20.2 by default and adds a minimal version policy - allowed versions are 2.20.0 and newer.
You can skip this chapter if you have already used KEDA version 2.20.0 or newer.
If you have declared app_version and/or chart_version, please confirm that they match the new version requirements.
Now the configuration can be applied:
bashterraform apply
Minimal setup with default parameters:
hclmodule "keda" {
source = "solutions.corewide.com/kubernetes/tf-k8s-keda/helm"
version = "~> 2.1"
}
Deploy KEDA operator and metrics server with 2 replicas each, set pod annotation to configure with the AWS IAM role, enable Prometheus monitoring, and restrict KEDA to watch only specific namespaces to scale their workloads. KEDA resources are placed on a specific node with debug logging enabled:
hclmodule "keda" {
source = "solutions.corewide.com/kubernetes/tf-k8s-keda/helm"
version = "~> 2.1"
operator_replicas = 2
metrics_server_replicas = 2
watch_namespaces = [
"prod",
"dev",
]
pod_annotations = {
"iam.amazonaws.com/role" = "arn:aws:iam::123456789012:role/keda-operator"
}
prometheus = {
create_service_monitor = true
}
node_selector = {
"node-type" = "worker"
}
custom_values = {
logging = {
operator = {
level = "debug"
}
}
}
}
| Variable | Description | Type | Default | Required | Sensitive |
|---|---|---|---|---|---|
name_prefix |
Naming prefix for all the resources created by the module | string |
yes | no | |
app_version |
KEDA version to deploy (image tag, compatible versions are 2.20.0 and newer) |
string |
2.20.2 |
no | no |
chart_version |
KEDA Helm chart version to deploy (compatible versions are 2.20.0 and newer) |
string |
2.20.2 |
no | no |
create_namespace |
Indicates whether to create a dedicated namespace for KEDA deployment | bool |
true |
no | no |
custom_values |
KEDA Helm chart custom values | any |
{} |
no | no |
http_addon |
KEDA HTTP addon parameters: | object |
{} |
no | no |
http_addon.app_version |
KEDA HTTP addon server version | string |
0.15.0 |
no | no |
http_addon.chart_version |
KEDA HTTP addon chart version | string |
0.15.0 |
no | no |
http_addon.custom_values |
KEDA HTTP addon Helm chart custom values | any |
{} |
no | no |
http_addon.enabled |
Toggle KEDA HTTP addon installation | bool |
false |
no | no |
http_addon.node_selector |
Node selector for the KEDA HTTP addon components. By default, the same as in KEDA | map(string) |
{} |
no | no |
http_addon.watch_namespaces |
List of namespaces KEDA HTTP addon should watch. Empty means watch all namespaces. By default, the same as in KEDA | list(string) |
[] |
no | no |
metrics_server_replicas |
Number of replicas for the KEDA metrics API server | number |
2 |
no | no |
namespace |
The namespace to install KEDA into | string |
keda |
no | no |
node_selector |
Node selector for KEDA components | map(string) |
{} |
no | no |
operator_replicas |
Number of replicas for the KEDA operator | number |
2 |
no | no |
pod_annotations |
Annotations to add to KEDA pods (operator and metrics API server) | map(string) |
{} |
no | no |
prometheus |
KEDA Prometheus integration configuration parameters: | object |
{} |
no | no |
prometheus.create_pod_monitor |
Indicates if a PodMonitor should be created for Prometheus monitoring | bool |
false |
no | no |
prometheus.create_service_monitor |
Indicates if a ServiceMonitor should be created for Prometheus monitoring | bool |
false |
no | no |
service_account |
KEDA operator ServiceAccount configuration parameters: | object |
{} |
no | no |
service_account.annotations |
KEDA operator service account annotations | map(string) |
{} |
no | no |
service_account.create |
Indicates creation service account for KEDA operator | bool |
true |
no | no |
service_account.name |
KEDA operator service account name | string |
keda-operator |
no | no |
watch_namespaces |
List of namespaces KEDA should watch. Empty means watch all namespaces | list(string) |
[] |
no | no |
| Output | Description | Type | Sensitive |
|---|---|---|---|
namespace |
The namespace where KEDA is installed | resource |
no |
service_account_name |
The name of the ServiceAccount used by KEDA operator | attribute |
no |
| Dependency | Version | Kind |
|---|---|---|
terraform |
>= 1.3 |
CLI |
hashicorp/helm |
~> 3.1 |
provider |
hashicorp/kubernetes |
~> 3.0 |
provider |
These components are included as is under the terms of their corresponding licenses.
| Component | License |
|---|---|
| KEDA | Apache-2.0 |
| KEDA Helm charts | Apache-2.0 |
| KEDA HTTP addon | Apache-2.0 |