-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
add a flag to configure docker network #277
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,18 +48,22 @@ func getPort() (int, error) { | |
|
||
// CreateControlPlaneNode creates a contol-plane node | ||
// and gets ready for exposing the the API server | ||
func CreateControlPlaneNode(name, image, clusterLabel string) (node *Node, err error) { | ||
func CreateControlPlaneNode(name, image, network, clusterLabel string) (node *Node, err error) { | ||
// gets a random host port for the API server | ||
port, err := getPort() | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to get port for API server") | ||
} | ||
|
||
node, err = createNode(name, image, clusterLabel, config.ControlPlaneRole, | ||
extraArgs := []string{ | ||
// publish selected port for the API server | ||
"--expose", fmt.Sprintf("%d", port), | ||
"-p", fmt.Sprintf("%d:%d", port, kubeadm.APIServerPort), | ||
) | ||
} | ||
if network != "" { | ||
extraArgs = append(extraArgs, "--network", network) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this binds a kind CLI flag to the underlying CR (docker). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, i'm iffy on this. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it was in the config would it be at the top level? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, time flew by so fast :( i'm not sure.. I could see this (EDIT: this = per node network options) maybe, we could start top level and do an override. Either way we're mostly decoupled from docker at the user interface right now, and I do intend to support podman etc., I meant to investigate further if there was a better way to specify this or any other work arounds. I do see how this is a feature we need to enable. |
||
} | ||
node, err = createNode(name, image, clusterLabel, config.ControlPlaneRole, extraArgs...) | ||
if err != nil { | ||
return node, err | ||
} | ||
|
@@ -72,18 +76,22 @@ func CreateControlPlaneNode(name, image, clusterLabel string) (node *Node, err e | |
|
||
// CreateExternalLoadBalancerNode creates an external loab balancer node | ||
// and gets ready for exposing the the API server and the load balancer admin console | ||
func CreateExternalLoadBalancerNode(name, image, clusterLabel string) (node *Node, err error) { | ||
func CreateExternalLoadBalancerNode(name, image, network, clusterLabel string) (node *Node, err error) { | ||
// gets a random host port for control-plane load balancer | ||
port, err := getPort() | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to get port for control-plane load balancer") | ||
} | ||
|
||
node, err = createNode(name, image, clusterLabel, config.ExternalLoadBalancerRole, | ||
extraArgs := []string{ | ||
// publish selected port for the control plane | ||
"--expose", fmt.Sprintf("%d", port), | ||
"-p", fmt.Sprintf("%d:%d", port, haproxy.ControlPlanePort), | ||
) | ||
} | ||
if network != "" { | ||
extraArgs = append(extraArgs, "--network", network) | ||
} | ||
node, err = createNode(name, image, clusterLabel, config.ExternalLoadBalancerRole, extraArgs...) | ||
if err != nil { | ||
return node, err | ||
} | ||
|
@@ -95,8 +103,12 @@ func CreateExternalLoadBalancerNode(name, image, clusterLabel string) (node *Nod | |
} | ||
|
||
// CreateWorkerNode creates a worker node | ||
func CreateWorkerNode(name, image, clusterLabel string) (node *Node, err error) { | ||
node, err = createNode(name, image, clusterLabel, config.WorkerRole) | ||
func CreateWorkerNode(name, image, network, clusterLabel string) (node *Node, err error) { | ||
var extraArgs []string | ||
if network != "" { | ||
extraArgs = []string{"--network", network} | ||
} | ||
node, err = createNode(name, image, clusterLabel, config.WorkerRole, extraArgs...) | ||
if err != nil { | ||
return node, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason this should be an option on context instead of Create()? do you forsee other calls needing this?
👍 for this pattern in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't know if anything else was calling Create so I didn't want to change the parameters. Either way works. I haven't dug into the code enough to see how/where it is used.