Reputation: 1055
I have an EKS cluster setup in a VPC. The worker nodes are launched in private subnets. I can successfully deploy pods and services.
However, I'm not able to perform DNS resolution from within the pods. (It works fine on the worker nodes, outside the container.)
Troubleshooting using https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/ results in the following from nslookup (timeout after a minute or so):
Server: 172.20.0.10 Address 1: 172.20.0.10
nslookup: can't resolve 'kubernetes.default'
When I launch the cluster in an all-public VPC, I don't have this problem. Am I missing any necessary steps for DNS resolution from within a private subnet?
Many thanks, Daniel
Upvotes: 33
Views: 45837
Reputation: 1552
In my situation, this occurs in one of our clusters where both "security group for pods" and "prefix mode" are enabled. The issue isn't that DNS resolution fails entirely; rather, it's so slow that most operations time out while waiting for addresses to resolve. Occasionally, it resolves before timing out, but increasing the timeout limit isn't a solution because it is already too high (even 15 seconds isn't sufficient).
I can confirm the issue by removing a security group from a problematic pod and assigning it to a normally functioning pod. Once the normal pod is recycled and the security group is applied, the previously functioning pod begins to exhibit the same problem.
Unable to find a solution, I stopped using security groups and switched to network policies, which only operate with IP addresses, making it cumbersome.
Upvotes: 0
Reputation: 617
I also banged my head on this class of problem for several days.
Specifically my problem was that I could VPN into my private subnet and resolve my management endpoint once. This is to say that on Monday (for example) from the office I could set up my VPN for the first time and use kubectl
to my hearts content, but on Tuesday at home I would be able to connect to the VPN but when I ran any kubectl
interaction I would get whiffed with:
Unable to connect to the server: dial tcp: lookup XXXXX.eks.amazonaws.com on 127.0.0.53:53: read udp 127.0.0.1:39491->127.0.0.53:53: i/o timeout
I think it is working again (but I've yet to see if it works tomorrow from the office); the change I made was to the Client VPN endpoints->Autorization rules
. I added a rule to authorize access to the destination network containing the DNS server (VPC CIDR +2) which I had also called out explicitly as the DNS server for the Client VPN Enpoint itself.
Upvotes: 1
Reputation: 1468
As many others, I've been struggling with this bug a few hours.
In my case the issue was this bug https://github.com/awslabs/amazon-eks-ami/issues/636 that basically sets up an incorrect DNS when you specify endpoint and certificate but not certificate.
To confirm, check
Upvotes: 2
Reputation: 43
I ran into this as well. I have multiple node groups, and each one was created from a CloudFormation template. The CloudFormation template created a security group for each node group that allowed the nodes in that group to communicate with each other.
The DNS error resulted from Pods running in separate node groups from the CoreDNS Pods, so the Pods were unable to reach CoreDNS (network communications were only permitted withing node groups). I will make a new CloudFormation template for the node security group so that all my node groups in my cluster can share the same security group.
I resolved the issue for now by allowing inbound UDP traffic on port 53 for each of my node group security groups.
Upvotes: 3
Reputation: 441
We had run into a similar issue where DNS resolution times out on some of the pods, but re-creating the pod couple of times resolves the problem. Also its not every pod on a given node showing issues, only some pods.
It turned out to be due to a bug in version 1.5.4
of Amazon VPC CNI, more details here -- https://github.com/aws/amazon-vpc-cni-k8s/issues/641.
Quick solution is to revert to the recommended version 1.5.3
- https://docs.aws.amazon.com/eks/latest/userguide/update-cluster.html
Upvotes: 1
Reputation: 59
Re: AWS EKS Kube Cluster and Route53 internal/private Route53 queries from pods
Just wanted to post a note on what we needed to do to resolve our issues. Noting that YMMV and everyone has different environments and resolutions, etc.
Disclaimer: We're using the community terraform eks module to deploy/manage vpcs and the eks clusters. We didn't need to modify any security groups. We are working with multiple clusters, regions, and VPC's.
ref: Terraform EKS module
CoreDNS Changes: We have a DNS relay for private internal, so we needed to modify coredns configmap and add in the dns-relay IP address ...
ec2.internal:53 {
errors
cache 30
forward . 10.1.1.245
}
foo.dev.com:53 {
errors
cache 30
forward . 10.1.1.245
}
foo.stage.com:53 {
errors
cache 30
forward . 10.1.1.245
}
...
VPC DHCP option sets: Update with the IP of the above relay server if applicable--requires regeneration of the option set as they cannot be modified.
Our DHCP options set looks like this:
["AmazonProvidedDNS", "10.1.1.245", "169.254.169.253"]
ref: AWS DHCP Option Sets
Route-53 Updates: Associate every route53 zone with the VPC-ID that you need to associate it with (where our kube cluster resides and the pods will make queries from).
there is also a terraform module for that: https://www.terraform.io/docs/providers/aws/r/route53_zone_association.html
Upvotes: 2
Reputation: 201
To elaborate on the comment from @Daniel, you need:
I hadn't added (2) and was seeing CoreDNS receiving requests and trying to respond, but the response wasn't getting back to the requester.
Some tips for others dealing with these kinds of issues, turn on CoreDNS logging by adding the log
configuration to the configmap, which I was able to do with kubectl edit configmap -n kube-system coredns
. See CoreDNS docs on this https://github.com/coredns/coredns/blob/master/README.md#examples This can help you figure out whether the issue is CoreDNS receiving queries or sending the response back.
Upvotes: 20
Reputation: 409
So I been struggling for a couple of hours i think, lost track of time, with this issue as well.
Since i am using the default VPC but with the worker nodes inside the private subnet, it wasn't working.
I went through the amazon-vpc-cni-k8s and found the solution.
We have to sff the environment variable of the aws-node daemonset AWS_VPC_K8S_CNI_EXTERNALSNAT=true
.
You can either get the new yaml and apply or just fix it through the dashboard. However for it to work you have to restart the worker node instance so the ip route tables are refreshed.
issue link is here
thankz
Upvotes: 1
Reputation: 1330
I feel like I have to give this a proper answer because coming upon this question was the answer to 10 straight hours of debugging for me. As @Daniel said in his comment, the issue I found was with my ACL blocking outbound traffic on UDP port 53 which apparently kubernetes uses to resolve DNS records.
The process was especially confusing for me because one of my pods worked actually worked the entire time since (I think?) it happened to be in the same zone as the kubernetes DNS resolver.
Upvotes: 28