kubernetes-sigs / aws-load-balancer-controller

A Kubernetes controller for Elastic Load Balancers
https://kubernetes-sigs.github.io/aws-load-balancer-controller/
Apache License 2.0
3.89k stars 1.44k forks source link

Share traffic among multiple namespaces, equally distributed among pods across namespaces #3788

Open nbellowe opened 1 month ago

nbellowe commented 1 month ago

Is your feature request related to a problem?

I want to be able to deploy multiple versions of my application to different namespaces, and have pods take equivalent amounts of traffic from a shared ALB, at the same path/host.

For example, I could have

  1. namespaceA with 100 pods of versionA
  2. namespaceB with 1 pod of versionB

I want the number of requests that a pod in namespaceA to receive, to match the number of requests in namespaceB.

Describe the solution you'd like

Ideally I'd be able to either:

1) Define TargetGroupBinding resources in multiple namespaces, each targeting the same TargetGroup arn! Ideally, this would lead to all pods being a member of the same target group. Right now, aws-load-balancer-controller does not support multiple TargetGroupBindings with the same targetArn.

2) Define Ingress resources in multiple namespaces, each targeting the same ingress group name, and rules. Ideally, this would lead to pods in different namespaces using the same underlying targetGroup. Right now, this configuration creates different targetGroups and listener rules with different priorities, so that only the one with the highest priority will get ANY traffic.

Describe alternatives you've considered

For reasons, I cannot use a kubernetes API gateway. For now, I have multiple versions of my application modeled by seperate deployments, in the same namespace, with a single service in front of all of them. This is suboptimal, because I don't get benefits of namespace isolation, and need to manage things like unique resource naming etc.

M00nF1sh commented 1 month ago

one possible solution is to create two targetGroup and use TargetGroupBinding to bind them to two service separately. Then use weighted load balancing feature to configure a listener rule that forward traffic to two targetGroup with weights. However, the weights indeed needs to be adjusted yourself.

nbellowe commented 1 month ago

That won't work for me, because the number of pods in different namespaces will be dynamic. In my case, I have different namespaces, with dynamic, changing number of pods.