1
0
Fork 0

rework loadbalancer support

This commit is contained in:
Julien Salleyron 2019-06-05 22:18:06 +02:00 committed by Traefiker Bot
parent b143101f82
commit 518a37e776
86 changed files with 339 additions and 1055 deletions

View file

@ -78,7 +78,6 @@ func (p *Provider) buildTCPServiceConfiguration(ctx context.Context, container d
if len(configuration.Services) == 0 {
configuration.Services = make(map[string]*config.TCPService)
lb := &config.TCPLoadBalancerService{}
lb.SetDefaults()
configuration.Services[serviceName] = &config.TCPService{
LoadBalancer: lb,
}
@ -151,7 +150,6 @@ func (p *Provider) addServerTCP(ctx context.Context, container dockerData, loadB
if len(loadBalancer.Servers) == 0 {
server := config.TCPServer{}
server.SetDefaults()
loadBalancer.Servers = []config.TCPServer{server}
}

View file

@ -60,11 +60,9 @@ func TestDefaultRule(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -111,11 +109,9 @@ func TestDefaultRule(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -164,11 +160,9 @@ func TestDefaultRule(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -210,11 +204,9 @@ func TestDefaultRule(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -256,11 +248,9 @@ func TestDefaultRule(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -307,11 +297,9 @@ func TestDefaultRule(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -392,11 +380,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -462,11 +448,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -474,11 +458,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -542,15 +524,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -565,7 +544,7 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -598,11 +577,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "drr",
PassHostHeader: true,
},
},
@ -617,9 +594,9 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "wrr",
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.routers.Router1.service": "Service1",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.routers.Router1.service": "Service1",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -652,11 +629,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -698,11 +673,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -723,8 +696,8 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.services.Service1.loadbalancer.method": "wrr",
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -757,11 +730,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -776,9 +747,9 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.services.Service1.loadbalancer.method": "wrr",
"traefik.http.services.Service2.loadbalancer.method": "wrr",
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
"traefik.http.services.Service2.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -806,11 +777,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -818,11 +787,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -831,14 +798,14 @@ func Test_buildConfiguration(t *testing.T) {
},
},
{
desc: "two containers with same service name and different LB methods",
desc: "two containers with same service name and different passhostheader",
containers: []dockerData{
{
ID: "1",
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -857,7 +824,7 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "wrr",
"traefik.http.services.Service1.loadbalancer.passhostheader": "false",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -890,14 +857,14 @@ func Test_buildConfiguration(t *testing.T) {
},
},
{
desc: "three containers with same service name and different LB methods",
desc: "three containers with same service name and different passhostheader",
containers: []dockerData{
{
ID: "1",
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.http.services.Service1.loadbalancer.passhostheader": "false",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -916,7 +883,7 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "wrr",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -935,7 +902,7 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "foo",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -975,7 +942,7 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -994,7 +961,7 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -1027,15 +994,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "drr",
PassHostHeader: true,
},
},
@ -1082,11 +1046,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1169,15 +1131,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1245,15 +1204,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1340,19 +1296,15 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
{
URL: "http://127.0.0.3:80",
Weight: 1,
URL: "http://127.0.0.3:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1415,15 +1367,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1505,19 +1454,15 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
{
URL: "http://127.0.0.3:80",
Weight: 1,
URL: "http://127.0.0.3:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1585,15 +1530,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1654,11 +1596,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1666,11 +1606,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1718,11 +1656,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1771,11 +1707,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "h2c://127.0.0.1:8080",
Weight: 1,
URL: "h2c://127.0.0.1:8080",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1819,11 +1753,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1831,11 +1763,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:8080",
Weight: 1,
URL: "http://127.0.0.1:8080",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -2060,11 +1990,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -2123,11 +2051,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -2173,10 +2099,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:80",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -2219,10 +2143,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:80",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -2273,10 +2195,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -2295,10 +2215,10 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
"traefik.tcp.routers.foo.tls": "true",
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
"traefik.tcp.routers.foo.tls": "true",
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -2317,10 +2237,10 @@ func Test_buildConfiguration(t *testing.T) {
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
"traefik.tcp.routers.foo.tls": "true",
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
"traefik.tcp.routers.foo.tls": "true",
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
@ -2350,14 +2270,11 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:8080",
Weight: 1,
},
{
Address: "127.0.0.2:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -2375,15 +2292,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "drr",
PassHostHeader: true,
},
},
@ -2422,10 +2336,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},

View file

@ -191,7 +191,6 @@ func getTestCases() []ProvideTestCase {
[http.services.application-{{ $e }}]
[[http.services.application-{{ $e }}.servers]]
url="http://127.0.0.1"
weight = 1
{{ end }}
`,
},
@ -318,7 +317,6 @@ func createServicesConfiguration(n int) string {
[http.services.application-%[1]d.loadbalancer]
[[http.services.application-%[1]d.loadbalancer.servers]]
url = "http://172.17.0.%[1]d:80"
weight = 1
`, i)
}
return conf

View file

@ -187,8 +187,7 @@ func loadServers(client Client, namespace string, svc v1alpha1.Service) ([]confi
var servers []config.Server
if service.Spec.Type == corev1.ServiceTypeExternalName {
servers = append(servers, config.Server{
URL: fmt.Sprintf("http://%s:%d", service.Spec.ExternalName, portSpec.Port),
Weight: 1,
URL: fmt.Sprintf("http://%s:%d", service.Spec.ExternalName, portSpec.Port),
})
} else {
endpoints, endpointsExists, endpointsErr := client.GetEndpoints(namespace, svc.Name)
@ -224,8 +223,7 @@ func loadServers(client Client, namespace string, svc v1alpha1.Service) ([]confi
for _, addr := range subset.Addresses {
servers = append(servers, config.Server{
URL: fmt.Sprintf("%s://%s:%d", protocol, addr.IP, port),
Weight: 1,
URL: fmt.Sprintf("%s://%s:%d", protocol, addr.IP, port),
})
}
}
@ -332,7 +330,6 @@ func (p *Provider) loadConfigurationFromIngresses(ctx context.Context, client Cl
LoadBalancer: &config.LoadBalancerService{
Servers: allServers,
// TODO: support other strategies.
Method: "wrr",
PassHostHeader: true,
},
}

View file

@ -50,15 +50,12 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://10.10.0.1:80",
Weight: 1,
URL: "http://10.10.0.1:80",
},
{
URL: "http://10.10.0.2:80",
Weight: 1,
URL: "http://10.10.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -98,15 +95,12 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://10.10.0.1:80",
Weight: 1,
URL: "http://10.10.0.1:80",
},
{
URL: "http://10.10.0.2:80",
Weight: 1,
URL: "http://10.10.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -140,15 +134,12 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://10.10.0.1:80",
Weight: 1,
URL: "http://10.10.0.1:80",
},
{
URL: "http://10.10.0.2:80",
Weight: 1,
URL: "http://10.10.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -156,15 +147,12 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://10.10.0.1:80",
Weight: 1,
URL: "http://10.10.0.1:80",
},
{
URL: "http://10.10.0.2:80",
Weight: 1,
URL: "http://10.10.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -192,23 +180,18 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://10.10.0.1:80",
Weight: 1,
URL: "http://10.10.0.1:80",
},
{
URL: "http://10.10.0.2:80",
Weight: 1,
URL: "http://10.10.0.2:80",
},
{
URL: "http://10.10.0.3:8080",
Weight: 1,
URL: "http://10.10.0.3:8080",
},
{
URL: "http://10.10.0.4:8080",
Weight: 1,
URL: "http://10.10.0.4:8080",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -294,15 +277,12 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://10.10.0.1:80",
Weight: 1,
URL: "http://10.10.0.1:80",
},
{
URL: "http://10.10.0.2:80",
Weight: 1,
URL: "http://10.10.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -331,15 +311,12 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://10.10.0.1:80",
Weight: 1,
URL: "http://10.10.0.1:80",
},
{
URL: "http://10.10.0.2:80",
Weight: 1,
URL: "http://10.10.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -367,15 +344,12 @@ func TestLoadIngressRoutes(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "https://10.10.0.5:443",
Weight: 1,
URL: "https://10.10.0.5:443",
},
{
URL: "https://10.10.0.6:443",
Weight: 1,
URL: "https://10.10.0.6:443",
},
},
Method: "wrr",
PassHostHeader: true,
},
},

View file

@ -31,9 +31,8 @@ type TLS struct {
// Service defines an upstream to proxy traffic.
type Service struct {
Name string `json:"name"`
Port int32 `json:"port"`
// TODO Weight int `json:"weight,omitempty"`
Name string `json:"name"`
Port int32 `json:"port"`
HealthCheck *HealthCheck `json:"healthCheck,omitempty"`
Strategy string `json:"strategy,omitempty"`
}

View file

@ -195,8 +195,7 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
if service.Spec.Type == corev1.ServiceTypeExternalName {
servers = append(servers, config.Server{
URL: fmt.Sprintf("http://%s:%d", service.Spec.ExternalName, portSpec.Port),
Weight: 1,
URL: fmt.Sprintf("http://%s:%d", service.Spec.ExternalName, portSpec.Port),
})
} else {
endpoints, endpointsExists, endpointsErr := client.GetEndpoints(namespace, backend.ServiceName)
@ -233,8 +232,7 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
for _, addr := range subset.Addresses {
servers = append(servers, config.Server{
URL: fmt.Sprintf("%s://%s:%d", protocol, addr.IP, port),
Weight: 1,
URL: fmt.Sprintf("%s://%s:%d", protocol, addr.IP, port),
})
}
}
@ -243,7 +241,6 @@ func loadService(client Client, namespace string, backend v1beta1.IngressBackend
return &config.Service{
LoadBalancer: &config.LoadBalancerService{
Servers: servers,
Method: "wrr",
PassHostHeader: true,
},
}, nil

View file

@ -51,16 +51,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -88,16 +85,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -125,16 +119,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -158,16 +149,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -190,12 +178,10 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/example-com/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.11.0.1:80",
Weight: 1,
URL: "http://10.11.0.1:80",
},
},
},
@ -223,16 +209,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -260,16 +243,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -297,16 +277,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -341,16 +318,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -389,32 +363,26 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
},
"testing/service2/8082": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.2:8080",
Weight: 1,
URL: "http://10.10.0.2:8080",
},
{
URL: "http://10.21.0.2:8080",
Weight: 1,
URL: "http://10.21.0.2:8080",
},
},
},
@ -461,16 +429,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"default-backend": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
{
URL: "http://10.21.0.1:8080",
Weight: 1,
URL: "http://10.21.0.1:8080",
},
},
},
@ -494,16 +459,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8089",
Weight: 1,
URL: "http://10.10.0.1:8089",
},
{
URL: "http://10.21.0.1:8089",
Weight: 1,
URL: "http://10.21.0.1:8089",
},
},
},
@ -527,16 +489,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/tchouk": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8089",
Weight: 1,
URL: "http://10.10.0.1:8089",
},
{
URL: "http://10.21.0.1:8089",
Weight: 1,
URL: "http://10.21.0.1:8089",
},
},
},
@ -560,16 +519,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/tchouk": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8089",
Weight: 1,
URL: "http://10.10.0.1:8089",
},
{
URL: "http://10.10.0.2:8089",
Weight: 1,
URL: "http://10.10.0.2:8089",
},
},
},
@ -597,32 +553,26 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/tchouk": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8089",
Weight: 1,
URL: "http://10.10.0.1:8089",
},
{
URL: "http://10.10.0.2:8089",
Weight: 1,
URL: "http://10.10.0.2:8089",
},
},
},
},
"testing/service1/carotte": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8090",
Weight: 1,
URL: "http://10.10.0.1:8090",
},
{
URL: "http://10.10.0.2:8090",
Weight: 1,
URL: "http://10.10.0.2:8090",
},
},
},
@ -650,32 +600,26 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/tchouk": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8089",
Weight: 1,
URL: "http://10.10.0.1:8089",
},
{
URL: "http://10.10.0.2:8089",
Weight: 1,
URL: "http://10.10.0.2:8089",
},
},
},
},
"toto/service1/tchouk": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.11.0.1:8089",
Weight: 1,
URL: "http://10.11.0.1:8089",
},
{
URL: "http://10.11.0.2:8089",
Weight: 1,
URL: "http://10.11.0.2:8089",
},
},
},
@ -721,12 +665,10 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/8080": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://traefik.wtf:8080",
Weight: 1,
URL: "http://traefik.wtf:8080",
},
},
},
@ -750,12 +692,10 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/example-com/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.11.0.1:80",
Weight: 1,
URL: "http://10.11.0.1:80",
},
},
},
@ -787,16 +727,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/443": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "https://10.10.0.1:443",
Weight: 1,
URL: "https://10.10.0.1:443",
},
{
URL: "https://10.21.0.1:443",
Weight: 1,
URL: "https://10.21.0.1:443",
},
},
},
@ -820,16 +757,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/8443": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "https://10.10.0.1:8443",
Weight: 1,
URL: "https://10.10.0.1:8443",
},
{
URL: "https://10.21.0.1:8443",
Weight: 1,
URL: "https://10.21.0.1:8443",
},
},
},
@ -854,16 +788,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/8443": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "https://10.10.0.1:8443",
Weight: 1,
URL: "https://10.10.0.1:8443",
},
{
URL: "https://10.21.0.1:8443",
Weight: 1,
URL: "https://10.21.0.1:8443",
},
},
},
@ -888,16 +819,13 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"default-backend": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.30.0.1:8080",
Weight: 1,
URL: "http://10.30.0.1:8080",
},
{
URL: "http://10.41.0.1:8080",
Weight: 1,
URL: "http://10.41.0.1:8080",
},
},
},
@ -921,12 +849,10 @@ func TestLoadConfigurationFromIngresses(t *testing.T) {
Services: map[string]*config.Service{
"testing/service1/80": {
LoadBalancer: &config.LoadBalancerService{
Method: "wrr",
PassHostHeader: true,
Servers: []config.Server{
{
URL: "http://10.10.0.1:8080",
Weight: 1,
URL: "http://10.10.0.1:8080",
},
},
},

View file

@ -138,12 +138,10 @@ func TestDecodeConfiguration(t *testing.T) {
"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.scheme": "foobar",
"traefik.http.services.Service0.loadbalancer.server.port": "8080",
"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",
@ -153,7 +151,6 @@ func TestDecodeConfiguration(t *testing.T) {
"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.scheme": "foobar",
@ -168,12 +165,8 @@ func TestDecodeConfiguration(t *testing.T) {
"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",
}
configuration, err := DecodeConfiguration(labels)
@ -210,22 +203,18 @@ func TestDecodeConfiguration(t *testing.T) {
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
{
Port: "42",
Weight: 42,
Port: "42",
},
},
Method: "foobar",
},
},
"Service1": {
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
{
Port: "42",
Weight: 42,
Port: "42",
},
},
Method: "foobar",
},
},
},
@ -522,10 +511,8 @@ func TestDecodeConfiguration(t *testing.T) {
{
Scheme: "foobar",
Port: "8080",
Weight: 42,
},
},
Method: "foobar",
HealthCheck: &config.HealthCheck{
Scheme: "foobar",
Path: "foobar",
@ -550,10 +537,8 @@ func TestDecodeConfiguration(t *testing.T) {
{
Scheme: "foobar",
Port: "8080",
Weight: 1,
},
},
Method: "foobar",
HealthCheck: &config.HealthCheck{
Scheme: "foobar",
Path: "foobar",
@ -611,22 +596,18 @@ func TestEncodeConfiguration(t *testing.T) {
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
{
Port: "42",
Weight: 42,
Port: "42",
},
},
Method: "foobar",
},
},
"Service1": {
LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{
{
Port: "42",
Weight: 42,
Port: "42",
},
},
Method: "foobar",
},
},
},
@ -922,10 +903,8 @@ func TestEncodeConfiguration(t *testing.T) {
{
Scheme: "foobar",
Port: "8080",
Weight: 42,
},
},
Method: "foobar",
HealthCheck: &config.HealthCheck{
Scheme: "foobar",
Path: "foobar",
@ -950,10 +929,8 @@ func TestEncodeConfiguration(t *testing.T) {
{
Scheme: "foobar",
Port: "8080",
Weight: 42,
},
},
Method: "foobar",
HealthCheck: &config.HealthCheck{
Scheme: "foobar",
Path: "foobar",
@ -1104,12 +1081,10 @@ func TestEncodeConfiguration(t *testing.T) {
"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",
@ -1119,28 +1094,22 @@ func TestEncodeConfiguration(t *testing.T) {
"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.Service0.LoadBalancer.HealthCheck.Headers.name0": "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",
"traefik.TCP.Routers.Router0.TLS.Passthrough": "false",
"traefik.TCP.Routers.Router1.Rule": "foobar",
"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",
"traefik.TCP.Routers.Router0.Rule": "foobar",
"traefik.TCP.Routers.Router0.EntryPoints": "foobar, fiibar",
"traefik.TCP.Routers.Router0.Service": "foobar",
"traefik.TCP.Routers.Router0.TLS.Passthrough": "false",
"traefik.TCP.Routers.Router1.Rule": "foobar",
"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.server.Port": "42",
"traefik.TCP.Services.Service1.LoadBalancer.server.Port": "42",
}
for key, val := range expected {

View file

@ -131,7 +131,6 @@ func (p *Provider) buildTCPServiceConfiguration(ctx context.Context, app maratho
if len(conf.Services) == 0 {
conf.Services = make(map[string]*config.TCPService)
lb := &config.TCPLoadBalancerService{}
lb.SetDefaults()
conf.Services[appName] = &config.TCPService{
LoadBalancer: lb,
}
@ -141,7 +140,6 @@ func (p *Provider) buildTCPServiceConfiguration(ctx context.Context, app maratho
var servers []config.TCPServer
defaultServer := config.TCPServer{}
defaultServer.SetDefaults()
if len(service.LoadBalancer.Servers) > 0 {
defaultServer = service.LoadBalancer.Servers[0]
@ -212,7 +210,6 @@ func (p *Provider) getTCPServer(app marathon.Application, task marathon.Task, ex
server := config.TCPServer{
Address: net.JoinHostPort(host, port),
Weight: 1,
}
return server, nil
@ -230,8 +227,7 @@ func (p *Provider) getServer(app marathon.Application, task marathon.Task, extra
}
server := config.Server{
URL: fmt.Sprintf("%s://%s", defaultServer.Scheme, net.JoinHostPort(host, port)),
Weight: 1,
URL: fmt.Sprintf("%s://%s", defaultServer.Scheme, net.JoinHostPort(host, port)),
}
return server, nil

View file

@ -61,11 +61,9 @@ func TestBuildConfiguration(t *testing.T) {
"app": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
}},
},
@ -117,11 +115,9 @@ func TestBuildConfiguration(t *testing.T) {
"app": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
}},
},
@ -165,11 +161,9 @@ func TestBuildConfiguration(t *testing.T) {
"app": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
}},
},
@ -211,15 +205,12 @@ func TestBuildConfiguration(t *testing.T) {
"Service1": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:8080",
Weight: 1,
URL: "http://localhost:8080",
},
{
URL: "http://localhost:8081",
Weight: 1,
URL: "http://localhost:8081",
},
},
Method: "wrr",
PassHostHeader: true,
}},
},
@ -263,23 +254,18 @@ func TestBuildConfiguration(t *testing.T) {
"Service1": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:8080",
Weight: 1,
URL: "http://localhost:8080",
},
{
URL: "http://localhost:8081",
Weight: 1,
URL: "http://localhost:8081",
},
{
URL: "http://localhost:8082",
Weight: 1,
URL: "http://localhost:8082",
},
{
URL: "http://localhost:8083",
Weight: 1,
URL: "http://localhost:8083",
},
},
Method: "wrr",
PassHostHeader: true,
}},
},
@ -319,21 +305,17 @@ func TestBuildConfiguration(t *testing.T) {
"foo": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:8080",
Weight: 1,
URL: "http://localhost:8080",
},
},
Method: "wrr",
PassHostHeader: true,
}},
"bar": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:8081",
Weight: 1,
URL: "http://localhost:8081",
},
},
Method: "wrr",
PassHostHeader: true,
}},
},
@ -366,15 +348,12 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
{
URL: "http://localhost:81",
Weight: 1,
URL: "http://localhost:81",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -389,7 +368,7 @@ func TestBuildConfiguration(t *testing.T) {
appID("/app"),
appPorts(80),
withTasks(localhostTask(taskPorts(80))),
withLabel("traefik.http.services.Service1.loadbalancer.method", "drr"),
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
)),
expected: &config.Configuration{
TCP: &config.TCPConfiguration{
@ -408,11 +387,9 @@ func TestBuildConfiguration(t *testing.T) {
"Service1": {LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "drr",
PassHostHeader: true,
}},
},
@ -426,7 +403,7 @@ func TestBuildConfiguration(t *testing.T) {
appID("/app"),
appPorts(80, 81),
withTasks(localhostTask(taskPorts(80, 81))),
withLabel("traefik.http.services.Service1.loadbalancer.method", "wrr"),
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
withLabel("traefik.http.routers.Router1.service", "Service1"),
)),
@ -448,11 +425,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -481,11 +456,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -507,7 +480,7 @@ func TestBuildConfiguration(t *testing.T) {
appPorts(80, 81),
withTasks(localhostTask(taskPorts(80, 81))),
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
withLabel("traefik.http.services.Service1.loadbalancer.method", "wrr"),
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
)),
expected: &config.Configuration{
TCP: &config.TCPConfiguration{
@ -527,11 +500,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -547,8 +518,8 @@ func TestBuildConfiguration(t *testing.T) {
appPorts(80, 81),
withTasks(localhostTask(taskPorts(80, 81))),
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
withLabel("traefik.http.services.Service1.loadbalancer.method", "wrr"),
withLabel("traefik.http.services.Service2.loadbalancer.method", "wrr"),
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
withLabel("traefik.http.services.Service2.loadbalancer.passhostheader", "true"),
)),
expected: &config.Configuration{
TCP: &config.TCPConfiguration{
@ -563,11 +534,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -575,11 +544,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -588,19 +555,19 @@ func TestBuildConfiguration(t *testing.T) {
},
},
{
desc: "two apps with same service name and different LB methods",
desc: "two apps with same service name and different passhostheader",
applications: withApplications(
application(
appID("/app"),
appPorts(80, 81),
withTasks(localhostTask(taskPorts(80, 81))),
withLabel("traefik.http.services.Service1.loadbalancer.method", "wrr"),
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "false"),
),
application(
appID("/app2"),
appPorts(80, 81),
withTasks(localhostTask(taskPorts(80, 81))),
withLabel("traefik.http.services.Service1.loadbalancer.method", "drr"),
withLabel("traefik.http.services.Service1.loadbalancer.passhostheader", "true"),
)),
expected: &config.Configuration{
TCP: &config.TCPConfiguration{
@ -667,11 +634,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -679,11 +644,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -728,11 +691,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -740,11 +701,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -780,11 +739,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -792,11 +749,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -812,14 +767,14 @@ func TestBuildConfiguration(t *testing.T) {
appPorts(80, 81),
withTasks(localhostTask(taskPorts(80, 81))),
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
withLabel("traefik.http.services.Service1.LoadBalancer.method", "wrr"),
withLabel("traefik.http.services.Service1.LoadBalancer.passhostheader", "true"),
),
application(
appID("/app2"),
appPorts(80, 81),
withTasks(localhostTask(taskPorts(80, 81))),
withLabel("traefik.http.routers.Router1.rule", "Host(`foo.com`)"),
withLabel("traefik.http.services.Service1.LoadBalancer.method", "wrr"),
withLabel("traefik.http.services.Service1.LoadBalancer.passhostheader", "true"),
)),
expected: &config.Configuration{
TCP: &config.TCPConfiguration{
@ -839,15 +794,12 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -883,11 +835,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -895,11 +845,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -934,11 +882,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -974,11 +920,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "h2c://localhost:90",
Weight: 1,
URL: "h2c://localhost:90",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1009,11 +953,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1021,11 +963,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:8080",
Weight: 1,
URL: "http://localhost:8080",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1208,11 +1148,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1255,11 +1193,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1294,11 +1230,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -1331,10 +1265,8 @@ func TestBuildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "localhost:80",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -1364,10 +1296,8 @@ func TestBuildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "localhost:80",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -1405,10 +1335,8 @@ func TestBuildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "localhost:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -1430,7 +1358,7 @@ func TestBuildConfiguration(t *testing.T) {
withLabel("traefik.tcp.routers.foo.rule", "HostSNI(`foo.bar`)"),
withLabel("traefik.tcp.routers.foo.tls", "true"),
withLabel("traefik.tcp.services.foo.loadbalancer.server.port", "8080"),
withLabel("traefik.http.services.bar.loadbalancer.method", "drr"),
withLabel("traefik.http.services.bar.loadbalancer.passhostheader", "true"),
)),
expected: &config.Configuration{
TCP: &config.TCPConfiguration{
@ -1447,10 +1375,8 @@ func TestBuildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "localhost:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -1468,11 +1394,9 @@ func TestBuildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
Method: "drr",
PassHostHeader: true,
},
},
@ -1591,12 +1515,10 @@ func TestGetServer(t *testing.T) {
extraConf: configuration{},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
},
@ -1611,7 +1533,6 @@ func TestGetServer(t *testing.T) {
extraConf: configuration{},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
error: "unable to process ports for /app taskID: no port found",
@ -1629,12 +1550,10 @@ func TestGetServer(t *testing.T) {
defaultServer: config.Server{
Scheme: "http",
Port: "88",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://localhost:88",
Weight: 1,
URL: "http://localhost:88",
},
},
},
@ -1650,7 +1569,6 @@ func TestGetServer(t *testing.T) {
defaultServer: config.Server{
Scheme: "http",
Port: "aaaa",
Weight: 1,
},
expected: expected{
error: `unable to process ports for /app taskID: strconv.Atoi: parsing "aaaa": invalid syntax`,
@ -1668,7 +1586,6 @@ func TestGetServer(t *testing.T) {
defaultServer: config.Server{
Scheme: "http",
Port: "-6",
Weight: 1,
},
expected: expected{
error: `unable to process ports for /app taskID: explicitly specified port -6 must be greater than zero`,
@ -1686,12 +1603,10 @@ func TestGetServer(t *testing.T) {
defaultServer: config.Server{
Scheme: "http",
Port: "index:1",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://localhost:81",
Weight: 1,
URL: "http://localhost:81",
},
},
},
@ -1707,7 +1622,6 @@ func TestGetServer(t *testing.T) {
defaultServer: config.Server{
Scheme: "http",
Port: "index:2",
Weight: 1,
},
expected: expected{
error: "unable to process ports for /app taskID: index 2 must be within range (0, 1)",
@ -1725,7 +1639,6 @@ func TestGetServer(t *testing.T) {
defaultServer: config.Server{
Scheme: "http",
Port: "index:aaa",
Weight: 1,
},
expected: expected{
error: `unable to process ports for /app taskID: strconv.Atoi: parsing "aaa": invalid syntax`,
@ -1743,12 +1656,10 @@ func TestGetServer(t *testing.T) {
extraConf: configuration{},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
},
@ -1764,12 +1675,10 @@ func TestGetServer(t *testing.T) {
extraConf: configuration{},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://127.0.0.1:88",
Weight: 1,
URL: "http://127.0.0.1:88",
},
},
},
@ -1785,12 +1694,10 @@ func TestGetServer(t *testing.T) {
extraConf: configuration{},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
},
@ -1806,12 +1713,10 @@ func TestGetServer(t *testing.T) {
extraConf: configuration{},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://localhost:80",
Weight: 1,
URL: "http://localhost:80",
},
},
},
@ -1837,12 +1742,10 @@ func TestGetServer(t *testing.T) {
},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
server: config.Server{
URL: "http://127.0.0.1:88",
Weight: 1,
URL: "http://127.0.0.1:88",
},
},
},
@ -1867,7 +1770,6 @@ func TestGetServer(t *testing.T) {
},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
error: "found 2 task IP addresses but missing IP address index for Marathon application /app on task taskID",
@ -1894,7 +1796,6 @@ func TestGetServer(t *testing.T) {
},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
error: "cannot use IP address index to select from 2 task IP addresses for Marathon application /app on task taskID",
@ -1916,7 +1817,6 @@ func TestGetServer(t *testing.T) {
extraConf: configuration{},
defaultServer: config.Server{
Scheme: "http",
Weight: 1,
},
expected: expected{
error: "missing IP address for Marathon application /app on task taskID",

View file

@ -74,7 +74,6 @@ func (p *Provider) buildTCPServiceConfiguration(ctx context.Context, service ran
if len(configuration.Services) == 0 {
configuration.Services = make(map[string]*config.TCPService)
lb := &config.TCPLoadBalancerService{}
lb.SetDefaults()
configuration.Services[serviceName] = &config.TCPService{
LoadBalancer: lb,
}
@ -155,7 +154,6 @@ func (p *Provider) addServerTCP(ctx context.Context, service rancherData, loadBa
if len(loadBalancer.Servers) == 0 {
server := config.TCPServer{}
server.SetDefaults()
loadBalancer.Servers = []config.TCPServer{server}
}
@ -173,7 +171,6 @@ func (p *Provider) addServerTCP(ctx context.Context, service rancherData, loadBa
for _, containerIP := range service.Containers {
servers = append(servers, config.TCPServer{
Address: net.JoinHostPort(containerIP, port),
Weight: 1,
})
}
@ -207,8 +204,7 @@ func (p *Provider) addServers(ctx context.Context, service rancherData, loadBala
var servers []config.Server
for _, containerIP := range service.Containers {
servers = append(servers, config.Server{
URL: fmt.Sprintf("%s://%s", loadBalancer.Servers[0].Scheme, net.JoinHostPort(containerIP, port)),
Weight: 1,
URL: fmt.Sprintf("%s://%s", loadBalancer.Servers[0].Scheme, net.JoinHostPort(containerIP, port)),
})
}

View file

@ -47,11 +47,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -101,11 +99,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -113,11 +109,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -167,15 +161,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -183,11 +174,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://128.0.0.1:80",
Weight: 1,
URL: "http://128.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -201,9 +190,9 @@ func Test_buildConfiguration(t *testing.T) {
{
Name: "Test",
Labels: map[string]string{
"traefik.http.services.Service1.loadbalancer.method": "wrr",
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.routers.Router1.service": "Service1",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.routers.Router1.service": "Service1",
},
Port: "80/tcp",
Containers: []string{"127.0.0.1"},
@ -229,11 +218,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -319,11 +306,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -403,11 +388,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -458,11 +441,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -502,11 +483,9 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
},
Method: "wrr",
PassHostHeader: true,
},
},
@ -545,10 +524,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:80",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -583,10 +560,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:80",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -629,10 +604,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -650,10 +623,10 @@ func Test_buildConfiguration(t *testing.T) {
{
Name: "Test",
Labels: map[string]string{
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
"traefik.tcp.routers.foo.tls": "true",
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
"traefik.http.services.Service1.loadbalancer.method": "drr",
"traefik.tcp.routers.foo.rule": "HostSNI(`foo.bar`)",
"traefik.tcp.routers.foo.tls": "true",
"traefik.tcp.services.foo.loadbalancer.server.port": "8080",
"traefik.http.services.Service1.loadbalancer.passhostheader": "true",
},
Port: "80/tcp",
Containers: []string{"127.0.0.1", "127.0.0.2"},
@ -676,14 +649,11 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:8080",
Weight: 1,
},
{
Address: "127.0.0.2:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},
@ -701,15 +671,12 @@ func Test_buildConfiguration(t *testing.T) {
LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{
{
URL: "http://127.0.0.1:80",
Weight: 1,
URL: "http://127.0.0.1:80",
},
{
URL: "http://127.0.0.2:80",
Weight: 1,
URL: "http://127.0.0.2:80",
},
},
Method: "drr",
PassHostHeader: true,
},
},
@ -740,10 +707,8 @@ func Test_buildConfiguration(t *testing.T) {
Servers: []config.TCPServer{
{
Address: "127.0.0.1:8080",
Weight: 1,
},
},
Method: "wrr",
},
},
},