Merge tag 'v1.4.0-rc3' into master
This commit is contained in:
commit
2cbf9cae71
93 changed files with 2772 additions and 1141 deletions
|
@ -10,10 +10,14 @@ import (
|
|||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/safe"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
rancher "github.com/rancher/go-rancher/client"
|
||||
)
|
||||
|
||||
const labelRancheStackServiceName = "io.rancher.stack_service.name"
|
||||
const (
|
||||
labelRancherStackServiceName = "io.rancher.stack_service.name"
|
||||
hostNetwork = "host"
|
||||
)
|
||||
|
||||
var withoutPagination *rancher.ListOpts
|
||||
|
||||
|
@ -221,9 +225,24 @@ func parseAPISourcedRancherData(environments []*rancher.Environment, services []
|
|||
}
|
||||
|
||||
for _, container := range containers {
|
||||
if container.Labels[labelRancheStackServiceName] == rancherData.Name &&
|
||||
if container.Labels[labelRancherStackServiceName] == rancherData.Name &&
|
||||
containerFilter(container.Name, container.HealthState, container.State) {
|
||||
rancherData.Containers = append(rancherData.Containers, container.PrimaryIpAddress)
|
||||
|
||||
if container.NetworkMode == hostNetwork {
|
||||
var endpoints []*rancher.PublicEndpoint
|
||||
err := mapstructure.Decode(service.PublicEndpoints, &endpoints)
|
||||
|
||||
if err != nil {
|
||||
log.Errorf("Failed to decode PublicEndpoint: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if len(endpoints) > 0 {
|
||||
rancherData.Containers = append(rancherData.Containers, endpoints[0].IpAddress)
|
||||
}
|
||||
} else {
|
||||
rancherData.Containers = append(rancherData.Containers, container.PrimaryIpAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
rancherDataList = append(rancherDataList, rancherData)
|
||||
|
|
|
@ -38,13 +38,13 @@ func (p *Provider) metadataProvide(configurationChan chan<- types.ConfigMessage,
|
|||
updateConfiguration := func(version string) {
|
||||
log.WithField("metadata_version", version).Debugln("Refreshing configuration from Rancher metadata service")
|
||||
|
||||
services, err := client.GetServices()
|
||||
stacks, err := client.GetStacks()
|
||||
if err != nil {
|
||||
log.Errorf("Failed to query Rancher metadata service: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
rancherData := parseMetadataSourcedRancherData(services)
|
||||
rancherData := parseMetadataSourcedRancherData(stacks)
|
||||
configuration := p.loadRancherConfig(rancherData)
|
||||
configurationChan <- types.ConfigMessage{
|
||||
ProviderName: "rancher",
|
||||
|
@ -118,21 +118,23 @@ func (p *Provider) longPoll(client rancher.Client, updateConfiguration func(stri
|
|||
<-stop
|
||||
}
|
||||
|
||||
func parseMetadataSourcedRancherData(services []rancher.Service) (rancherDataList []rancherData) {
|
||||
for _, service := range services {
|
||||
var containerIPAddresses []string
|
||||
for _, container := range service.Containers {
|
||||
if containerFilter(container.Name, container.HealthState, container.State) {
|
||||
containerIPAddresses = append(containerIPAddresses, container.PrimaryIp)
|
||||
func parseMetadataSourcedRancherData(stacks []rancher.Stack) (rancherDataList []rancherData) {
|
||||
for _, stack := range stacks {
|
||||
for _, service := range stack.Services {
|
||||
var containerIPAddresses []string
|
||||
for _, container := range service.Containers {
|
||||
if containerFilter(container.Name, container.HealthState, container.State) {
|
||||
containerIPAddresses = append(containerIPAddresses, container.PrimaryIp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rancherDataList = append(rancherDataList, rancherData{
|
||||
Name: service.Name,
|
||||
State: service.State,
|
||||
Labels: service.Labels,
|
||||
Containers: containerIPAddresses,
|
||||
})
|
||||
rancherDataList = append(rancherDataList, rancherData{
|
||||
Name: stack.Name + "/" + service.Name,
|
||||
State: service.State,
|
||||
Labels: service.Labels,
|
||||
Containers: containerIPAddresses,
|
||||
})
|
||||
}
|
||||
}
|
||||
return rancherDataList
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/containous/traefik/autogen"
|
||||
"github.com/containous/traefik/log"
|
||||
"github.com/containous/traefik/middlewares"
|
||||
mauth "github.com/containous/traefik/middlewares/auth"
|
||||
"github.com/containous/traefik/safe"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/containous/traefik/version"
|
||||
|
@ -135,7 +136,7 @@ func (provider *Provider) Provide(configurationChan chan<- types.ConfigMessage,
|
|||
var err error
|
||||
var negroniInstance = negroni.New()
|
||||
if provider.Auth != nil {
|
||||
authMiddleware, err := middlewares.NewAuthenticator(provider.Auth)
|
||||
authMiddleware, err := mauth.NewAuthenticator(provider.Auth)
|
||||
if err != nil {
|
||||
log.Fatal("Error creating Auth: ", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue