使用 EKS alb 入口运行状况检查管理的 ALB 前面的 AWS Global Accelerator 失败

AWS Global Accelerator in front of ALB managed with EKS alb ingress health checks fail

有一个带有 alb 入口控制器和连接到 route53 的外部 DNS 的 EKS 集群,现在一些客户需要静态 IP 或 IP 范围来连接到我们的服务器并在他们的防火墙中将这些 IP 列入白名单。

尝试了新的 AWS Global Accelerator,遵循本教程 https://docs.aws.amazon.com/global-accelerator/latest/dg/getting-started.html 但它失败了:

Listeners in this accelerator have an unhealthy status. To make sure that Global Accelerator can run health checks successfully, ensure that a service is responding on the protocol and port that you specified in the health check configuration. Learn more

进一步阅读后了解到,健康检查将与 ALB 上的配置相同,而且它可能会失败,因为 route53 健康检查 ip 未列入白名单,但所有入站流量都在端口 80 和 443 中打开,因此不会非常确定如何进一步调试它,或者是否有任何其他解决方案来获取 ALB 的 ip 范围或静态 ip。

您需要向入口控制器添加这样的健康检查规则:

- http:
    paths:
      - path: /global-accelerator-healthcheck
        backend:
          serviceName: global-accelerator-healthcheck
          servicePort: use-annotation

然后注释:

    alb.ingress.kubernetes.io/actions.global-accelerator-healthcheck: '{"Type": "fixed-response", "FixedResponseConfig": {"ContentType": "text/plain", "StatusCode": "200", "MessageBody": "healthy" }}'

然后将全局加速器配置为对该端点进行健康检查

说到AWS ALB Ingress controller,总会想到 在您使用 AWS ALB 及其目标群体时使用它。

  • 您甚至可以通过登录 AWS 控制台来识别 ALB 及其目标组 UI。
  • 要回答您的问题,请尝试将以下详细信息添加到您的入口,

代码:

annotations:
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
alb.ingress.kubernetes.io/healthcheck-port: "8161"
alb.ingress.kubernetes.io/healthcheck-path: /admin
alb.ingress.kubernetes.io/success-codes: '401'
alb.ingress.kubernetes.io/backend-protocol: HTTP`

注意:如果您对不同的服务有不同的健康检查设置,请从 K8s“入口”中删除此块并为每个 K8s“服务”添加块。

如需更多信息,请参考:https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.1/guide/ingress/annotations/