Unable to connect to the server: dial tcp: lookup <Server Location>: no such host

Carson picture Carson · Aug 27, 2020 · Viewed 7.6k times · Source

I'm beginning to build out a kubernetes cluster for our applications. We are using Azure for cloud services, so my K8s cluster is built using AKS. The AKs cluster was created using the portal interface for Azure. It has one node, and I am attempting to create a pod with a single container to deploy to the node. Where I am stuck currently is trying to connect to the AKS cluster from Powershell. The steps I have taken are:

az login (followed by logging in)
az account set --subscription <subscription id>
az aks get-credentials --name <cluster name> --resource-group <resource group name>
kubectl get nodes

After entering the last line, I am left with the error: Unable to connect to the server: dial tcp: lookup : no such host

I've also gone down a few other rabbit holes found on SO and other forums, but quite honestly, I'm looking for a straight forward way to access my cluster before complicating it further.

Edit: So in the end, I deleted the resource I was working with and spun up a new version of AKS, and am now having no trouble connecting. Thanks for the suggestions though!

Answer

Gaurav Gupta picture Gaurav Gupta · Sep 25, 2020

Unable to connect to the server: dial tcp: lookup : no such host

The error is coming because of private cluster. The Private Cluster option is enabled while creating the AKS cluster. You need to disable this option.

Kubectl is a kubernetes control client. It is an external connectivity provider to connect with our kubernetes cluster. We can't connect with the private cluster externally.

Believe me.... just disable the private cluster options And see your success. Thank you.

Note: We can't disable this option after the cluster creation. you need to delete the cluster and again reform it.