|
1 | 1 | ---
|
2 |
| -title: Install the Kubernetes Event-driven Autoscaling (KEDA) add-on by using Azure CLI |
3 |
| -description: Use Azure CLI to deploy the Kubernetes Event-driven Autoscaling (KEDA) add-on to Azure Kubernetes Service (AKS). |
| 2 | +title: Install the Kubernetes Event-driven Autoscaling (KEDA) add-on using the Azure CLI |
| 3 | +description: Use the Azure CLI to deploy the Kubernetes Event-driven Autoscaling (KEDA) add-on to Azure Kubernetes Service (AKS). |
4 | 4 | author: raorugan
|
5 | 5 | ms.author: raorugan
|
6 | 6 | ms.topic: article
|
7 |
| -ms.date: 10/10/2022 |
| 7 | +ms.date: 09/26/2023 |
8 | 8 | ms.custom: template-how-to, devx-track-azurecli
|
9 | 9 | ---
|
10 | 10 |
|
11 |
| -# Install the Kubernetes Event-driven Autoscaling (KEDA) add-on by using Azure CLI |
| 11 | +# Install the Kubernetes Event-driven Autoscaling (KEDA) add-on using the Azure CLI |
12 | 12 |
|
13 |
| -This article shows you how to install the Kubernetes Event-driven Autoscaling (KEDA) add-on to Azure Kubernetes Service (AKS) by using Azure CLI. The article includes steps to verify that it's installed and running. |
| 13 | +This article shows you how to install the Kubernetes Event-driven Autoscaling (KEDA) add-on to Azure Kubernetes Service (AKS) using the Azure CLI. |
14 | 14 |
|
15 | 15 | [!INCLUDE [Current version callout](./includes/keda/current-version-callout.md)]
|
16 | 16 |
|
17 |
| -## Prerequisites |
| 17 | +## Before you begin |
18 | 18 |
|
19 |
| -- An Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free). |
20 |
| -- [Azure CLI installed](/cli/azure/install-azure-cli). |
21 |
| -- Firewall rules are configured to allow access to the Kubernetes API server. ([learn more][aks-firewall-requirements]) |
| 19 | +- You need an Azure subscription. If you don't have an Azure subscription, you can create a [free account](https://azure.microsoft.com/free). |
| 20 | +- You need the [Azure CLI installed](/cli/azure/install-azure-cli). |
| 21 | +- 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][aks-firewall-requirements]. |
| 22 | +- [Install the `aks-preview` Azure CLI extension](#install-the-aks-preview-azure-cli-extension). |
| 23 | +- [Register the `AKS-KedaPreview` feature flag](#register-the-aks-kedapreview-feature-flag). |
22 | 24 |
|
23 |
| -## Install the aks-preview Azure CLI extension |
| 25 | +### Install the `aks-preview` Azure CLI extension |
24 | 26 |
|
25 | 27 | [!INCLUDE [preview features callout](includes/preview/preview-callout.md)]
|
26 | 28 |
|
27 |
| -To install the aks-preview extension, run the following command: |
| 29 | +1. Install the `aks-preview` extension using the [`az extension add`][az-extension-add] command. |
28 | 30 |
|
29 |
| -```azurecli |
30 |
| -az extension add --name aks-preview |
31 |
| -``` |
| 31 | + ```azurecli-interactive |
| 32 | + az extension add --name aks-preview |
| 33 | + ``` |
32 | 34 |
|
33 |
| -Run the following command to update to the latest version of the extension released: |
| 35 | +2. Update to the latest version of the `aks-preview` extension using the [`az extension update`][az-extension-update] command. |
34 | 36 |
|
35 |
| -```azurecli |
36 |
| -az extension update --name aks-preview |
37 |
| -``` |
| 37 | + ```azurecli-interactive |
| 38 | + az extension update --name aks-preview |
| 39 | + ``` |
38 | 40 |
|
39 |
| -## Register the 'AKS-KedaPreview' feature flag |
| 41 | +### Register the `AKS-KedaPreview` feature flag |
40 | 42 |
|
41 |
| -Register the `AKS-KedaPreview` feature flag by using the [az feature register][az-feature-register] command, as shown in the following example: |
| 43 | +1. Register the `AKS-KedaPreview` feature flag using the [`az feature register`][az-feature-register] command. |
42 | 44 |
|
43 |
| -```azurecli-interactive |
44 |
| -az feature register --namespace "Microsoft.ContainerService" --name "AKS-KedaPreview" |
45 |
| -``` |
| 45 | + ```azurecli-interactive |
| 46 | + az feature register --namespace "Microsoft.ContainerService" --name "AKS-KedaPreview" |
| 47 | + ``` |
46 | 48 |
|
47 |
| -It takes a few minutes for the status to show *Registered*. Verify the registration status by using the [az feature show][az-feature-show] command: |
| 49 | + It takes a few minutes for the status to show *Registered*. |
48 | 50 |
|
49 |
| -```azurecli-interactive |
50 |
| -az feature show --namespace "Microsoft.ContainerService" --name "AKS-KedaPreview" |
51 |
| -``` |
| 51 | +2. Verify the registration status using the [`az feature show`][az-feature-show] command. |
52 | 52 |
|
53 |
| -When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider by using the [az provider register][az-provider-register] command: |
| 53 | + ```azurecli-interactive |
| 54 | + az feature show --namespace "Microsoft.ContainerService" --name "AKS-KedaPreview" |
| 55 | + ``` |
54 | 56 |
|
55 |
| -```azurecli-interactive |
56 |
| -az provider register --namespace Microsoft.ContainerService |
57 |
| -``` |
| 57 | +3. When the status reflects *Registered*, refresh the registration of the *Microsoft.ContainerService* resource provider using the [`az provider register`][az-provider-register] command. |
58 | 58 |
|
59 |
| -## Install the KEDA add-on with Azure CLI |
60 |
| -To install the KEDA add-on, use `--enable-keda` when creating or updating a cluster. |
| 59 | + ```azurecli-interactive |
| 60 | + az provider register --namespace Microsoft.ContainerService |
| 61 | + ``` |
61 | 62 |
|
62 |
| -The following example creates a *myResourceGroup* resource group. Then it creates a *myAKSCluster* cluster with the KEDA add-on. |
| 63 | +## Enable the KEDA add-on on your AKS cluster |
63 | 64 |
|
64 |
| -```azurecli-interactive |
65 |
| -az group create --name myResourceGroup --location eastus |
| 65 | +> [!NOTE] |
| 66 | +> While KEDA provides various customization options, the KEDA add-on currently provides basic common configuration. |
| 67 | +> |
| 68 | +> 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**. |
66 | 69 |
|
67 |
| -az aks create \ |
68 |
| - --resource-group myResourceGroup \ |
69 |
| - --name myAKSCluster \ |
70 |
| - --enable-keda |
71 |
| -``` |
| 70 | +### Create a new AKS cluster with KEDA add-on enabled |
72 | 71 |
|
73 |
| -For existing clusters, use `az aks update` with `--enable-keda` option. The following code shows an example. |
| 72 | +1. Create a resource group using the [`az group create`][az-group-create] command. |
74 | 73 |
|
75 |
| -```azurecli-interactive |
76 |
| -az aks update \ |
77 |
| - --resource-group myResourceGroup \ |
78 |
| - --name myAKSCluster \ |
79 |
| - --enable-keda |
80 |
| -``` |
| 74 | + ```azurecli-interactive |
| 75 | + az group create --name myResourceGroup --location eastus |
| 76 | + ``` |
| 77 | +
|
| 78 | +2. Create a new AKS cluster using the [`az aks create`][az-aks-create] command and enable the KEDA add-on using the `--enable-keda` flag. |
| 79 | +
|
| 80 | + ```azurecli-interactive |
| 81 | + az aks create \ |
| 82 | + --resource-group myResourceGroup \ |
| 83 | + --name myAKSCluster \ |
| 84 | + --enable-keda |
| 85 | + ``` |
| 86 | +
|
| 87 | +### Enable the KEDA add-on on an existing AKS cluster |
| 88 | +
|
| 89 | +- Update an existing cluster using the [`az aks update`][az-aks-update] command and enable the KEDA add-on using the `--enable-keda` flag. |
| 90 | +
|
| 91 | + ```azurecli-interactive |
| 92 | + az aks update \ |
| 93 | + --resource-group myResourceGroup \ |
| 94 | + --name myAKSCluster \ |
| 95 | + --enable-keda |
| 96 | + ``` |
81 | 97 |
|
82 | 98 | ## Get the credentials for your cluster
|
83 | 99 |
|
84 |
| -Get the credentials for your AKS cluster by using the `az aks get-credentials` command. The following example command gets the credentials for *myAKSCluster* in the *myResourceGroup* resource group: |
85 |
| - |
86 |
| -```azurecli-interactive |
87 |
| -az aks get-credentials --resource-group myResourceGroup --name myAKSCluster |
88 |
| -``` |
89 |
| - |
90 |
| -## Verify that the KEDA add-on is installed on your cluster |
91 |
| - |
92 |
| -To see if the KEDA add-on is installed on your cluster, verify that the `enabled` value is `true` for `keda` under `workloadAutoScalerProfile`. |
93 |
| - |
94 |
| -The following example shows the status of the KEDA add-on for *myAKSCluster* in *myResourceGroup*: |
95 |
| - |
96 |
| -```azurecli-interactive |
97 |
| -az aks show -g "myResourceGroup" --name myAKSCluster --query "workloadAutoScalerProfile.keda.enabled" |
98 |
| -``` |
99 |
| -## Verify that KEDA is running on your cluster |
100 |
| - |
101 |
| -You can verify KEDA that's running on your cluster. Use `kubectl` to display the operator and metrics server installed in the AKS cluster under kube-system namespace. For example: |
102 |
| - |
103 |
| -```azurecli-interactive |
104 |
| -kubectl get pods -n kube-system |
105 |
| -``` |
106 |
| - |
107 |
| -The following example output shows that the KEDA operator and metrics API server are installed in the AKS cluster along with its status. |
108 |
| - |
109 |
| -```output |
110 |
| -kubectl get pods -n kube-system |
111 |
| -
|
112 |
| -keda-operator-********-k5rfv 1/1 Running 0 43m |
113 |
| -keda-operator-metrics-apiserver-*******-sj857 1/1 Running 0 43m |
114 |
| -``` |
115 |
| -To verify the version of your KEDA, use `kubectl get crd/scaledobjects.keda.sh -o yaml `. For example: |
116 |
| - |
117 |
| -```azurecli-interactive |
118 |
| -kubectl get crd/scaledobjects.keda.sh -o yaml |
119 |
| -``` |
120 |
| -The following example output shows the configuration of KEDA in the `app.kubernetes.io/version` label: |
121 |
| - |
122 |
| -```yaml |
123 |
| -kind: CustomResourceDefinition |
124 |
| -metadata: |
125 |
| - annotations: |
126 |
| - controller-gen.kubebuilder.io/version: v0.8.0 |
127 |
| - creationTimestamp: "2022-06-08T10:31:06Z" |
128 |
| - generation: 1 |
129 |
| - labels: |
130 |
| - addonmanager.kubernetes.io/mode: Reconcile |
131 |
| - app.kubernetes.io/component: operator |
132 |
| - app.kubernetes.io/name: keda-operator |
133 |
| - app.kubernetes.io/part-of: keda-operator |
134 |
| - app.kubernetes.io/version: 2.7.0 |
135 |
| - name: scaledobjects.keda.sh |
136 |
| - resourceVersion: "2899" |
137 |
| - uid: 85b8dec7-c3da-4059-8031-5954dc888a0b |
138 |
| -spec: |
139 |
| - conversion: |
140 |
| - strategy: None |
141 |
| - group: keda.sh |
142 |
| - names: |
143 |
| - kind: ScaledObject |
144 |
| - listKind: ScaledObjectList |
145 |
| - plural: scaledobjects |
146 |
| - shortNames: |
147 |
| - - so |
148 |
| - singular: scaledobject |
149 |
| - scope: Namespaced |
150 |
| - # Redacted for simplicity |
151 |
| - ``` |
152 |
| - |
153 |
| -While KEDA provides various customization options, the KEDA add-on currently provides basic common configuration. |
154 |
| - |
155 |
| -If you have requirement to run with another custom configurations, such as namespaces that should be watched or tweaking the log level, then you may edit the KEDA YAML manually and deploy it. |
156 |
| - |
157 |
| -However, when the installation is customized there will no support offered for custom configurations. |
158 |
| - |
159 |
| -## Disable KEDA add-on from your AKS cluster |
160 |
| - |
161 |
| -When you no longer need KEDA add-on in the cluster, use the `az aks update` command with--disable-keda option. This execution will disable KEDA workload auto-scaler. |
162 |
| - |
163 |
| -```azurecli-interactive |
164 |
| -az aks update \ |
165 |
| - --resource-group myResourceGroup \ |
166 |
| - --name myAKSCluster \ |
167 |
| - --disable-keda |
168 |
| -``` |
| 100 | +- Get the credentials for your AKS cluster using the [`az aks get-credentials`][az-aks-get-credentials] command. |
| 101 | +
|
| 102 | + ```azurecli-interactive |
| 103 | + az aks get-credentials --resource-group myResourceGroup --name myAKSCluster |
| 104 | + ``` |
| 105 | +
|
| 106 | +## Verify the KEDA add-on is installed on your cluster |
| 107 | +
|
| 108 | +- Verify the KEDA add-on is installed on your cluster using the [`az aks show`][az-aks-show] command and set the `--query` parameter to `workloadAutoScalerProfile.keda.enabled`. |
| 109 | +
|
| 110 | + ```azurecli-interactive |
| 111 | + az aks show -g myResourceGroup --name myAKSCluster --query "workloadAutoScalerProfile.keda.enabled" |
| 112 | + ``` |
| 113 | +
|
| 114 | + The following example output shows the KEDA add-on is installed on the cluster: |
| 115 | +
|
| 116 | + ```output |
| 117 | + true |
| 118 | + ``` |
| 119 | +
|
| 120 | +## Verify KEDA is running on your cluster |
| 121 | +
|
| 122 | +- Verify the KEDA add-on is running on your cluster using the [`kubectl get pods`][kubectl] command. |
| 123 | +
|
| 124 | + ```azurecli-interactive |
| 125 | + kubectl get pods -n kube-system |
| 126 | + ``` |
| 127 | +
|
| 128 | + The following example output shows the KEDA operator and metrics API server are installed on the cluster: |
| 129 | +
|
| 130 | + ```output |
| 131 | + keda-operator-********-k5rfv 1/1 Running 0 43m |
| 132 | + keda-operator-metrics-apiserver-*******-sj857 1/1 Running 0 43m |
| 133 | + ``` |
| 134 | +
|
| 135 | +## Verify the KEDA version on your cluster |
| 136 | +
|
| 137 | +- Verify the KEDA version using the `kubectl get crd/scaledobjects.keda.sh -o yaml` command. |
| 138 | +
|
| 139 | + ```azurecli-interactive |
| 140 | + kubectl get crd/scaledobjects.keda.sh -o yaml |
| 141 | + ``` |
| 142 | +
|
| 143 | + The following condensed example output shows the configuration of KEDA in the `app.kubernetes.io/version` label: |
| 144 | +
|
| 145 | + ```output |
| 146 | + apiVersion: apiextensions.k8s.io/v1 |
| 147 | + kind: CustomResourceDefinition |
| 148 | + metadata: |
| 149 | + annotations: |
| 150 | + controller-gen.kubebuilder.io/version: v0.9.0 |
| 151 | + meta.helm.sh/release-name: aks-managed-keda |
| 152 | + meta.helm.sh/release-namespace: kube-system |
| 153 | + creationTimestamp: "2023-09-26T10:31:06Z" |
| 154 | + generation: 1 |
| 155 | + labels: |
| 156 | + app.kubernetes.io/component: operator |
| 157 | + app.kubernetes.io/managed-by: Helm |
| 158 | + app.kubernetes.io/name: keda-operator |
| 159 | + app.kubernetes.io/part-of: keda-operator |
| 160 | + app.kubernetes.io/version: 2.10.1 |
| 161 | + ... |
| 162 | + ``` |
| 163 | +
|
| 164 | +## Disable the KEDA add-on on your AKS cluster |
| 165 | +
|
| 166 | +- Disable the KEDA add-on on your cluster using the [`az aks update`][az-aks-update] command with the `--disable-keda` flag. |
| 167 | +
|
| 168 | + ```azurecli-interactive |
| 169 | + az aks update \ |
| 170 | + --resource-group myResourceGroup \ |
| 171 | + --name myAKSCluster \ |
| 172 | + --disable-keda |
| 173 | + ``` |
169 | 174 |
|
170 | 175 | ## Next steps
|
171 |
| -This article showed you how to install the KEDA add-on on an AKS cluster using Azure CLI. The steps to verify that KEDA add-on is installed and running are included. With the KEDA add-on installed on your cluster, you can [deploy a sample application][keda-sample] to start scaling apps. |
172 | 176 |
|
173 |
| -You can troubleshoot KEDA add-on problems in [this article][keda-troubleshoot]. |
| 177 | +This article showed you how to install the KEDA add-on on an AKS cluster using the Azure CLI. |
| 178 | +
|
| 179 | +With the KEDA add-on installed on your cluster, you can [deploy a sample application][keda-sample] to start scaling apps. |
| 180 | +
|
| 181 | +For information on KEDA troubleshooting, see [Troubleshoot the Kubernetes Event-driven Autoscaling (KEDA) add-on][keda-troubleshoot]. |
174 | 182 |
|
175 | 183 | <!-- LINKS - internal -->
|
176 | 184 | [az-provider-register]: /cli/azure/provider#az-provider-register
|
177 | 185 | [az-feature-register]: /cli/azure/feature#az-feature-register
|
178 | 186 | [az-feature-show]: /cli/azure/feature#az-feature-show
|
179 | 187 | [az-aks-create]: /cli/azure/aks#az-aks-create
|
180 |
| -[az aks install-cli]: /cli/azure/aks#az-aks-install-cli |
181 |
| -[az aks get-credentials]: /cli/azure/aks#az-aks-get-credentials |
182 |
| -[az aks update]: /cli/azure/aks#az-aks-update |
183 |
| -[az-group-delete]: /cli/azure/group#az-group-delete |
184 | 188 | [keda-troubleshoot]: /troubleshoot/azure/azure-kubernetes/troubleshoot-kubernetes-event-driven-autoscaling-add-on?context=/azure/aks/context/aks-context
|
185 | 189 | [aks-firewall-requirements]: outbound-rules-control-egress.md#azure-global-required-network-rules
|
186 |
| - |
| 190 | +[az-aks-update]: /cli/azure/aks#az-aks-update |
| 191 | +[az-aks-get-credentials]: /cli/azure/aks#az-aks-get-credentials |
| 192 | +[az-aks-show]: /cli/azure/aks#az-aks-show |
| 193 | +[az-group-create]: /cli/azure/group#az-group-create |
| 194 | +[az-extension-add]: /cli/azure/extension#az-extension-add |
| 195 | +[az-extension-update]: /cli/azure/extension#az-extension-update |
| 196 | +
|
| 197 | +<!-- LINKS - external --> |
187 | 198 | [kubectl]: https://kubernetes.io/docs/user-guide/kubectl
|
188 |
| -[keda]: https://keda.sh/ |
189 |
| -[keda-scalers]: https://keda.sh/docs/scalers/ |
190 | 199 | [keda-sample]: https://github.com/kedacore/sample-dotnet-worker-servicebus-queue
|
0 commit comments