Install the Kubernetes Event-driven Autoscaling (KEDA) add-on using the Azure CLI
This article shows you how to install the Kubernetes Event-driven Autoscaling (KEDA) add-on to Azure Kubernetes Service (AKS) using the Azure CLI.
Important
Your cluster Kubernetes version determines what KEDA version will be installed on your AKS cluster. To see which KEDA version maps to each AKS version, see the AKS managed add-ons column of the Kubernetes component version table.
For GA Kubernetes versions, AKS offers full support of the corresponding KEDA minor version in the table. Kubernetes preview versions and the latest KEDA patch are partially covered by customer support on a best-effort basis. As such, these features aren't meant for production use. For more information, see the following support articles:
Note
KEDA version 2.15 introduces a breaking change that removes pod identity support. We recommend moving over to workload identity for your authentication if you're using pod identity. While the KEDA managed add-on doesn't currently run KEDA version 2.15, it will begin running it in the AKS preview version 1.31.
For more information on how to securely scale your applications with workload identity, please read our tutorial. To view KEDA's breaking change/deprecation policy, please read their official documentation.
Before you begin
- You need an Azure subscription. If you don't have an Azure subscription, you can create a Trial.
- You need the Azure CLI installed.
- Ensure you have firewall rules configured to allow access to the Kubernetes API server. For more information, see Outbound network and FQDN rules for Azure Kubernetes Service (AKS) clusters.
Note
If you're using Microsoft Entra Workload ID and you enable KEDA before Workload ID, you need to restart the KEDA operator pods so the proper environment variables can be injected:
Restart the pods by running
kubectl rollout restart deployment keda-operator -n kube-system
.Obtain KEDA operator pods using
kubectl get pod -n kube-system
and finding pods that begin withkeda-operator
.Verify successful injection of the environment variables by running
kubectl describe pod <keda-operator-pod> -n kube-system
. UnderEnvironment
, you should see values forAZURE_TENANT_ID
,AZURE_FEDERATED_TOKEN_FILE
, andAZURE_AUTHORITY_HOST
.
Install the KEDA add-on with Azure CLI
To install the KEDA add-on, use --enable-keda
when creating or updating a cluster.
Enable the KEDA add-on on your AKS cluster
Note
While KEDA provides various customization options, the KEDA add-on currently provides basic common configuration.
If you require custom configurations, you can manually edit the KEDA YAML files to customize the installation. Azure doesn't offer support for custom configurations.
Create a new AKS cluster with KEDA add-on enabled
Create a resource group using the
az group create
command.az group create --name myResourceGroup --location eastus
Create a new AKS cluster using the
az aks create
command and enable the KEDA add-on using the--enable-keda
flag.az aks create \ --resource-group myResourceGroup \ --name myAKSCluster \ --enable-keda \ --generate-ssh-keys
Enable the KEDA add-on on an existing AKS cluster
Update an existing cluster using the
az aks update
command and enable the KEDA add-on using the--enable-keda
flag.az aks update \ --resource-group myResourceGroup \ --name myAKSCluster \ --enable-keda
Get the credentials for your cluster
Get the credentials for your AKS cluster using the
az aks get-credentials
command.az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
Verify the KEDA add-on is installed on your cluster
Verify the KEDA add-on is installed on your cluster using the
az aks show
command and set the--query
parameter toworkloadAutoScalerProfile.keda.enabled
.az aks show --resource-group myResourceGroup --name myAKSCluster --query "workloadAutoScalerProfile.keda.enabled"
The following example output shows the KEDA add-on is installed on the cluster:
true
Verify KEDA is running on your cluster
Verify the KEDA add-on is running on your cluster using the
kubectl get pods
command.kubectl get pods -n kube-system
The following example output shows the KEDA operator, admissions hook, and metrics API server are installed on the cluster:
keda-admission-webhooks-**********-2n9zl 1/1 Running 0 3d18h keda-admission-webhooks-**********-69dkg 1/1 Running 0 3d18h keda-operator-*********-4hb5n 1/1 Running 0 3d18h keda-operator-*********-pckpx 1/1 Running 0 3d18h keda-operator-metrics-apiserver-**********-gqg4s 1/1 Running 0 3d18h keda-operator-metrics-apiserver-**********-trfcb 1/1 Running 0 3d18h
Verify the KEDA version on your cluster
To verify the version of your KEDA, use kubectl get crd/scaledobjects.keda.sh -o yaml
. For example:
kubectl get crd/scaledobjects.keda.sh -o yaml
The following example output shows the configuration of KEDA in the app.kubernetes.io/version
label:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.0
meta.helm.sh/release-name: aks-managed-keda
meta.helm.sh/release-namespace: kube-system
creationTimestamp: "2023-08-09T15:58:56Z"
generation: 1
labels:
app.kubernetes.io/component: operator
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keda-operator
app.kubernetes.io/part-of: keda-operator
app.kubernetes.io/version: 2.10.1
helm.toolkit.fluxcd.io/name: keda-adapter-helmrelease
helm.toolkit.fluxcd.io/namespace: 64d3b6fd3365790001260647
name: scaledobjects.keda.sh
resourceVersion: "1421"
uid: 29109c8c-638a-4bf5-ac1b-c28ad9aa11fa
spec:
conversion:
strategy: None
group: keda.sh
names:
kind: ScaledObject
listKind: ScaledObjectList
plural: scaledobjects
shortNames:
- so
singular: scaledobject
scope: Namespaced
# Redacted due to length
Disable the KEDA add-on on your AKS cluster
Disable the KEDA add-on on your cluster using the
az aks update
command with the--disable-keda
flag.az aks update \ --resource-group myResourceGroup \ --name myAKSCluster \ --disable-keda
Next steps
This article showed you how to install the KEDA add-on on an AKS cluster using the Azure CLI.
With the KEDA add-on installed on your cluster, you can deploy a sample application to start scaling apps.
For information on KEDA troubleshooting, see Troubleshoot the Kubernetes Event-driven Autoscaling (KEDA) add-on.
To learn more, view the upstream KEDA docs.