Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1891

[Fix] ‘Unable to connect to the server: dial tcp: lookup *.eks.amazonaws.com’ Error on kubectl

$
0
0

The error message “Unable to connect to the server: dial tcp: lookup *.eks.amazonaws.com on IP:53: no such host” is a common issue encountered when using kubectl, the command-line interface for Kubernetes. This error occurs when kubectl is unable to establish a connection to the Kubernetes API server.

The main cause of this error is a failure to resolve the hostname of the API server. The hostname is typically specified in the kubeconfig file, which is used to configure the connection between kubectl and the API server. In this case, the hostname contains a wildcard, which is causing the DNS resolver to fail to find the correct IP address for the API server.

How to Resolve the Kubectl Command Error

If you are encountering the error “Unable to connect to the server: dial tcp: lookup *.eks.amazonaws.com on IP:53: no such host” while using kubectl with an Amazon EKS cluster, you can follow the steps to resolve the issue:

  1. Backup your existing kubeconfig file: This step is optional, but it’s always a good idea to back up your existing configuration before making any changes. You can run the following command:

mv $HOME/.kube/config $HOME/.kube/config.old

  1. kubectlConfigure kubectl with the EKS API server credentials: To do this, run the following command, replacing [EKS_Region] and [EKS_Cluster_Name] with the appropriate values for your cluster:

aws eks --region [EKS_Region] update-kubeconfig --name [EKS_Cluster_Name]

For example, if your EKS cluster is in the us-east-1 region and the name of your cluster is k21-eks-cluster-cli, you would run the following command:

aws eks --region us-east-1 update-kubeconfig --name k21-eks-cluster-cli

  1. kubectl 1 Test the connection: After updating the kubeconfig file, run the following command to check the connection to the API server:

kubectl get svc

If the connection is successful, you should see a list of services running in your EKS cluster.

In conclusion, if you are encountering the error “Unable to connect to the server: dial tcp: lookup *.eks.amazonaws.com on IP:53: no such host” when using kubectl with an Amazon EKS cluster, you can resolve the issue by configuring kubectl with the correct API server credentials using the aws eks update-kubeconfig command.

Related Post

Join FREE Class

Begin your journey towards becoming a Certified Kubernetes Administrator [CKA]  from our Certified Kubernetes Administrator (CKA) training program. To know about the Roles and Responsibilities of a Kubernetes administrator, why learn Docker and KubernetesJob opportunities for Kubernetes administrator in the market. Also, know about Hands-On labs you must perform to clear the Certified Kubernetes Administrator (CKA) Certification exam by registering for our FREE class.

Docker & Kubernetes Free class

The post [Fix] ‘Unable to connect to the server: dial tcp: lookup *.eks.amazonaws.com’ Error on kubectl appeared first on Cloud Training Program.


Viewing all articles
Browse latest Browse all 1891

Trending Articles