Problem scenario
kubectl commands are failing with an error message like this: "Unable to connect to the server: dial tcp: lookup ABCD123EFG.gr7.us-west-1.eks.amazonaws.com on x.x.x.x:53: no such host"
How do you get kubectl commands to work?
Possible Solution #1
If you are using EKS and you have the name of the cluster (e.g., "foobar"), run a command like this:
aws eks update-kubeconfig --name foobar
Possible Solution #2
- Find what VPC your EC-2 instance is in. Remember the x.x.x.x IP address in the error message above. Now look at the relevant VPC. One way to find the relevant VPC would be to use the AWS CLI (link to this posting). Then run this command: aws ec2 describe-vpcs Look at the output. Find the VpcId value for the x.x.x.x IP address.
- In the web UI, go here (but replace "west-1" with the region seen in the error):
https://us-west-1.console.aws.amazon.com/vpc/home?region=us-west-1#vpcs:
- Click on the VPC that was determined in step #1.
- Make sure DNS resolution and DNS hostnames are enabled. These are two separate features of a VPC.
Possible Solution #3
Try redeploying the Kubernetes cluster. The cluster itself may have issues. If you want explicit directions on creating an EKS cluster, see these postings:
https://www.continualintegration.com/miscellaneous-articles/how-do-you-use-amazon-elastic-kubernetes-service-with-the-cli/
https://www.continualintegration.com/miscellaneous-articles/how-do-you-deploy-a-kubernetes-cluster-to-azure/
https://www.continualintegration.com/miscellaneous-articles/how-do-you-deploy-aks-azures-kubernetes-using-the-gui/
https://www.continualintegration.com/miscellaneous-articles/how-do-you-deploy-a-kubernetes-cluster-in-google-cloud-platform/
I check solution #1, and #2. and All is correct.
But still not sure why I am getting “Unable to connect error.. no such host”
Hopefully someone else who has another solution can post it.
First method worked. Thanks!
solution 1 worked for me
and the new ARN is updated (for my new cluster ) in kube config file. Post that I am able to create the deployment.
Thank you so much for helping !
Regulatory Disclosure
This article was brought to you by a Google LLC employee. This article does not reflect the opinions of Google LLC.