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:
- 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
Configure 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
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
- [Solved] The connection to the server localhost:8080 was refused – did you specify the right host or port?
- [Solved] Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)
- How To Setup A Three Node Kubernetes Cluster For CKA: Step By Step
- Certified Kubernetes Administrator (CKA): Step-by-Step Activity Guide (Hands-on Lab)
- CKA Certification Exam (Certified Kubernetes Administrator)
- Kubernetes for Beginners – A Complete Beginners Guide
- Kubernetes Dashboard: An Overview, Installation, and Accessing
- CKA/CKAD Exam Questions & Answers 2022
- Docker Container Lifecycle Management: Create, Run, Pause, Stop And Delete
- CKA vs CKAD vs CKS – Differences & Which Exam is Best For You?
- Etcd Backup And Restore In Kubernetes: Step By Step
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 Kubernetes, Job 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.
The post [Fix] ‘Unable to connect to the server: dial tcp: lookup *.eks.amazonaws.com’ Error on kubectl appeared first on Cloud Training Program.