kedacore / http-add-on

Add-on for KEDA to scale HTTP workloads
https://kedacore.github.io/http-add-on/
Apache License 2.0
356 stars 95 forks source link

Ignoring requests #282

Open arschles opened 3 years ago

arschles commented 3 years ago

I'd like to be able to configure the interceptor to prevent specific incoming requests from triggering a scaling event. Examples of these types of requests would be health checks or requests for metrics.

Use-Case

My interceptor fleet is fronted by a load balancer that makes periodic health check requests to the /healthz path. In this situation, I want these requests to check if the interceptors are healthy, not necessarily the backend application. Therefore, the backend application should not scale.

Specification

There should be optional configuration to instruct the interceptor to ignore certain classes of requests. I believe this should be a different CRD, as ignore configuration should be orthogonal to scaling configuration. Such a CRD might look similar to the below:

kind: HTTPIgnoreRule
apiVersion: http.keda.sh/v1alpha1
metadata:
    name: healthz-path
spec:
    paths:
        - /healthz*

This rule would ignore all paths that match the pattern (perhaps one that matches the one defined in filepath.Match) across all requests. Importantly, this ignore rule would match all requests across all hosts. The CRD should support specification of hosts or host patterns via a spec.hosts field so that HTTPIgnoreRules have a many-to-many relationship to HTTPScaledObjects.

There should also be a spec.headers field that contains matching rules for incoming request headers:

kind: HTTPIgnoreRule
apiVersion: http.keda.sh/v1alpha1
metadata:
    name: custom-value-header
spec:
    headers:
        - X-Custom-Value: abc*xyz

This rule would match all incoming requests that have an X-Custom-Value header that starts with abc and ends with xyz.

If both of these rules were submitted to the cluster at once, only requests that match the union of these two rules would be ignored. In other words, for any given host, all applicable rules are ANDed together to match against requests.

vitarkah commented 3 years ago

Looks good; one question - How would HTTPIgnoreRule be tied back to the relevant HTTPScaledObject?

arschles commented 3 years ago

@vitarkah it may not tie back to just one specific HTTPScaledObject but the intersection point between the two is the Host. If there were an HTTPScaledObject issued for host: mysite.com and an HTTPIgnoreRule issued similar to this:

kind: HTTPIgnoreRule
apiVersion: http.keda.sh/v1alpha1
metadata:
    name: healthz-path
spec:
    hosts:
        - *site.com

Then the ignore would apply to that HTTPScaledObject and others ending in site.com (like host: myothersite.com)

vitarkah commented 2 years ago

Perfect! Thanks and look forward to this feature.