首页 > 解决方案 > EKS 中的 Pod:无法解析 DNS(但可以 ping IP)

问题描述

我有 2 个 EKS 集群,位于 2 个不同的 AWS 账户中,并且我可能假设有不同的防火墙(我无权访问)。第一个(Dev)没问题,但是,在相同的配置下,UAT 集群 pod 正在努力解析 DNS。节点可以解决并且似乎没问题。

1) ping 8.8.8.8 有效

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms

2)我可以ping google(和其他人)的IP,但不能ping 实际的dns 名称。

我们的配置:

  1. 配置了 Terraform。
  2. 工作节点和控制平面 SG 与开发节点相同。我相信这些都很好。
  3. 在入站 + 出站 NACl 上添加了 53 TCP 和 53 UDP(只是为了确保 53 真的打开了......)。添加了从工作节点出站的 53 个 TCP 和 53 个 UDP。
  4. 我们使用ami-059c6874350e63ca9的是 1.14 kubernetes 版本。

我不确定问题是某处的防火墙、coredns、我需要更新的配置还是“愚蠢的错误”。任何帮助,将不胜感激。

标签: kubernetesamazon-ekscoredns

解决方案


请注意,此问题可能以多种形式出现(例如,DNS 无法解析只是一种可能的情况)。该terraform-awk-eks模块公开一个 terraform 输入以创建必要的安全组规则,以允许这些工作组/节点组之间的通信:worker_create_cluster_primary_security_group_rules. terraform-awk-eks此问题中的更多信息https://github.com/terraform-aws-modules/terraform-aws-eks/issues/1089

启用输入后,terraform 会创建以下安全组规则:

  # module.eks.module.eks.aws_security_group_rule.cluster_primary_ingress_workers[0] will be created                                                                                                                                                                                                                           
  + resource "aws_security_group_rule" "cluster_primary_ingress_workers" {                                                                                                                                                                                                                                                     
      + description              = "Allow pods running on workers to send communication to cluster primary security group (e.g. Fargate pods)."                                                                                                                                                                                
      + from_port                = 0                                                                                                                                                                                                                                                                                           
      + id                       = (known after apply)                                                                                                                                                                                                                                                                         
      + protocol                 = "-1"                                                                                                                                                                                                                                                                                        
      + security_group_id        = "sg-03bb33d3318e4aa03"                                                                                                                                                                                                                                                                      
      + self                     = false                                                                                                                                                                                                                                                                                       
      + source_security_group_id = "sg-0fffc4d49a499a1d8"                                                                                                                                                                                                                                                                      
      + to_port                  = 65535                                                                                                                                                                                                                                                                                       
      + type                     = "ingress"                                                                                                                                                                                                                                                                                   
    }                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                                                                                                                                                               
  # module.eks.module.eks.aws_security_group_rule.workers_ingress_cluster_primary[0] will be created                                                                                                                                                                                                                           
  + resource "aws_security_group_rule" "workers_ingress_cluster_primary" {                                                                                                                                                                                                                                                     
      + description              = "Allow pods running on workers to receive communication from cluster primary security group (e.g. Fargate pods)."                                                                                                                                                                           
      + from_port                = 0                                                                                                                                                                                                                                                                                           
      + id                       = (known after apply)                                                                                                                                                                                                                                                                         
      + protocol                 = "-1"                                                                                                                                                                                                                                                                                        
      + security_group_id        = "sg-0fffc4d49a499a1d8"                                                                                                                                                                                                                                                                      
      + self                     = false
      + source_security_group_id = "sg-03bb33d3318e4aa03"
      + to_port                  = 65535
      + type                     = "ingress"
    }

推荐阅读