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.91k stars 1.45k forks source link

Combine multiple LB rules to one rule with OR #3446

Open nirroz93 opened 11 months ago

nirroz93 commented 11 months ago

Is your feature request related to a problem? Let's say we have the following (I used use-annotation, but it doesn't matter)

   - host: myFirstDNS.example.com
      http:
        paths:
        - backend:
            service:
              name: canary
              port:
                name: use-annotation
          path: /
          pathType: Prefix
    - host: mySecondDNS.example.com
      http:
        paths:
        - backend:
            service:
              name: canary
              port:
                name: use-annotation
          path: /
          pathType: Prefix

This will create 2 Load Balancer rules on the load balancer, the first with condition:

Path Pattern is /*, AND
HTTP Host Header is myFirstDNS.example.com

and the second with condition:

Path Pattern is /*, AND
HTTP Host Header is mySecondDNS.example.com

However, it could have created only 1 rule with condition

Path Pattern is /*, AND
HTTP Host Header is myFirstDNS.example.com or mySecondDNS.example.com

Creating multiple rules increase the rules evaluation (and therefore creates additional costs), and it's also less clear. Describe the solution you'd like Combine ingress rules with the same settings but different prefix\host to one rule

Describe alternatives you've considered Creating multiple LBs to avoid the extra evaluations costs

TheSAS commented 9 months ago

It would be nice to see this implemented :+1: It would partially solve this one https://github.com/kubernetes-sigs/aws-load-balancer-controller/issues/1784 too.

oliviassss commented 8 months ago

Thanks for bringing this up, I think it's a good improvement to have. I think we can have the controller to merge the paths for each ingress if:

For example, when creating an ingress with the following spec:

spec:
  rules:
    - http:
        paths:
          - path: /test1
            pathType: ImplementationSpecific
            backend:
              service:
                name: my_service
                port:
                  number: 80
          - path: /test2
            pathType: ImplementationSpecific
            backend:
              service:
                name: my_service
                port:
                  number: 80
    - http:
        paths:
          - path: /*
            pathType: ImplementationSpecific
            backend:
              service:
                name: my_service
                port:
                  number: 80

The controller is generating three rules right now:

With the change the controller will only generate one rule:

oliviassss commented 8 months ago

/kind feature

jcogilvie commented 8 months ago

What is the maximum number of characters (or clauses) that can be merged into a single matcher line? If a rule would exceed it, it should be split into multiple rules at some boundary.

k8s-triage-robot commented 5 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

jcogilvie commented 5 months ago

/remove-lifecycle stale

omerap12 commented 3 months ago

/assign

k8s-triage-robot commented 2 weeks ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

henryzhao95 commented 2 weeks ago

/remove-lifecycle stale