kubectl after device login returns error you must be logged in to the server (Unauthorized)

Viewed 1676

What works on one corporate computer doesn't work on another.

Maybe corporate network proxy or CA cert? Domain whitelisting? How do you debug this?

az login
az account set --subscription <subscription>
az aks get-credentials --resource-group <group name> --name <aks name>
kubectl get nodes

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ... to authenticate. E1201 ... 11576 round_trippers.go:174] CancelRequest not implemented by *azure.azureRoundTripper error: You must be logged in to the server (Unauthorized)

2 Answers

When I wanted to open an Azure support ticket, it alerted that there were failures because of using an old kubectl CLI.

I had a similar issue and found that the version of "Docker for Mac" I was using was overriding the kubectl installation I had done via `homebrew.

❯ which kubectl
/usr/local/bin/kubectl
❯ ls -l /usr/local/bin/kubectl
lrwxr-xr-x  1 root  staff  55 16 Sep  2019 /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl

And when I checked the version of the client, sure enough:

kubectl version --client
Client Version: version.Info{Major:"1", Minor:"14" //snip

This seems to have been resolved quite some time ago, but may save some time for someone in the future

The solutions seem to be:

  1. Upgrade docker for mac (if this is your problem)
  2. Delete the link to the docker for mac provided kubectl and set to a current version
Related