简体   繁体   English

Azure Kubernetes LoadBalancer 将请求转发到所有实例

[英]Azure Kubernetes LoadBalancer forward requests to all instances

I have a service using Azure Kubernetes cluster and AKS load balancer.我有一个使用 Azure Kubernetes 集群和 AKS 负载平衡器的服务。 I want to forward some HTTP(client) requests to all instances.我想将一些 HTTP(客户端)请求转发到所有实例。 is there any way to configure this behavior using AKS or Kubernetes in general?一般来说,有什么方法可以使用 AKS 或 Kubernetes 配置此行为?

Say I have XYZ API running two replicas/instances.假设我有运行两个副本/实例的 XYZ API。

  • XYZ-1 pod instance XYZ-1 pod 实例
  • XYZ-2 pod instance XYZ-2 pod 实例

I have some rest API requests to the app domain.com/testendpoint我对应用程序 domain.com/testendpoint 有一些 rest API 请求

Currently, using AKS load balancer it sends the requests in a round-robin fashion to XYZ-1 and XYZ-2.目前,使用 AKS 负载均衡器,它以循环方式将请求发送到 XYZ-1 和 XYZ-2。 I am looking to see if it is possible to forward a request to both instances (XYZ-1 and XYZ-2) when the request endpoint is testendpoint and all other API requests use the same round-robin order.当请求端点是testendpoint并且所有其他 API 请求使用相同的循环顺序时,我正在查看是否可以将请求转发到两个实例(XYZ-1 和 XYZ-2)。

The use case to refresh a service in-memory data via a rest call once a day or twice and the rest call will be triggered by another service when needed.通过每天一次或两次调用 rest 刷新服务内存中数据的用例,并且 rest 调用将在需要时由另一个服务触发。 so want to make sure all pod instances update/refresh in-memory data by an HTTP request.所以要确保所有 pod 实例都通过 HTTP 请求更新/刷新内存中的数据。

if it is possible to forward a request to both instances (XYZ-1 and XYZ-2) when the request endpoint is testendpoint当请求端点是 testendpoint 时,是否可以将请求转发到两个实例(XYZ-1 和 XYZ-2)

This is not a feature in the HTTP protocol, so you need a purpose built service to handle this.这不是 HTTP 协议中的功能,因此您需要专门构建的服务来处理此问题。

The use case to refresh a service in-memory data via a rest call once a day or twice and the rest call will be triggered by another service when needed.通过每天一次或两次调用 rest 刷新服务内存中数据的用例,并且 rest 调用将在需要时由另一个服务触发。 so want to make sure all pod instances update/refresh in-memory data by an HTTP request.所以要确保所有 pod 实例都通过 HTTP 请求更新/刷新内存中的数据。

I suggest that you create a new utility service, "update-service" - that you send the call once a day to.我建议您创建一个新的实用程序服务“update-service” - 您每天向该服务发送一次调用。 This service then makes a request to every instance of XYZ, like XYZ-1 and XYZ-2 .然后,该服务向 XYZ 的每个实例发出请求,例如XYZ-1XYZ-2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM