You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/essentials/integrating-keda.md
+217-6Lines changed: 217 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,13 +15,224 @@ Install KEDA
15
15
Configure sacler
16
16
17
17
18
-
To integrate KEDA with Azure Monitor, you need to Deploy and configure workload identity on your AKS cluster. This allows KEDA to authenticate with you Azure Monitor workspace and retrieve metrics for scaling.
18
+
To integrate KEDA with Azure Monitor, you need to Deploy and configure workload identity or pod identity on your AKS cluster. This allows KEDA to authenticate with you Azure Monitor workspace and retrieve metrics for scaling.
19
19
20
+
This article will walk you through the steps to integrate KEDA with Azure Monitor using workload identity.
20
21
21
-
export RESOURCE_GROUP="rg-ed-kedatest-01"
22
+
## Set up a workload identity
23
+
24
+
1. Start by setting up some environment variables. Change the values to suit your AKS cluster.Do not change these values for `SERVICE_ACCOUNT_NAMESPACE` and `SERVICE_ACCOUNT_NAME`. They are the namespace and name of the kubernetes service account that KEDA will use to authenticate with Azure Monitor.
25
+
26
+
`USER_ASSIGNED_IDENTITY_NAME` is the name of the Azure Active directory identity that will be created for KEDA.
27
+
`FEDERATED_IDENTITY_CREDENTIAL_NAME` is the name of the credential that will be created for KEDA to use to authenticate with Azure.
1. If your AKS cluster has not been created with workload-identity or oidc-issuer enabled, you will need to enable it. If you are not sure, you can run the following command to check if it is enabled.
40
+
41
+
```azurecli
42
+
az aks show --resource-group $RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query oidcIssuerProfile
43
+
az aks show --resource-group $RESOURCE_GROUP --name $AKS_CLUSTER_NAME --query securityProfile.workloadIdentity
44
+
```
45
+
46
+
To enable workload identity and oidc-issuer , run the following command.
47
+
48
+
```azurecli
49
+
az aks update -g $RESOURCE_GROUP -n $AKS_CLUSTER_NAME --enable-managed-identity --enable-oidc-issuer
50
+
```
51
+
52
+
1. Store the OIDC issuer url in an environment variable. This will be used later.
53
+
54
+
```bash
55
+
export AKS_OIDC_ISSUER="$(az aks show -n $CLUSTER_NAME -g $RESOURCE_GROUP --query "oidcIssuerProfile.issuerUrl" -otsv)"
56
+
```
57
+
58
+
1. Create a user assigned identity for KEDA. This identity will be used by KEDA to authenticate with Azure Monitor.
1. Assign the *Monitoring Data Reader* role user to identity for your Azure Monitor workspace. This will allow KEDA to read metrics from you workspace.
kubectl describe serviceaccount workload-identity-sa -n keda
117
+
```
118
+
119
+
1. Establish the federated identity between the service account and the user assigned identity. This will allow the service account to use the user assigned identity to authenticate with Azure.
KEDA can be deployed using YAML manifests or Helm charts. This article will use Helm charts. For more information on deploying KEDA, see [Deploying KEDA](https://keda.sh/docs/2.10/deploy/)
129
+
130
+
1. Deply KEDA using the following command.
131
+
132
+
133
+
```bash
134
+
helm install keda kedacore/keda --namespace keda \
Scalers define how and when KEDA should scale a deployment. KEDA supports a variety of scalers. For more information on scalers, see [Scalers](https://keda.sh/docs/2.10/scalers/prometheus/)
156
+
157
+
The following yaml file defines a scaler.
158
+
159
+
The `serverAddress` is the Query endpoint of your Azure Monitor workspace. `metricName` is the name of the metric you want to scale on. The `query` is the query used to retrieve the metric. The `threshold` is the value at which the deployment will scale. Set thee `podIdentity.provider` according to the type of identity you are using.
160
+
161
+
```yml
162
+
apiVersion: keda.sh/v1alpha1
163
+
kind: TriggerAuthentication
164
+
metadata:
165
+
name: azure-managed-prometheus-trigger-auth
166
+
spec:
167
+
podIdentity:
168
+
: azure-workload | azure # use "azure" for pod identity and "azure-workload" for workload identity
169
+
identityId: <identity-id> # Optional. Default: Identity linked with the label set when installing KEDA.
Check the values used to create the ServiceAccount and the credentials created with `az identity federated-credential create` and ensure the `subject` value matches the `system:serviceaccount` value.
218
+
219
+
### Azure Monitor workspace persmissions
220
+
221
+
If you are having issues with KEDA authenticating with Azure, check the permissions for the Azure Monitor workspace.
222
+
The following log excerpt shows that the identity does not have read permissions for the Azure Monitor workspace.
223
+
224
+
```bash
225
+
kubectl logs -n keda keda-operator-5d9f7d975-mgv7r
226
+
227
+
2023-05-30T11:15:45Z ERROR scale_handler error getting metric for scaler
0 commit comments