【问题标题】:Pods in EKS: can't resolve DNS (but can ping IP)EKS 中的 Pod:无法解析 DNS(但可以 ping IP)
【发布时间】:2020-01-09 11:06:42
【问题描述】:

我有 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、我需要更新的配置还是“愚蠢的错误”。任何帮助将不胜感激。

【问题讨论】:

  • 你的情况有很多变数,你介意分享你的 terraform 脚本吗?不要忘记删除敏感数据。还需要从您的服务中读取 yaml,如果没有,请运行kubectl get services -o yaml 将其导出并粘贴到您的问题中。

标签: kubernetes amazon-eks coredns


【解决方案1】:

请注意,此问题可能以多种形式出现(例如,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"
    }

【讨论】:

  • 很高兴看到使用 terraform eks 模块的答案。有趣的是 worker_create_cluster_primary_security_group_rules 默认是禁用的。如果您希望使用 AWS 入口控制器并连接到 RDS 端点,则需要启用该功能和 enable_irsa 功能。
【解决方案2】:

经过几天的调试,这就是问题所在: 我允许节点之间的所有流量,但 all traffic 是 TCP,而不是 UDP。

这基本上是 AWS 中的一行: 在工作节点 SG 中,添加来自工作节点端口 53 协议 DNS (UDP) 的入站规则。

如果你使用 terraform,它应该是这样的:

resource "aws_security_group_rule" "eks-node-ingress-cluster-dns" {
  description = "Allow pods DNS"
  from_port                = 53
  protocol                 = 17
  security_group_id        = "${aws_security_group.SG-eks-WorkerNodes.id}"
  source_security_group_id = "${aws_security_group.SG-eks-WorkerNodes.id}"  
  to_port                  = 53
  type                     = "ingress"
}

【讨论】:

    猜你喜欢
    • 2022-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-18
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 2019-10-22
    相关资源
    最近更新 更多