Skip to content

Commit

Permalink
Configurable network
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 00521c4
Author: keymone <[email protected]>
Date:   Mon Oct 21 11:43:25 2019 +0100

    Allow specifying network name to use in docker provisioner
  • Loading branch information
mks-m committed Oct 24, 2019
1 parent 85a46de commit 4b98621
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/apis/config/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type Cluster struct {

/* Advanced fields */

// Network contains docker network to use in all containers
Network string `yaml:"network,omitempty" json:"network,omitempty"`

// Networking contains cluster wide network settings
Networking Networking `yaml:"networking,omitempty" json:"networking,omitempty"`

Expand Down
1 change: 1 addition & 0 deletions pkg/internal/apis/config/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func Convertv1alpha3(in *v1alpha3.Cluster) *Cluster {
in = in.DeepCopy() // deep copy first to avoid touching the original
out := &Cluster{
Nodes: make([]Node, len(in.Nodes)),
Network: in.Network,
KubeadmConfigPatches: in.KubeadmConfigPatches,
KubeadmConfigPatchesJSON6902: make([]PatchJSON6902, len(in.KubeadmConfigPatchesJSON6902)),
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/internal/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type Cluster struct {

/* Advanced fields */

// Network contains docker network to use in all containers
Network string

// Networking contains cluster wide network settings
Networking Networking

Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/cluster/providers/docker/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,17 @@ func clusterHasImplicitLoadBalancer(cfg *config.Cluster) bool {
// commonArgs computes static arguments that apply to all containers
func commonArgs(cluster string, cfg *config.Cluster) ([]string, error) {
// standard arguments all nodes containers need, computed once
network := cfg.Network
if network == "" {
network = "bridge"
}

args := []string{
"--detach", // run the container detached
"--tty", // allocate a tty for entrypoint logs
// label the node with the cluster ID
"--label", fmt.Sprintf("%s=%s", constants.ClusterLabelKey, cluster),
"--network", network,
}

// enable IPv6 if necessary
Expand Down

3 comments on commit 4b98621

@Bronek
Copy link

@Bronek Bronek commented on 4b98621 Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keymone is there a corresponding PR upstream?

@Bronek
Copy link

@Bronek Bronek commented on 4b98621 Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NVM, I found kubernetes-sigs#978

@Bronek
Copy link

@Bronek Bronek commented on 4b98621 Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.