user584018
user584018

Reputation: 11304

Not able to connect to AKS cluster on Ubuntu console but powershell works

In Ubuntu 18.4 console on Windows 10 machine, I have run below command to connects AKS cluster to fetch node information,

az Login

Then fetching cluster credential,

az aks get-credentials --resource-group <resource_group_name> --name <cluster_name>

I can see kube config file C:\Users\XXX\.kube\config is created with the right AKS cluster information also I don't have any local cluster running on my machine.

But when I am trying to get node information for AKS cluster, it's trying to connect localhost:8080

 :/mnt/c/Users/XXX$ kubectl get nodes
 The connection to the server localhost:8080 was refused - did you specify the right 
 host or port?

But the same working from PowerShell console. What settings I am missing for Ubuntu?

Upvotes: 0

Views: 746

Answers (1)

RamaraoAdapa
RamaraoAdapa

Reputation: 3119

I have tested in my environment. The reason for the error is .kube/config file is created in the windows but not in the ubuntu. The .kube/config file needs to be copied to ubuntu.

Please use the below command to copy the config file from your windows machine to ubuntu :

cp /mnt/c/Users/[USERNAME]/.kube/config ~/.kube/config

Use below command to switch to the aks cluster :

kubectl config use-context [cluster-name]

Now, you should be able to get the node information of your cluster using :

kubectl get nodes

Please refer below screenshot :

enter image description here

Upvotes: 1

Related Questions