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

implement basic DDOS protections in the HAProxy template router #9810

Merged
merged 1 commit into from
Jul 26, 2016

Conversation

JacobTanenbaum
Copy link
Contributor

Using annotations implement basic DDOS protections in the HAProxy router

  • ability to limit the number of concurrent TCP connections
  • limit the rate at which a client can request TCP connections
  • limit the rate at which HTTP requests can be made

These are enabled on a per route bases because apps could have extremely
different traffic patterns

setting "router.openshift.io/haproxy.DDOS" enables the settings to be
configured

setting "router.openshift.io/haproxy.DDOS.concurrentTCP" changes the
number concurrent TCP connections that can be made by the same IP
address on this route.

setting "router.openshift.io/haproxy.DDOS.rateTCP" changes the number of
TCP connections that can be opened by a client IP.

setting "router.openshift.io/haproxy.DDOS.rateHTTP" changes the number
of HTTP requests that a client IP can make in a 3s period.

Since traffic patterns can vary wildly I provided no default values for
these protections

If the DDOS conditions are violated the router closes the connection to
the client.

@@ -226,6 +226,28 @@ backend be_edge_http_{{$cfgIdx}}
{{ else }}
balance leastconn
{{ end }}

{{ if index $cfg.Annotations "router.openshift.io/haproxy.DDOS" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use uppercase in annotations. I don't know that these annotations have anything to do with DDOS, they're just optional fields, so they should be named appropriately.

The top level flag should be named appropriately, probably haproxy.router.openshift.io/rate-limit-connections and the others should follow that pattern with sub names.

@JacobTanenbaum
Copy link
Contributor Author

@openshift/networking @knobunc

@knobunc
Copy link
Contributor

knobunc commented Jul 20, 2016

LGTM @rajatchopra PTAL

@rajatchopra
Copy link
Contributor

rajatchopra commented Jul 20, 2016

We need a test case for this. Set connection rate limit to 3 and open 4th connection. extended tests may be the right place still.

@@ -231,6 +231,29 @@ backend be_edge_http_{{$cfgIdx}}
timeout server {{$value}}
{{ end }}
{{ end }}

{{ if index $cfg.Annotations "router.openshift.io/haproxy.rate-limit-connections" }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs the haproxy.router.openshift.io/ prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed the same format for annotations as Rajat (line 222). If I change mine the naming will be inconsistent, should I change Rajat's as well? @rajatchopra

Copy link
Contributor

@rajatchopra rajatchopra Jul 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think (router-name).router.openshift.io/(feature) sounds better scoped. @JacobTanenbaum change the one that I wrote too then maybe (will need testcase changes too). Thanks.

@JacobTanenbaum
Copy link
Contributor Author

[Test]

Using annotations implement basic DDOS protections in the HAProxy router
   - ability to limit the number of concurrent TCP connections
   - limit the rate at which a client can request TCP connections
   - limit the rate at which HTTP requests can be made

These are enabled on a per route bases because apps could have extremely
different traffic patterns

setting "router.openshift.io/haproxy.DDOS" enables the settings to be
configured

setting "router.openshift.io/haproxy.DDOS.concurrentTCP" changes the
number concurrent TCP connections that can be made by the same IP
address on this route.

setting "router.openshift.io/haproxy.DDOS.rateTCP" changes the number of
TCP connections that can be opened by a client IP.

setting "router.openshift.io/haproxy.DDOS.rateHTTP" changes the number
of HTTP requests that a client IP can make in a 3s period.

Since traffic patterns can vary wildly I provided no default values for
these protections

If the DDOS conditions are violated the router closes the connection to
the client.
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 2b4703a

@knobunc
Copy link
Contributor

knobunc commented Jul 25, 2016

LGTM. @rajatchopra if you like it, I think we are good to merge.

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6812/)

@rajatchopra
Copy link
Contributor

LGTM. But we need a test somewhere. [merge], the test looks flaky.

@openshift-bot
Copy link
Contributor

openshift-bot commented Jul 26, 2016

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/6947/) (Image: devenv-rhel7_4671)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to 2b4703a

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

Successfully merging this pull request may close these issues.

5 participants