【问题标题】:Traefik on EKS with pod Security Groups带有 pod 安全组的 EKS 上的 Traefik
【发布时间】:2021-03-21 06:59:15
【问题描述】:

我正在尝试在公共 AWS NLB 上设置一个仅对特定 IP 范围可见的 pod。为此,我认为我可以使用 EKS 的安全组策略。

如果我来自 IP 123.45.67.81,我希望在 Traefik 日志中作为我的 clientHost 看到这一点,然后在我的最终应用程序中看到同样的结果。相反,我看到 Traefik 的 IP 是我们的内部网络 10.X.Y.Z。我设法通过添加以下内容来设置 NLB 以将客户端 IP 传递给 traefik:

    service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: "*",

spec: {
    externalTrafficPolicy: Local
}

但我仍然看不到最后一个 pod 上的 IP。我在 traefik 的配置中添加了以下内容:

- "--entryPoints.web.forwardedHeaders.trustedIPs=10.X.0.0/16"
- "--entryPoints.web.forwardedHeaders.insecure"
- "--entryPoints.web.proxyProtocol.trustedIPs=10.X.0.0/16"
- "--entryPoints.web.proxyProtocol.insecure"
- "--entryPoints.websecure.forwardedHeaders.trustedIPs=10.X.0.0/16"
- "--entryPoints.websecure.forwardedHeaders.insecure"
- "--entryPoints.websecure.proxyProtocol.trustedIPs=10.X.0.0/16"
- "--entryPoints.websecure.proxyProtocol.insecure"

但它似乎没有任何区别。我知道要使其正常工作,我需要使代理协议正常工作,但我不确定它为什么不工作!

【问题讨论】:

  • 您能否使用您的应用程序收到的 HTTP 请求标头更新问题?特别是那些以“X-”开头的。

标签: amazon-web-services kubernetes traefik amazon-eks


【解决方案1】:

您可能希望使用 traefik 和 eks 版本更新您的问题,因为这可能会与版本有关。

既然你说nlb,我假设你已经设置了.spec.metadata.annotations.service\.beta\.kubernetes\.io/aws-load-balancer-type=nlb,这意味着你正在使用in-tree provider

您是否确认负载均衡器确实收到了service.beta.kubernetes.io/aws-load-balancer-proxy-protocol 的配置?转到控制台的ec2 > load balancers 区域并验证该字段是否按预期设置。我敢打赌不是。

在我的 eks 1.19.x 集群中,这种行为不像宣传的那样起作用。这似乎是一个active issue,在active re-organization of the load balancer provider 之中,这使得它很难追踪。据我所知,修复是slated to land in k8s 1.20,不知道是否/何时可以使用反向移植。

在那之前,我至少可以确认注释似乎使用新创建的aws-load-balancer-controller project 可以正常工作,但它们只支持nlb-ip,这有其自身的问题(在我的情况下为like 5+ minute registration/deregistration times!引用: It can take a few minutes for the registration process to complete and health checks to start.)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-19
    • 2021-03-25
    • 1970-01-01
    • 2021-05-31
    • 2019-05-30
    • 2018-05-03
    • 1970-01-01
    相关资源
    最近更新 更多