rework loadbalancer support
This commit is contained in:
parent
b143101f82
commit
518a37e776
86 changed files with 339 additions and 1055 deletions
|
@ -134,5 +134,4 @@ labels:
|
|||
[http.services.service1.LoadBalancer]
|
||||
[[http.services.service1.LoadBalancer.Servers]]
|
||||
URL = "http://127.0.0.1:80"
|
||||
Weight = 1
|
||||
```
|
||||
|
|
|
@ -92,7 +92,6 @@ labels:
|
|||
|
||||
[[http.services.service1.LoadBalancer.Servers]]
|
||||
URL = "http://127.0.0.1:80"
|
||||
Weight = 1
|
||||
```
|
||||
|
||||
## Advanced Configuration
|
||||
|
|
|
@ -232,7 +232,7 @@ Every [Router](../routing/routers/index.md) parameter can be updated this way.
|
|||
|
||||
### Services
|
||||
|
||||
To update the configuration of the Service automatically attached to the container, add labels starting with `traefik.http.services.{name-of-your-choice}.`, followed by the option you want to change. For example, to change the load balancer method, you'd add the label `traefik.http.services.{name-of-your-choice}.loadbalancer.method=drr`.
|
||||
To update the configuration of the Service automatically attached to the container, add labels starting with `traefik.http.services.{name-of-your-choice}.`, followed by the option you want to change. For example, to change the passhostheader behavior, you'd add the label `traefik.http.services.{name-of-your-choice}.loadbalancer.passhostheader=false`.
|
||||
|
||||
Every [Service](../routing/services/index.md) parameter can be updated this way.
|
||||
|
||||
|
|
|
@ -44,13 +44,10 @@ You can write these configuration elements:
|
|||
[http.services]
|
||||
[http.services.service-foo]
|
||||
[http.services.service-foo.LoadBalancer]
|
||||
method = "wrr"
|
||||
[[http.services.service-foo.LoadBalancer.Servers]]
|
||||
url = "http://foo/"
|
||||
weight = 30
|
||||
[[http.services.service-foo.LoadBalancer.Servers]]
|
||||
url = "http://bar/"
|
||||
weight = 70
|
||||
```
|
||||
|
||||
## Provider Configuration Options
|
||||
|
|
|
@ -262,7 +262,7 @@ Every [Router](../routing/routers/index.md) parameter can be updated this way.
|
|||
|
||||
To update the configuration of the Service automatically attached to the container,
|
||||
add labels starting with `traefik.HTTP.Services.{service-name-of-your-choice}.`, followed by the option you want to change.
|
||||
For example, to change the load balancer method, you'd add the label `traefik.HTTP.Services.Servicename.LoadBalancer.Method=drr`.
|
||||
For example, to change the passhostheader behavior, you'd add the label `traefik.HTTP.Services.Servicename.LoadBalancer.PassHostHeader=false`.
|
||||
|
||||
Every [Service](../routing/services/index.md) parameter can be updated this way.
|
||||
|
||||
|
|
|
@ -152,8 +152,8 @@ Every [Router](../routing/routers/index.md) parameter can be updated this way.
|
|||
### Services
|
||||
|
||||
To update the configuration of the Service automatically attached to the container, add labels starting with `traefik.http.services.{name-of-your-choice}.`,
|
||||
followed by the option you want to change. For example, to change the load balancer method,
|
||||
you'd add the label `traefik.http.services.{name-of-your-choice}.loadbalancer.method=drr`.
|
||||
followed by the option you want to change. For example, to change the passhostheader behavior,
|
||||
you'd add the label `traefik.http.services.{name-of-your-choice}.loadbalancer.passhostheader=false`.
|
||||
|
||||
Every [Service](../routing/services/index.md) parameter can be updated this way.
|
||||
|
||||
|
|
|
@ -172,19 +172,16 @@
|
|||
[HTTP.Services]
|
||||
[HTTP.Services.Service0]
|
||||
[HTTP.Services.Service0.LoadBalancer]
|
||||
Method = "foobar"
|
||||
PassHostHeader = true
|
||||
|
||||
[[HTTP.Services.Service0.LoadBalancer.Servers]]
|
||||
URL = "foobar"
|
||||
Weight = 42
|
||||
|
||||
[HTTP.Services.Service0.LoadBalancer.Stickiness]
|
||||
CookieName = "foobar"
|
||||
|
||||
[[HTTP.Services.Service0.LoadBalancer.Servers]]
|
||||
URL = "foobar"
|
||||
Weight = 42
|
||||
|
||||
[HTTP.Services.Service0.LoadBalancer.HealthCheck]
|
||||
Scheme = "foobar"
|
||||
|
@ -214,15 +211,12 @@
|
|||
|
||||
[TCP.Services.TCPService0]
|
||||
[TCP.Services.TCPService0.LoadBalancer]
|
||||
Method = "foobar"
|
||||
|
||||
[[TCP.Services.TCPService0.LoadBalancer.Servers]]
|
||||
Address = "foobar"
|
||||
Weight = 42
|
||||
|
||||
[[TCP.Services.TCPService0.LoadBalancer.Servers]]
|
||||
Address = "foobar"
|
||||
Weight = 42
|
||||
|
||||
[[TLS]]
|
||||
Stores = ["foobar", "foobar"]
|
||||
|
|
|
@ -122,12 +122,10 @@ labels:
|
|||
- "traefik.HTTP.Services.Service0.LoadBalancer.HealthCheck.Port=42"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.HealthCheck.Scheme=foobar"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.HealthCheck.Timeout=foobar"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.Method=foobar"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.PassHostHeader=true"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.ResponseForwarding.FlushInterval=foobar"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.server.Port=8080"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.server.Scheme=foobar"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.server.Weight=42"
|
||||
- "traefik.HTTP.Services.Service0.LoadBalancer.Stickiness.CookieName=foobar"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.HealthCheck.Headers.name0=foobar"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.HealthCheck.Headers.name1=foobar"
|
||||
|
@ -137,12 +135,10 @@ labels:
|
|||
- "traefik.HTTP.Services.Service1.LoadBalancer.HealthCheck.Port=42"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.HealthCheck.Scheme=foobar"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.HealthCheck.Timeout=foobar"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.Method=foobar"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.PassHostHeader=true"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.ResponseForwarding.FlushInterval=foobar"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.server.Port=8080"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.server.Scheme=foobar"
|
||||
- "traefik.HTTP.Services.Service1.LoadBalancer.server.Weight=42"
|
||||
- "traefik.TCP.Routers.Router0.Rule=foobar"
|
||||
- "traefik.TCP.Routers.Router0.EntryPoints=foobar, fiibar"
|
||||
- "traefik.TCP.Routers.Router0.Service=foobar"
|
||||
|
@ -151,9 +147,5 @@ labels:
|
|||
- "traefik.TCP.Routers.Router1.EntryPoints=foobar, fiibar"
|
||||
- "traefik.TCP.Routers.Router1.Service=foobar"
|
||||
- "traefik.TCP.Routers.Router1.TLS.Passthrough=false"
|
||||
- "traefik.TCP.Services.Service0.LoadBalancer.Method=foobar"
|
||||
- "traefik.TCP.Services.Service0.LoadBalancer.server.Port=42"
|
||||
- "traefik.TCP.Services.Service0.LoadBalancer.server.Weight=42"
|
||||
- "traefik.TCP.Services.Service1.LoadBalancer.Method=foobar"
|
||||
- "traefik.TCP.Services.Service1.LoadBalancer.server.Port=42"
|
||||
- "traefik.TCP.Services.Service1.LoadBalancer.server.Weight=42"
|
||||
|
|
|
@ -14,14 +14,11 @@ The `Services` are responsible for configuring how to reach the actual services
|
|||
```toml
|
||||
[http.services]
|
||||
[http.services.my-service.LoadBalancer]
|
||||
method = "wrr" # Load Balancing based on weights
|
||||
|
||||
[[http.services.my-service.LoadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
weight = 30 # 30% of the requests will go to that instance
|
||||
[[http.services.my-service.LoadBalancer.servers]]
|
||||
url = "http://private-ip-server-2/"
|
||||
weight = 70 # 70% of the requests will go to that instance
|
||||
```
|
||||
|
||||
??? example "Declaring a TCP Service with Two Servers -- Using the [File Provider](../../providers/file.md)"
|
||||
|
@ -52,21 +49,17 @@ The load balancers are able to load balance the requests between multiple instan
|
|||
```toml
|
||||
[http.services]
|
||||
[http.services.my-service.LoadBalancer]
|
||||
method = "wrr" # Load Balancing based on weights
|
||||
|
||||
[[http.services.my-service.LoadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
weight = 50 # 50% of the requests will go to that instance
|
||||
[[http.services.my-service.LoadBalancer.servers]]
|
||||
url = "http://private-ip-server-2/"
|
||||
weight = 50 # 50% of the requests will go to that instance
|
||||
```
|
||||
|
||||
#### Servers
|
||||
|
||||
Servers declare a single instance of your program.
|
||||
The `url` option point to a specific instance.
|
||||
The `weight` option defines the weight of the server for the load balancing algorithm.
|
||||
|
||||
!!! note
|
||||
Paths in the servers' `url` have no effet.
|
||||
|
@ -80,28 +73,21 @@ The `weight` option defines the weight of the server for the load balancing algo
|
|||
[http.services.my-service.LoadBalancer]
|
||||
[[http.services.my-service.LoadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
weight = 1
|
||||
```
|
||||
|
||||
#### Load-balancing
|
||||
|
||||
Various methods of load balancing are supported:
|
||||
For now, only round robin load balancing is supported:
|
||||
|
||||
- `wrr`: Weighted Round Robin.
|
||||
- `drr`: Dynamic Round Robin: increases weights on servers that perform better than others (rolls back to original weights when the server list is updated)
|
||||
|
||||
??? example "Load Balancing Using DRR -- Using the [File Provider](../../providers/file.md)"
|
||||
??? example "Load Balancing -- Using the [File Provider](../../providers/file.md)"
|
||||
|
||||
```toml
|
||||
[http.services]
|
||||
[http.services.my-service.LoadBalancer]
|
||||
method = "drr"
|
||||
[[http.services.my-service.LoadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
weight = 1
|
||||
[[http.services.my-service.LoadBalancer.servers]]
|
||||
url = "http://private-ip-server-1/"
|
||||
weight = 1
|
||||
```
|
||||
|
||||
#### Sticky sessions
|
||||
|
@ -239,7 +225,3 @@ The `address` option (IP:Port) point to a specific instance.
|
|||
[[tcp.services.my-service.LoadBalancer.servers]]
|
||||
address = "xx.xx.xx.xx:xx"
|
||||
```
|
||||
|
||||
!!! note "Weight"
|
||||
|
||||
The TCP LoadBalancer is currently a round robin only implementation and doesn't yet support weights.
|
Loading…
Add table
Add a link
Reference in a new issue