kubelogin is a client-go credential (exec) plugin implementing azure authentication. This plugin provides features that are not available in kubectl. It is supported on kubectl v1.11+ and you can bypass interactive authentication with it. This means that you do not have to enter a device code login when interacting with AKS.
I had to use the tool for managed identity authentication with Kubernetes service. In the documentation you can find instructions on how to use it for cases like user login, service principal, managed identity.
Although I was following the correct instructions I was struggling with the error shown below when I was executing kubectl commands.
This error was due to the fact that I was not requesting the admin credentials on the kubectl command.
When I was asking for credentials with the below command I ended up with the error.
az aks get-credentials--resource-group rg --name clustername
As I had assigned the Kubernetes admin Cluster role on my managed identity I was able to execute kubectl commands when using.
az aks get-credentials --admin --resource-group rg --name clustername