From ac9fbc4e376c26a03da1789253e50b71c9ff7320 Mon Sep 17 00:00:00 2001 From: Chuck Ha Date: Fri, 5 Jul 2019 10:11:29 -0400 Subject: [PATCH 1/2] PR feedback Signed-off-by: Chuck Ha --- actuators/actuators.go | 15 ++++++++++++--- cmd/capd-manager/main.go | 4 ---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/actuators/actuators.go b/actuators/actuators.go index 0efd7d5..2c780f0 100644 --- a/actuators/actuators.go +++ b/actuators/actuators.go @@ -77,9 +77,18 @@ func kubeconfigToSecret(clusterName, namespace string) (*v1.Secret, error) { return nil, errors.WithStack(err) } - // This is necessary so the management cluster in a container can talk to another container. - // They share the same bridged network and the load balancer does respond on 6443 at its docker IP - // however, the *HOST* is listening on some random port (the one returned from the GetLoadBalancerHostAndPort). + // TODO: Clean this up at some point + // The Management cluster, running the NodeRef controller, needs to talk to the child clusters. + // The management cluster and child cluster must communicate over DockerIP address/ports. + // The load balancer listens on :6443 and exposes a port on the host at some random open port. + // Any traffic directed to the nginx container will get round-robined to a control plane node in the cluster. + // Since the NodeRef controller is running inside a container, it must reference the child cluster load balancer + // host by using the Docker IP address and port 6443, but us, running on the docker host, must use the localhost + // and random port the LB is exposing to our system. + // Right now the secret that contains the kubeconfig will work only for the node ref controller. In order for *us* + // to interact with the child clusters via kubeconfig we must take the secret uploaded, + // rewrite the kube-apiserver-address to be 127.0.0.1:. + // It's not perfect but it works to at least play with cluster-api v0.1.4 lbip, _, err := actions.GetLoadBalancerHostAndPort(allNodes) lines := bytes.Split(data, []byte("\n")) for i, line := range lines { diff --git a/cmd/capd-manager/main.go b/cmd/capd-manager/main.go index f640c80..36e668e 100644 --- a/cmd/capd-manager/main.go +++ b/cmd/capd-manager/main.go @@ -17,7 +17,6 @@ limitations under the License. package main import ( - "flag" "fmt" "time" @@ -36,9 +35,6 @@ import ( ) func main() { - flag.Set("v", "0") - flag.Parse() - cfg, err := config.GetConfig() if err != nil { panic(err) From 481ef1a54c5f874065404c1be051ea3944331e9a Mon Sep 17 00:00:00 2001 From: Chuck Ha Date: Fri, 5 Jul 2019 10:28:33 -0400 Subject: [PATCH 2/2] more accurate naming Signed-off-by: Chuck Ha --- kind/actions/cluster_actions.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kind/actions/cluster_actions.go b/kind/actions/cluster_actions.go index 9b9176c..384b461 100644 --- a/kind/actions/cluster_actions.go +++ b/kind/actions/cluster_actions.go @@ -179,12 +179,12 @@ func KubeadmInit(clusterName, version string) error { } // save the kubeconfig on the host with the loadbalancer endpoint - _, hostPort, err := GetLoadBalancerHostAndPort(allNodes) + _, loadBalancerPort, err := GetLoadBalancerHostAndPort(allNodes) if err != nil { return errors.Wrap(err, "failed to get kubeconfig from node") } dest := KubeConfigPath(clusterName) - if err := writeKubeConfig(node, dest, "127.0.0.1", hostPort); err != nil { + if err := writeKubeConfig(node, dest, "127.0.0.1", loadBalancerPort); err != nil { return errors.Wrap(err, "failed to get kubeconfig from node") } return nil