AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Kubelet User Assigned Managed Identity

Open palma21 opened this issue 6 years ago • 26 comments

palma21 avatar Nov 11 '20 07:11 palma21

@Azure/aks-pm issue needs labels

ghost avatar Nov 11 '20 18:11 ghost

Hi @palma21, I'm really waiting for this feature, could you share what is ETA to deliver ? In current state when using control plane BYO User Assigned Managed Identity, there are auto-generated 3 additional identities inside MC_ resource group: kubelet, azurepolicy (if using addon), omsagent (if configured) without any role assignments. It makes me unable to use POD Identity (installed myself from Helm Chart), it causes that kubelet identity does not have authorization to perform action 'Microsoft.Compute/virtualMachineScaleSets/write'.

Is there any other solution than assigning Contributor role to this auto-generated kubelet identity ?

mrowken avatar Jan 29 '21 14:01 mrowken

This will be out in mid-Feb.

miwithro avatar Jan 29 '21 14:01 miwithro

Hi @miwithro , is this feature released? I still see auto-created UAMI without any roles assigned.

SatyKrish avatar Feb 26 '21 19:02 SatyKrish

Hi @miwithro , can you share any documentation about this feature?

SatyKrish avatar Mar 16 '21 07:03 SatyKrish

https://docs.microsoft.com/en-us/azure/aks/use-managed-identity#bring-your-own-control-plane-mi

miwithro avatar Mar 16 '21 18:03 miwithro

This guide does not replace the kubelet identity.

Tried workarounds that failed: I've tried installing the user assigned identity with aad-pod-identity (with helm not addon) and a dummy pod, binding the user assigned identity to the pod. But that does not seem to work for nodes and ACR, it does work for the pod.

Examples:

rg_name=Group-AKS-Lab
msi_name=msi-aks-lab
aks_name=aks-lab
az group create -n ${rg_name}
az identity create -n ${msi_name} -g ${rg_name}
msi_id=$(az identity show -n ${msi_name} -g ${rg_name} -o json --query id | jq -rc)
az aks create -n ${aks_name} -g ${rg_name} --enable-managed-identity --assign-identity ${msi_id}
az aks show -n ${aks_name} -g ${rg_name} -o json --query '{identity: identity, kubelet: identityProfile.kubeletidentity}'

Why we need this: We have a blue/green deploy on cluster level since AKS is so easy to work with along side Argocd and its gitops. If we need to do a cluster change, upgrade a ingress, cert-manager or any other major cluster breaking changes we do that in a new cluster. In order to preserve the RBAC for the cluster as well as enable aad-pod-identity we would like to use a user assigned identity for the kubelet, since this will have access to our teams ACR and MI.

tehho avatar Mar 17 '21 07:03 tehho

microsoft.ContainerService/CustomKubeletIdentityPreview? :crossed_fingers: Datamining with az cli

az feature list -o json --query '[].name' | grep ContainerService | grep ubelet

tehho avatar Mar 29 '21 11:03 tehho

I registered but haven't figured out how to use it yet:-)

jabbera avatar Apr 01 '21 14:04 jabbera

@norshtein

miwithro avatar Apr 01 '21 21:04 miwithro

Hi! Any documentation on how to use this? I really don't know how it can be called in public preview without any documentation:-)

jabbera avatar Apr 06 '21 19:04 jabbera

Sorry to badger. Any documentation on this?

jabbera avatar Apr 15 '21 11:04 jabbera

@jabbera not yet. As soon as it posted I will paste it here. Any day now.

miwithro avatar Apr 15 '21 11:04 miwithro

Thank you for the update @miwithro this feature will make our dev and prod environments much easier to manage. Cheers!

justin-chizer avatar Apr 16 '21 19:04 justin-chizer

Custom kubelet identity documentation is available here. https://docs.microsoft.com/en-us/azure/aks/use-managed-identity#bring-your-own-kubelet-mi-preview

@miwithro , as per documentation custom kubelet identity is supported for brand new aks cluster. But there is no support for updating existing cluster to use custom kubelet identity.

az aks update -g MyResourceGroup -n MyManagedCluster --enable-managed-identity --assign-identity <user_assigned_identity_resource_id>

It will be good to have --assign-kubelet-identity argument for updating cluster. Without this, we are forced to build new clusters on all our environments.

SatyKrish avatar Apr 30 '21 04:04 SatyKrish

@miwithro can the arm template be used to set this as well? If so how?

jabbera avatar May 12 '21 03:05 jabbera

@miwithro can the arm template be used to set this as well? If so how?

You can set kubelet identity at identityProfile under managedCluster properties.

"identityProfile": {
                    "kubeletidentity": {
                      "resourceId": "[parameters('kubeletUami').resourceID]",
                      "clientId": "[parameters('kubeletUami').clientID]",
                      "objectId": "[parameters('kubeletUami').objectID]"
                    }
                }

SatyKrish avatar May 12 '21 06:05 SatyKrish

This only works for new clusters. This is not designed for upgrading existing clusters.

miwithro avatar May 12 '21 13:05 miwithro

@SatyKrish this works but you also need to assign the "Managed Identity Operator" role on the kublet identity to the cluster identity.

jabbera avatar May 12 '21 14:05 jabbera

@miwithro yup! I just blew away the cluster and recreated it. I used the setting from @SatyKrish and combining that with assign "Managed Identity Operator" to the cluster identity all seems to work as expected.

jabbera avatar May 12 '21 14:05 jabbera