I have installed the kubectl binary with curl and kubelogin with snap.
I am unable to connect to Azure Kubernetes Service (AKS) cluster recently with kubectl. I have seen that the connection steps were extended with and using the kubelogin plugin after getting the AKS credentials:
az login
az account set --subscription <subscription_id>
az aks get-credentials --resource-group <resource_group> --name <cluster_name> --overwrite-existing
kubelogin convert-kubeconfig -l azurecli
However, I get a permission denied error on listing the deployments:
Error: failed to get token: initialing the device code authentication: autorest/adal/devicetoken: Error occurred while sending request for Device Authorization Code: Post "https://login.microsoftonline.com/eb70b763-b6d7-4486-8555-8831709a784e/oauth2/devicecode": dial tcp: lookup login.microsoftonline.com on [::1]:53: dial udp [::1]:53: socket: permission denied
As it turned out, the snap version of kubelogin is not working as expected. I had to reinstall the kubelogin alongside with kubectl using the AzureCLI:
sudo az aks install-cli
It installed both binaries, and afterwards you need to sing-in in the browser when executing a command:
$ kubectl get deployments
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code EF4V2BQJY to authenticate.
No resources found in default namespace.
Reference: https://azure.github.io/kubelogin/install.html#using-azure-cli