Exercise - Deploy KEDA on an Azure Kubernetes Service cluster
Install the aks-preview
Azure CLI extension
Open the Azure Cloud Shell in your browser and select Bash.
Install the
aks-preview
extension using theaz extension add
command:az extension add --name aks-preview --allow-preview true
Update to the latest version of the
aks-preview
extension using theaz extension update
command:az extension update --name aks-preview --allow-preview true
Register the AKS-KedaPreview
feature flag
Register the
AKS-KedaPreview
feature flag using theaz feature register
command:az feature register --name AKS-KedaPreview --namespace Microsoft.ContainerService
It can take few minutes for the status to show as Registered.
Verify the registration status using the
az feature show
command:az feature show --name AKS-KedaPreview --namespace Microsoft.ContainerService
When the status reflects as Registered, refresh the Microsoft.ContainerService resource provider's registration using the
az provider register
command:az provider register --namespace Microsoft.ContainerService
Enable the KEDA add-on on an AKS cluster
Use the following commands to create environment variables for the resource group name, location, and cluster name for use throughout this module. If you want to use your own names or location, replace the values in the following commands with your own.
RESOURCE_GROUP=myContosoRG LOCATION=westus2 CLUSTER_NAME=myContosoCluster
Create an Azure resource group using the
az group create
command:az group create -n $RESOURCE_GROUP -l $LOCATION
Create an AKS cluster with the KEDA add-on enabled using the
az aks create
command and the--enable-keda
flag:az aks create -g $RESOURCE_GROUP -n $CLUSTER_NAME --enable-keda --generate-ssh-keys
This command can take a few minutes to run.
Connect to your AKS cluster using the
az aks get-credentials
command:az aks get-credentials -n $CLUSTER_NAME -g $RESOURCE_GROUP
Verify the KEDA add-on is installed on your cluster using the
az aks show
command and set the--query
flag toworkloadAutoScalerProfile.keda.enabled
:az aks show -n $CLUSTER_NAME -g $RESOURCE_GROUP --query "workloadAutoScalerProfile.keda.enabled"
Your output should look like the following example output, which shows the KEDA add-on is installed on the cluster:
true
Create an Azure Cache for Redis instance
Use the following command to create an environment variable for the Redis name for use throughout this module:
REDIS_NAME=contoso-redis-$RANDOM
Create an Azure Cache for Redis instance using the
az redis create
command:az redis create --location $LOCATION --name $REDIS_NAME --resource-group $RESOURCE_GROUP --sku Basic --vm-size c0 --enable-non-ssl-port
This command can take several minutes to run.
Create environment variables for the Redis host and key for use throughout this module using the
az redis show
andaz redis list-keys
commands:REDIS_HOST=$(az redis show -n $REDIS_NAME -g $RESOURCE_GROUP -o tsv --query "hostName") REDIS_KEY=$(az redis list-keys --name $REDIS_NAME --resource-group $RESOURCE_GROUP -o tsv --query "primaryKey")