Skip to content
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

Support custom ingress annotations and expose them to haproxy.tmpl #1165

Open
phihos opened this issue Aug 20, 2024 · 0 comments
Open

Support custom ingress annotations and expose them to haproxy.tmpl #1165

phihos opened this issue Aug 20, 2024 · 0 comments

Comments

@phihos
Copy link

phihos commented Aug 20, 2024

What are you trying to do

Hi, I really like that the ingress controller allows admins to override the config template. That way features can be implemented that are not yet supported or may never be supported because it may be too niche.
Let's say we override how the rate-limiting works in the template and have two stick-tables recording the request rate over 1s and 30s. We put the default thresholds for rate limiting into the variables req.rate_limit_1s and req.rate_limit_30s and render a snippet into each backend that denies requests when either of the thresholds is met.
Now the important part: I would like users to override these thresholds in their ingress resources. Of course I could tell them to do something like this:

    annotations:
      haproxy-ingress.github.io/config-backend: |
        http-request set-var(req.rate_limit_1s) int(50)
        http-request set-var(req.rate_limit_30s) int(1000)

But this is very brittle and asks too much of the users. Instead I would like to be able to provide a custom annotation like this:

```haproxy
    annotations:
      haproxy-ingress.myorg.com/rate-limit-1s: "50"
      haproxy-ingress.myorg.com/rate-limit-30s: "1000"

What HAProxy Ingress should do or how it should behave differently

HAProxy Ingress could accept config parameters that define the allowed custom annotations via regexes. In haproxy.tmpl they could be exposed like this:

{{- $rateLimit1s := $backend.CustomAnnotations "haproxy-ingress.myorg.com/rate-limit-1s" }}
# ...

I am aware that overriding the template is not recommended, but when people (like me) insist on shooting themselves in the foot why not help them? :-)
This feature can help to implement the missing 10% in cases where the ingress controller already provides 90% of what is needed. If that feature has a chance to be accepted I would be happy to help implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants