Skip to content

Commit

Permalink
[Fix] Reuse registry in multicluster (fixes #485,@kuritka) (#486, @ku…
Browse files Browse the repository at this point in the history
  • Loading branch information
kuritka authored Feb 9, 2021
1 parent 78c22f7 commit 76fc9eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/runtimes/docker/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ func GetGatewayIP(ctx context.Context, network string) (net.IP, error) {

// ConnectNodeToNetwork connects a node to a network
func (d Docker) ConnectNodeToNetwork(ctx context.Context, node *k3d.Node, networkName string) error {
// check that node was not attached to network before
if isAttachedToNetwork(node, networkName) {
log.Infof("Container '%s' is already connected to '%s'", node.Name,networkName)
return nil
}

// get container
container, err := getNodeContainer(ctx, node)
if err != nil {
Expand Down
11 changes: 11 additions & 0 deletions pkg/runtimes/docker/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func (d Docker) WriteToNode(ctx context.Context, content []byte, dest string, no
return nil
}


// GetDockerClient returns a docker client
func GetDockerClient() (*client.Client, error) {
var err error
Expand Down Expand Up @@ -168,3 +169,13 @@ func GetDockerClient() (*client.Client, error) {

return cli, err
}

// isAttachedToNetwork return true if node is attached to network
func isAttachedToNetwork(node *k3d.Node, network string) bool {
for _, nw := range node.Networks {
if nw == network {
return true
}
}
return false
}

0 comments on commit 76fc9eb

Please sign in to comment.