Allow binding ECS container port
This commit is contained in:
parent
12c713b187
commit
0d262561d1
5 changed files with 89 additions and 28 deletions
|
@ -68,7 +68,7 @@ func (p *Provider) filterInstance(i ecsInstance) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if labelPort := label.GetStringValue(i.TraefikLabels, label.TraefikPort, ""); i.machine.port == 0 && labelPort == "" {
|
||||
if labelPort := label.GetStringValue(i.TraefikLabels, label.TraefikPort, ""); len(i.machine.ports) == 0 && labelPort == "" {
|
||||
log.Debugf("Filtering ecs instance without port %s (%s)", i.Name, i.ID)
|
||||
return false
|
||||
}
|
||||
|
@ -119,9 +119,17 @@ func getHost(i ecsInstance) string {
|
|||
|
||||
func getPort(i ecsInstance) string {
|
||||
if value := label.GetStringValue(i.TraefikLabels, label.TraefikPort, ""); len(value) > 0 {
|
||||
return value
|
||||
port, err := strconv.ParseInt(value, 10, 64)
|
||||
if err == nil {
|
||||
for _, mapping := range i.machine.ports {
|
||||
if port == mapping.hostPort || port == mapping.containerPort {
|
||||
return strconv.FormatInt(mapping.hostPort, 10)
|
||||
}
|
||||
}
|
||||
return value
|
||||
}
|
||||
}
|
||||
return strconv.FormatInt(i.machine.port, 10)
|
||||
return strconv.FormatInt(i.machine.ports[0].hostPort, 10)
|
||||
}
|
||||
|
||||
func filterFrontends(instances []ecsInstance) []ecsInstance {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue