Azure Kubernetes LoadBalancer forward requests to all instances

11/30/2020

I have a service using Azure Kubernetes cluster and AKS load balancer. I want to forward some HTTP(client) requests to all instances. is there any way to configure this behavior using AKS or Kubernetes in general?

Say I have XYZ API running two replicas/instances.

  • XYZ-1 pod instance
  • XYZ-2 pod instance

I have some rest API requests to the app domain.com/testendpoint

Currently, using AKS load balancer it sends the requests in a round-robin fashion to XYZ-1 and 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.

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. so want to make sure all pod instances update/refresh in-memory data by an HTTP request.

-- vkt
azure
azure-aks
azure-load-balancer
kubernetes
load-balancing

1 Answer

11/30/2020

if it is possible to forward a request to both instances (XYZ-1 and XYZ-2) when the request endpoint is testendpoint

This is not a feature in the HTTP protocol, so you need a purpose built service to handle this.

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. so want to make sure all pod instances update/refresh in-memory data by an HTTP request.

I suggest that you create a new utility service, "update-service" - that you send the call once a day to. This service then makes a request to every instance of XYZ, like XYZ-1 and XYZ-2.

-- Jonas
Source: StackOverflow