Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

Feedback from a recent PR I forgot to push #68

Merged
merged 2 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions actuators/actuators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <docker_ip>: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:<randomly-assigned-by-docker-port>.
// 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 {
Expand Down
4 changes: 0 additions & 4 deletions cmd/capd-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package main

import (
"flag"
"fmt"
"time"

Expand All @@ -36,9 +35,6 @@ import (
)

func main() {
flag.Set("v", "0")
flag.Parse()

cfg, err := config.GetConfig()
if err != nil {
panic(err)
Expand Down
4 changes: 2 additions & 2 deletions kind/actions/cluster_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down