I need to grant a process (build pipeline) RBAC access to AKS API for deployment purposes. But the target AKS cluster has AAD integration active (as described here)
I was expecting to be able to access the AKS API's with a simple Service Principal, but I'm redirected to a devicelogin page:
$ az login --service-principal --username [REDACTED]-XXXX-XXXX-XXXX-XXXXXXXXXXXX --password [REDACTED]XXxxXXxxXXxxxXXXxxXXxxXXxx= --tenant [REDACTED]-XXXX-XXXX-XXXX-XXXXXXXXXXXX
$ az aks get-credentials -n oli-aksdemo01 -g oli-aksdemo01
Merged "oli-aksdemo01" as current context in /home/olivier/.kube/config
$ kubectl get nodes
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code C2NP77EGR to authenticate.
:-(
Is there a way to avoid the devicelogin page when authenticating a Service Principal on an AAD-integrated AKS cluster on Azure ?
For anyone out there who still needs this.
I solved the same issue for my Jenkins pipeline. All you have to do is create a service principal with the cluster scope or subscription.
you should be fine.
Unlike @Festus Fashola's answer, which works simply because it's using the
--admin
flag in the command which bypasses AAD verification (not what the OP was asking), the correct way of doing this now is using KubeLogin, which allows service principal non-interactive authentication: https://github.com/Azure/kubelogin#service-principal-login-flow-non-interactiveUsage example:
TL;DR : It is not possible, yet.
I asked the very same question to Azure support and here is their answer: