Fix Docker integration problems
This commit is contained in:
parent
be5b1fd92b
commit
c9d4c5ae3e
3 changed files with 15 additions and 11 deletions
|
@ -252,6 +252,7 @@ func (provider *Docker) loadDockerConfig(containersInspected []dockerData) *type
|
||||||
"hasMaxConnLabels": provider.hasMaxConnLabels,
|
"hasMaxConnLabels": provider.hasMaxConnLabels,
|
||||||
"getMaxConnAmount": provider.getMaxConnAmount,
|
"getMaxConnAmount": provider.getMaxConnAmount,
|
||||||
"getMaxConnExtractorFunc": provider.getMaxConnExtractorFunc,
|
"getMaxConnExtractorFunc": provider.getMaxConnExtractorFunc,
|
||||||
|
"getSticky": provider.getSticky,
|
||||||
"replace": replace,
|
"replace": replace,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,19 +261,26 @@ func (provider *Docker) loadDockerConfig(containersInspected []dockerData) *type
|
||||||
return provider.containerFilter(container)
|
return provider.containerFilter(container)
|
||||||
}, containersInspected).([]dockerData)
|
}, containersInspected).([]dockerData)
|
||||||
|
|
||||||
|
// sticky backends
|
||||||
|
stickycontainers := map[string][]dockerData{}
|
||||||
|
|
||||||
frontends := map[string][]dockerData{}
|
frontends := map[string][]dockerData{}
|
||||||
for _, container := range filteredContainers {
|
for _, container := range filteredContainers {
|
||||||
frontendName := provider.getFrontendName(container)
|
frontendName := provider.getFrontendName(container)
|
||||||
frontends[frontendName] = append(frontends[frontendName], container)
|
frontends[frontendName] = append(frontends[frontendName], container)
|
||||||
|
frontends[frontendName] = append(frontends[frontendName], container)
|
||||||
|
stickycontainers[provider.getBackend(container)] = container
|
||||||
}
|
}
|
||||||
|
|
||||||
templateObjects := struct {
|
templateObjects := struct {
|
||||||
Containers []dockerData
|
Containers []dockerData
|
||||||
Frontends map[string][]dockerData
|
Frontends map[string][]dockerData
|
||||||
|
StickyContainers map[string][]dockerData
|
||||||
Domain string
|
Domain string
|
||||||
}{
|
}{
|
||||||
filteredContainers,
|
filteredContainers,
|
||||||
frontends,
|
frontends,
|
||||||
|
stickycontainers,
|
||||||
provider.Domain,
|
provider.Domain,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,9 +449,9 @@ func (provider *Docker) getWeight(container dockerData) string {
|
||||||
|
|
||||||
func (provider *Docker) getSticky(container dockertypes.ContainerJSON) string {
|
func (provider *Docker) getSticky(container dockertypes.ContainerJSON) string {
|
||||||
if label, err := getLabel(container, "traefik.stickysession"); err == nil {
|
if label, err := getLabel(container, "traefik.stickysession"); err == nil {
|
||||||
return true
|
return "true"
|
||||||
}
|
}
|
||||||
return false
|
return "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *Docker) getDomain(container dockerData) string {
|
func (provider *Docker) getDomain(container dockerData) string {
|
||||||
|
|
|
@ -940,7 +940,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: nil,
|
LoadBalancer: &types.LoadBalancer{Sticky: false, Method: ""},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1027,7 +1027,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
CircuitBreaker: nil,
|
CircuitBreaker: nil,
|
||||||
LoadBalancer: nil,
|
LoadBalancer: &types.LoadBalancer{Sticky: false, Method: ""},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,10 +16,6 @@
|
||||||
extractorfunc = "{{getMaxConnExtractorFunc . }}"
|
extractorfunc = "{{getMaxConnExtractorFunc . }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
[backends.backend-{{getBackend .}}.servers.server-{{.Name | replace "/" "" | replace "." "-"}}]
|
|
||||||
url = "{{getProtocol .}}://{{getIPAddress .}}:{{getPort .}}"
|
|
||||||
weight = {{getWeight .}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
[frontends]{{range $frontend, $containers := .Frontends}}
|
[frontends]{{range $frontend, $containers := .Frontends}}
|
||||||
[frontends."frontend-{{$frontend}}"]{{$container := index $containers 0}}
|
[frontends."frontend-{{$frontend}}"]{{$container := index $containers 0}}
|
||||||
|
|
Loading…
Reference in a new issue