Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow skip ingress network #1

Open
wants to merge 1 commit into
base: swarm-mode
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ Usage of /bin/registrator:
-tags="": Append tags for all registered services
-ttl=0: TTL for services (default is no expiry)
-ttl-refresh=0: Frequency with which service TTLs are refreshed
-swarm-manager-servicename="": Register swarm manager service when non-empty
-swarm-replicas-aware=true: Remove registered swarm services without replicas (default true)
-swarm-skip-internal-ingress=false: Skip ingress network for internal mode
```

## Contributing
Expand Down
15 changes: 14 additions & 1 deletion bridge/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,20 @@ func (b *Bridge) newService(port ServicePort, isgroup bool) []*Service {
var p int

if b.config.Internal == true {
service.IP = port.ExposedIP
exists := false
if b.config.SwarmSkipIntIngress {
for name, network := range container.NetworkSettings.Networks {
if name != "ingress" {
exists = true
service.IP = network.IPAddress
log.Printf("service %s will use network %s", service.Name, name)
break
}
}
}
if !exists {
service.IP = port.ExposedIP
}
p, _ = strconv.Atoi(port.ExposedPort)
} else {
service.IP = port.HostIP
Expand Down
1 change: 1 addition & 0 deletions bridge/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type Config struct {
Cleanup bool
SwarmReplicasAware bool
SwarmManagerSvcName string
SwarmSkipIntIngress bool
}

type Service struct {
Expand Down
2 changes: 2 additions & 0 deletions registrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var retryInterval = flag.Int("retry-interval", 2000, "Interval (in millisecond)
var cleanup = flag.Bool("cleanup", false, "Remove dangling services")
var swarmReplicasAware = flag.Bool("swarm-replicas-aware", true, "Remove registered swarm services without replicas")
var swarmManagerSvcName = flag.String("swarm-manager-servicename", "", "Register swarm manager service when non-empty")
var swarmSkipIntIngress = flag.Bool("swarm-skip-internal-ingress", false, "Skip ingress network for internal mode")

func getopt(name, def string) string {
if env := os.Getenv(name); env != "" {
Expand Down Expand Up @@ -155,6 +156,7 @@ func main() {
Cleanup: *cleanup,
SwarmReplicasAware: *swarmReplicasAware,
SwarmManagerSvcName: *swarmManagerSvcName,
SwarmSkipIntIngress: *swarmSkipIntIngress,
})

assert(err)
Expand Down