【问题标题】:Multi-cluster Kubernetes with percentage traffic cross cluster具有跨集群百分比流量的多集群 Kubernetes
【发布时间】:2021-07-11 10:00:44
【问题描述】:

现在,我在谷歌云 GKE 中有生产基础设施。我计划将其迁移到 Azure AKS。

当我从 GKE 迁移到 AKS(零停机时间)时,我对如何跨不同集群计算流量百分比的策略感到困惑。

例子,

在谷歌云中,我使用 Cloudflare + GCLB 和 NEG(网络端点组)作为后端服务,在 Azure 中,我使用应用程序网关入口控制器 (AGIC)。

我们称为 XYZ 服务的微服务部署在 GKE 和 AKS 中。我可以说我可以访问 xyz.domain.tld 并得到预期的响应。

如何实现百分比流量,例如 10% 的流量将流向 AKS,剩下的 90% 留在 GKE?

我应该在我当前的生产环境中实现 istio 吗?或者 Cloudflare 是否具有百分比流量的功能,例如 90% 将流向 GKE IP 地址,10% 将流向 AKS IP 地址?

【问题讨论】:

    标签: google-kubernetes-engine cloudflare azure-aks


    【解决方案1】:

    您可以通过Cloudflare's Workers 实现它,这是一个运行在 Cloudflare 全球云网络上的无服务器应用程序平台。

    对于 A/B 测试场景,请查看 Cloudflare Workers 官方文档中的 this example

    A/B 测试 通过控制提供的响应来设置 A/B 测试 基于 cookie。

    function handleRequest(request) {
      const NAME = "experiment-0"
    
      // The Responses below are placeholders. You can set up a custom path for each test (e.g. /control/somepath ).
      const TEST_RESPONSE = new Response("Test group") // e.g. await fetch("/test/sompath", request)
      const CONTROL_RESPONSE = new Response("Control group") // e.g. await fetch("/control/sompath", request)
    
      // Determine which group this requester is in.
      const cookie = request.headers.get("cookie")
      if (cookie && cookie.includes(`${NAME}=control`)) {
        return CONTROL_RESPONSE
      }
      else if (cookie && cookie.includes(`${NAME}=test`)) {
        return TEST_RESPONSE
      }
      else {
        // If there is no cookie, this is a new client. Choose a group and set the cookie.
        const group = Math.random() < 0.5 ? "test" : "control" // 50/50 split
        const response = group === "control" ? CONTROL_RESPONSE : TEST_RESPONSE
        response.headers.append("Set-Cookie", `${NAME}=${group}; path=/`)
    
        return response
      }
    }
    
    addEventListener("fetch", event => {
      event.respondWith(handleRequest(event.request))
    })
    

    【讨论】:

    • 是否有可以根据 DNS IP 地址应用百分比流量的功能或堆栈?例如,mydomain.tld 有 3 个 IP 地址(A、B 和 C),但我可以将 90% 配置给 IP A 和 B,剩下 10% 给 IP C?
    • 好吧,我没听说过,但是如果您的域是在 cloudflare 上管理的,我想您也可以尝试将上述脚本调整为您的流量分布在后面提到的 3 个 IP 地址的场景yourdomain.tld
    猜你喜欢
    • 2020-05-24
    • 2019-07-11
    • 2019-02-28
    • 1970-01-01
    • 2020-10-15
    • 1970-01-01
    • 2019-05-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多