Skip to content

Commit

Permalink
experimentally allow custom networks
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTheElder committed Apr 30, 2020
1 parent a358f0b commit 1a5d820
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions pkg/cluster/internal/providers/docker/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,37 @@ import (
"encoding/binary"
"errors"
"net"
"os"
"regexp"
"strings"

"sigs.k8s.io/kind/pkg/exec"
"sigs.k8s.io/kind/pkg/log"
)

// TODO: we'll probably allow configuring this
// This may be overridden by KIND_EXPERIMENTAL_DOCKER_NETWORK env,
// experimentally...
//
// however currently picking a single network is equivalent to the previous
// By default currently picking a single network is equivalent to the previous
// behavior *except* that we moved from the default bridge to a user defined
// network because the default bridge is actually special versus any other
// docker network and lacks the emebdded DNS
//
// for now this also makes it easier for apps to join the same network
// For now this also makes it easier for apps to join the same network, and
// leaves users with complex networking desires to create and manage their own
// networks.
const fixedNetworkName = "kind"

func ensureKindNetwork(logger log.Logger) error {
name := fixedNetworkName
if n, set := os.LookupEnv("KIND_EXPERIMENTAL_DOCKER_NETWORK"); set {
logger.Warn("WARNING: Overriding docker network due to KIND_EXPERIMENTAL_DOCKER_NETWORK")
logger.Warn("WARNING: Here be dragons! This is not supported currently.")
name = n
}
return ensureNetwork(name)
}

// ensureNetwork checks if docker network by name exists, if not it creates it
func ensureNetwork(name string) error {
// TODO: the network might already exist and not have ipv6 ... :|
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/internal/providers/docker/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p *Provider) Provision(status *cli.Status, cluster string, cfg *config.Clu
return err
}

if err := ensureNetwork(fixedNetworkName); err != nil {
if err := ensureKindNetwork(p.logger); err != nil {
return errors.Wrap(err, "failed to ensure docker network")
}

Expand Down

0 comments on commit 1a5d820

Please sign in to comment.