[Fix] Reuse registry in multicluster (fixes #485,@kuritka) (#486, @kuritka)

pull/496/head
MichalK 4 years ago committed by GitHub
parent 78c22f7a0c
commit 76fc9ebed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      pkg/runtimes/docker/network.go
  2. 11
      pkg/runtimes/docker/util.go

@ -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 {

@ -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
@ -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
}

Loading…
Cancel
Save