Skip to content

Route specific filterchains / dynamic filter order #11690

Open

Description

@mandarjog

Usecase:
This behaviour is desirable for Istio extensions API and related K8s Service APIs Per Target Actions

Many times at ingress there is a need to attach specific behaviours to specific paths.
For example

kind: HTTPRoute
apiVersion: networking.x-k8s.io/v1alpha1
spec:
 hosts:
   - hostname: foo.com
     rules:
     - match:
         path: /bar
       actions:
       - custom:
           targetRef:
             group: "proxy-vendor1.com/v1alpha1"
             resource: "actions"
             name: foo-com-authn
       - custom:
           targetRef:
             group: "mesh-vendor2.com/v1alpha1"
             resource: "plugins"
             name: foo-com-rate-limit
       - modify:
           headers:
             add:
               example: foo
       forwardTo:
       - targetRef:
           name: foo

There is no first class support for this.

What is possible today ?

There is a requested feature for conditional filter dispatch, with this feature or ad-doc filter specific route metadata it is possible to enable and disable filters for specific paths that can approximate the above behaviour.

Problems

a. Every filter must participate in this behaviour. If a filter does not honor filter-enable type flag then it will be dispatched even if the user did not intend it.
b. Filter order cannot be changed. Filter order is statically programmed in the filter chain, and the above process can only enable or disable filters within.

Options

Add ability to specify route specific filter chains.

  1. The current http filterchain, becomes the default filterchain.
  2. User can specify a filterchain inline with the route, or refer to it by name.
  3. If route specific filterchain is specified, the route computation happens before dispatching anything, (unlike lazy route computation which happens today)

Activity

  1. mandarjog commented on Jun 22, 2020

    @mandarjog
    ContributorAuthor
  2. added
    enhancement
    on Jun 22, 2020
  3. kyessenov commented on Jun 22, 2020

    @kyessenov
    Contributor

    I think there is some overlap with per_filter_configs that needs to be resolved. The design question is whether we want to instantiate different filters based on routes, which would mean that router needs to compute the route ahead of time.

  4. mattklein123 commented on Jun 22, 2020

    @mattklein123
    Member

    I like this idea but this definitely needs more thinking and a spec. Some quick things beyond what @kyessenov notes:

    1. How do we handle a filter changing the route? Does this become an internal redirect?
    2. There are potentially some pretty gnarly issues around workers and config to deal with in terms of pre-computing the filter chain. We may end up needing callbacks that can be registered when RDS changes for example so that different routes can have filter chains pre-cached in some way. Note that this conversation is actually super relevant with this per-route Lua PR which I don't think actually works as written for the reasons outlined: lua: Add per filter config for Lua filter #11235. cc @dio @wbpcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/httpenhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions