Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 979
Carson Avatar asked Aug 27 '20 18:08

Carson


People also ask

What is hcp Westeurope azmk8s io?

hcp.westeurope.azmk8s.io) — this is the dns that is running your api server(HTTPS:443, UDP: 1194) mcr.microsoft.com , *. data.mcr.microsoft.com — This is required since some AKS images are coming from the Microsoft Container Registry (HTTPS: 443)

How do I check my connection in Kubernetes pod?

To find the cluster IP address of a Kubernetes pod, use the kubectl get pod command on your local machine, with the option -o wide . This option will list more information, including the node the pod resides on, and the pod's cluster IP. The IP column will contain the internal cluster IP address for each pod.


1 Answers

As of now, the aks run command adds a fourth option to connect to private clusters extending @Darius's three options posted earlier:

  1. Use the AKS Run Command feature.
az aks command invoke -g <resourceGroup> -n <clusterName> -c "kubectl get pods -n kube-system"
az aks command invoke -g <resourceGroup> -n <clusterName> -c "kubectl get nodes"

In case you get a (ResourceGroupNotFound) error, try adding the subscription, too

az aks command invoke -g <resourceGroup> -n <clusterName> --subscription <subscription> -c "kubectl get nodes"

You can also configure the default subscription:

az account set -s <subscription>
like image 156
Carambakaracho Avatar answered Sep 16 '22 12:09

Carambakaracho