Skip to content

Commit 3d7c13e

Browse files
authored
Merge pull request #110599 from zr-msft/ds-aad-pod-id-troubleshooting
[Dev Spaces] Added callout for aad-pod-id
2 parents cbae514 + 003930c commit 3d7c13e

File tree

2 files changed

+111
-3
lines changed

2 files changed

+111
-3
lines changed

articles/dev-spaces/faq.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ When using Visual Studio to prepare your project, you have the option of enablin
7474

7575
## Can I use pod managed identities with Azure Dev Spaces?
7676

77-
Currently, Azure Dev Spaces does not support using [pod managed identities][aks-pod-managed-id] on AKS clusters with Azure Dev Spaces enabled. If you have pod managed identities installed and would like to uninstall it, you can find more details in the [uninstall notes][aks-pod-managed-id-uninstall].
77+
Yes, you can use [pod managed identities][aks-pod-managed-id] on AKS clusters with Azure Dev Spaces enabled, but there are [additional configuration steps][dev-spaces-pod-managed-id-steps] after you enable Azure Dev Spaces on your cluster with pod managed identities. If you have pod managed identities installed and would like to uninstall it, you can find more details in the [uninstall notes][aks-pod-managed-id-uninstall].
7878

7979
## Can I use Azure Dev Spaces with multiple microservices in an application?
8080

@@ -93,6 +93,7 @@ In Visual Studio, it is possible to configure .NET Core solutions for debugging
9393
[aks-pod-managed-id-uninstall]: https://github.com/Azure/aad-pod-identity#uninstall-notes
9494
[aks-restrict-egress-traffic]: ../aks/limit-egress-traffic.md
9595
[bike-sharing]: https://github.com/Azure/dev-spaces/tree/master/samples/BikeSharingApp
96+
[dev-spaces-pod-managed-id-steps]: troubleshooting.md#error-no-azureassignedidentity-found-for-podazdsazds-webhook-deployment-id-in-assigned-state
9697
[dev-spaces-prep]: how-dev-spaces-works-prep.md
9798
[dev-spaces-routing]: how-dev-spaces-works-routing.md#how-routing-works
9899
[ingress-nginx]: how-to/ingress-https-nginx.md#configure-a-custom-nginx-ingress-controller

articles/dev-spaces/troubleshooting.md

Lines changed: 109 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ You can also try deleting the controller:
3434
azds remove -g <resource group name> -n <cluster name>
3535
```
3636

37-
Use the Azure Dev Spaces CLI to delete a controller. Its not possible to delete a controller from Visual Studio. You also can't install the Azure Dev Spaces CLI in the Azure Cloud Shell so you can't delete a controller from the Azure Cloud Shell.
37+
Use the Azure Dev Spaces CLI to delete a controller. It's not possible to delete a controller from Visual Studio. You also can't install the Azure Dev Spaces CLI in the Azure Cloud Shell so you can't delete a controller from the Azure Cloud Shell.
3838

3939
If you don't have the Azure Dev Spaces CLI installed, you can first install it using the following command then delete your controller:
4040

@@ -89,7 +89,7 @@ To fix this issue, update your installation of the [Azure CLI](/cli/azure/instal
8989

9090
### Error "Unable to reach kube-apiserver"
9191

92-
You might see this error when Azure Dev Spaces is unable to connect to your AKS cluster's API server.
92+
You might see this error when Azure Dev Spaces is unable to connect to your AKS cluster's API server.
9393

9494
If access to your AKS cluster API server is locked down or if you have [API server authorized IP address ranges](../aks/api-server-authorized-ip-ranges.md) enabled for your AKS cluster, you must also [create](../aks/api-server-authorized-ip-ranges.md#create-an-aks-cluster-with-api-server-authorized-ip-ranges-enabled) or [update](../aks/api-server-authorized-ip-ranges.md#update-a-clusters-api-server-authorized-ip-ranges) your cluster to [allow additional ranges based on your region](https://github.com/Azure/dev-spaces/tree/master/public-ips).
9595

@@ -266,6 +266,113 @@ For example, to stop and disable the *Windows BranchCache* service:
266266
* Optionally, you can disable it by setting *Startup type* to *Disabled*.
267267
* Click *OK*.
268268

269+
### Error "no AzureAssignedIdentity found for pod:azds/azds-webhook-deployment-\<id\> in assigned state"
270+
271+
When running a service with Azure Dev Spaces on an AKS cluster with a [managed identity](../aks/use-managed-identity.md) and [pod managed identities](../aks/developer-best-practices-pod-security.md#use-pod-managed-identities) installed, the process may hang after the *chart install* step. If you inspect the *azds-injector-webhook* in the *azds* name space, you may see this error.
272+
273+
The services Azure Dev Spaces runs on your cluster utilize the cluster's managed identity to talk to the Azure Dev Spaces backend services outside the cluster. When the pod managed identity is installed, networking rules are configured on your cluster's nodes to redirect all calls for managed identity credentials to a [Node Managed Identity (NMI) DaemonSet installed on the cluster](https://github.com/Azure/aad-pod-identity#node-managed-identity). This NMI DaemonSet identifies the calling pod and ensures that pod has been labeled appropriately to access the requested managed identity. Azure Dev Spaces can't detect if a cluster has pod managed identity installed and can't perform the necessary configuration to allow Azure Dev Spaces services to access the cluster's managed identity. Since the Azure Dev Spaces services haven't been configured to access the cluster's managed identity, the NMI DaemonSet will not allow them to obtain an AAD token for the managed identity and fail to communicate with Azure Dev Spaces backend services.
274+
275+
To fix this issue, apply an [AzurePodIdentityException](https://github.com/Azure/aad-pod-identity/blob/master/docs/readmes/README.app-exception.md) for the *azds-injector-webhook* and update pods instrumented by Azure Dev Spaces to access the managed identity.
276+
277+
Create a file named *webhookException.yaml* and copy the following YAML definition:
278+
279+
```yaml
280+
apiVersion: "aadpodidentity.k8s.io/v1"
281+
kind: AzurePodIdentityException
282+
metadata:
283+
name: azds-infrastructure-exception
284+
namespace: azds
285+
spec:
286+
PodLabels:
287+
azds.io/uses-cluster-identity: "true"
288+
```
289+
290+
The above file creates a *AzurePodIdentityException* object for the *azds-injector-webhook*. To deploy this object, use `kubectl`:
291+
292+
```cmd
293+
kubectl apply -f webhookException.yaml
294+
```
295+
296+
To update pods instrumented by Azure Dev Spaces to access the managed identity, update the *namespace* in the below YAML definition and use `kubectl` to apply it for each dev space.
297+
298+
```yaml
299+
apiVersion: "aadpodidentity.k8s.io/v1"
300+
kind: AzurePodIdentityException
301+
metadata:
302+
name: azds-infrastructure-exception
303+
namespace: myNamespace
304+
spec:
305+
PodLabels:
306+
azds.io/instrumented: "true"
307+
```
308+
309+
Alternatively, you can create *AzureIdentity* and *AzureIdentityBinding* objects and update the pod labels for workloads running in spaces instrumented by Azure Dev Spaces to access the managed identity created by the AKS cluster.
310+
311+
To list the details of the managed identity, run the following command for your AKS cluster:
312+
313+
```azurecli
314+
az aks show -g <resourcegroup> -n <cluster> -o json --query "{clientId: identityProfile.kubeletidentity.clientId, resourceId: identityProfile.kubeletidentity.resourceId}"
315+
```
316+
317+
The above command outputs the *clientId* and *resourceId* for the managed identity. For example:
318+
319+
```json
320+
{
321+
"clientId": "<clientId>",
322+
"resourceId": "/subscriptions/<subid>/resourcegroups/<resourcegroup>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<name>"
323+
}
324+
```
325+
326+
To create an *AzureIdentity* object, create a file named *clusteridentity.yaml* and use the following YAML definition updated with the details of your managed identity from the previous command:
327+
328+
```yaml
329+
apiVersion: "aadpodidentity.k8s.io/v1"
330+
kind: AzureIdentity
331+
metadata:
332+
name: my-cluster-mi
333+
spec:
334+
type: 0
335+
ResourceID: /subscriptions/<subid>/resourcegroups/<resourcegroup>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<name>
336+
ClientID: <clientId>
337+
```
338+
339+
To create an *AzureIdentityBinding* object, create a file named *clusteridentitybinding.yaml* and use the following YAML definition:
340+
341+
```yaml
342+
apiVersion: "aadpodidentity.k8s.io/v1"
343+
kind: AzureIdentityBinding
344+
metadata:
345+
name: my-cluster-mi-binding
346+
spec:
347+
AzureIdentity: my-cluster-mi
348+
Selector: my-label-value
349+
```
350+
351+
To deploy the *AzureIdentity* and *AzureIdentityBinding* objects, use `kubectl`:
352+
353+
```cmd
354+
kubectl apply -f clusteridentity.yaml
355+
kubectl apply -f clusteridentitybinding.yaml
356+
```
357+
358+
After you deploy the *AzureIdentity* and *AzureIdentityBinding* objects, any workload with the *aadpodidbinding: my-label-value* label can access the cluster's managed identity. Add this label and redeploy all workloads running in any dev space. For example:
359+
360+
```yaml
361+
apiVersion: apps/v1
362+
kind: Deployment
363+
metadata:
364+
name: sample
365+
spec:
366+
replicas: 1
367+
template:
368+
metadata:
369+
labels:
370+
app: sample
371+
aadpodidbinding: my-label-value
372+
spec:
373+
[...]
374+
```
375+
269376
## Common issues using Visual Studio and Visual Studio Code with Azure Dev Spaces
270377

271378
### Error "Required tools and configurations are missing"

0 commit comments

Comments
 (0)