About Me

My photo
I am an MCSE in Data Management and Analytics, specializing in MS SQL Server, and an MCP in Azure. With over 19+ years of experience in the IT industry, I bring expertise in data management, Azure Cloud, Data Center Migration, Infrastructure Architecture planning, as well as Virtualization and automation. I have a deep passion for driving innovation through infrastructure automation, particularly using Terraform for efficient provisioning. If you're looking for guidance on automating your infrastructure or have questions about Azure, SQL Server, or cloud migration, feel free to reach out. I often write to capture my own experiences and insights for future reference, but I hope that sharing these experiences through my blog will help others on their journey as well. Thank you for reading!

Unable to connect to the server: getting credentials: exec: executable kubelogin not found

Issue:- Unable to connect to the server: getting credentials: exec: executable kubelogin not found

C:\Users\kusha>kubectl get deployments --all-namespaces=true

Unable to connect to the server: getting credentials: exec: executable kubelogin not found


It looks like you are trying to use a client-go credential plugin that is not installed.


To learn more about this feature, consult the documentation available at:

      https://kubernetes.io/docs/reference/access-authn-authz/authentication/#client-go-credential-plugins

Resolution:- run az aks install-cli from command prompt using local Administrator


C:\Users\kusha>az aks install-cli

The detected architecture is 'amd64', which will be regarded as 'amd64' and the corresponding binary will be downloaded. If there is any problem, please download the appropriate binary by yourself.

Downloading client to "C:\Users\kusha\.azure-kubectl\kubectl.exe" from "https://storage.googleapis.com/kubernetes-release/release/v1.26.1/bin/windows/amd64/kubectl.exe"

The installation directory "C:\Users\kusha\.azure-kubectl" has been successfully appended to the user path, the configuration will only take effect in the new command sessions. Please re-open the command window.

Downloading client to "C:\Users\kusha\AppData\Local\Temp\tmp7oi643ok\kubelogin.zip" from "https://github.com/Azure/kubelogin/releases/download/v0.0.26/kubelogin.zip"

The installation directory "C:\Users\kusha\.azure-kubelogin" has been successfully appended to the user path, the configuration will only take effect in the new command sessions. Please re-open the command window.


C:\Users\kusha>


C:\Windows\System32>az logout


C:\Windows\System32>az login


C:\Windows\System32>az account set --subscription 69b34dfc-4b97-XXXX-93f3-037ed7eec25e


C:\Windows\System32>az aks get-credentials --resource-group rakResourceGroup --name myAKSCluster

Merged "myAKSCluster" as current context in C:\Users\kusha\.kube\config


C:\Windows\System32>kubectl get deployments --all-namespaces=true

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code DGPGMEDE4 to authenticate.

NAMESPACE         NAME                      READY   UP-TO-DATE   AVAILABLE   AGE

calico-system     calico-kube-controllers   1/1     1            1           171m

calico-system     calico-typha              1/1     1            1           171m

kube-system       coredns                   2/2     2            2           173m

kube-system       coredns-autoscaler        1/1     1            1           173m

kube-system       konnectivity-agent        2/2     2            2           173m

kube-system       metrics-server            2/2     2            2           173m

tigera-operator   tigera-operator           1/1     1            1           173m


C:\Windows\System32>

Explanation:-

When you run az aks get-credentials, it uses the Azure CLI to retrieve the cluster credentials and then saves them to your local machine. This method may use a different authentication method that does not require kubelogin.


However, when you try to use kubelogin, it expects to be able to authenticate to the cluster using the Kubernetes API server. If kubelogin is not installed or not properly configured, you may see the error message mentioned.

To use kubelogin, you will need to ensure that it is properly installed and configured. You can check whether kubelogin is installed by running the command which kubelogin in your terminal. If kubelogin is not installed, you can download and install it by following the instructions in the documentation: https://github.com/Azure/kubelogin

Once kubelogin is properly installed, you may need to configure it to use the correct authentication method for your cluster. You can find more information on how to configure kubelogin in the documentation as well.

No comments: