-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Http header routing pattern #1177
Comments
I really like the idea of the feature, I think it's essential that http-add-on supports routing based on headers. I would like to propose an alternative path on how it is implemented. Instead of ENV variable static for the entire traffic passing through the interceptor, it would be imho better to follow the design decisions from Gateway API. Mixing URLs and header values in Currently the apiVersion: http.keda.sh/v1alpha1
kind: HTTPScaledObject
spec:
hosts:
- my.domain.com
- my2.domain.com
pathPrefixes:
- /root
- /new-feature Adding apiVersion: http.keda.sh/v1alpha1
kind: HTTPScaledObject
spec:
hosts:
- my.domain.com
- my2.domain.com
pathPrefixes:
- /root
- /new-feature
headers:
- name: x-header-test
value: abc
- name: x-header-test2
value: def |
hey @gjreasoner I'm here because I'm seeing a similar issue (#851 to be exact) and I think this fix can address it. If I can pass in custom headers, I can rewrite the L7 path on the ingress and route based on custom headers rather than the path. when do you think you can have this PR merged by? im happy to help |
Hey @erich23 it's definitely top of mind, I have a work around (this patch on the interceptor image) in place that's keeping it from a being an absolute rush on my side. I'd still like to get back to the proposed solution hopefully in the week or so with the holiday slowdown. Feel free to take a stab at it if you'd like, I'll update here if I start work on it 👍🏻 |
hey @gjreasoner and @wozniakjan, here's my implementation of the proposed solution: #1222. Can you guys give this a review? I'm going to try and get test cases to pass now but please let me know if anything is missing |
In KEDA's apiVersion: http.keda.sh/v1alpha1
kind: HTTPScaledObject
metadata:
name: canary
spec:
hosts:
- my.domain.com
- my2.domain.com
pathPrefixes:
- /root
- /new-feature
---
apiVersion: http.keda.sh/v1alpha1
kind: HTTPScaledObject
metadata:
name: primary
spec:
hosts:
- my.domain.com
- my2.domain.com
pathPrefixes:
- /root
- /new-feature
headers:
- name: X-Flagger-Traffic-Target-To
value: primary In this setup, both The Kubernetes Gateway API's
Applying these principles to Implementing such matching precedence in By clarifying and adopting these matching precedence rules, we can leverage header matches to achieve sophisticated routing and scaling scenarios, enhancing the flexibility and control over traffic management in KEDA deployments. This approach would facilitate configurations like the one depicted below, enabling efficient management of multiple traffic versions and revisions: |
@kahirokunn I'm not familiar with Gateway API's implementation of HTTPRoute, but based on what you're describing my PR is almost fulling these requirements. Since it returns a longest prefix match that fulfills
But we can tweak the PR to rank HTTPScaledObjects by # of header matches and go with the most frequent one. This would also mean that, when none of headers match any please feel free to review the current implementation 😊 I plan to chip away at this PR more tomorrow |
Proposal
Would like to use a HTTP header in the HTTP request to determine which service to route to using http header based routing pattern.
Use-Case
Imagine hundreds of customers each with 100s of different domains pointed to their own HttpScaledObject.
Rather than maintaining the 100 domains on
HTTPScaledObject
, you send a custom headerX-Customer-Id: customer-id-1
and register the hosts ascustomer-id-1
,customer-id-2
.This means your upstream can add/update/delete host names without needing to update HTTPScaledObjects or extra k8s ingress/services.
Is this a feature you are interested in implementing yourself?
Yes
Anything else?
Can see this being implemented like
KEDA_HTTP_ADDTL_ROUTING_HEADER=X-Customer-Id
when blank or missing from the request, it still uses the HTTP Host headerThis gives you an easy way to opt into the feature and have fallback/main site domains.
While your remaining domains might look like
The text was updated successfully, but these errors were encountered: