-
Notifications
You must be signed in to change notification settings - Fork 43
Conversation
Signed-off-by: Chuck Ha <chuckh@vmware.com>
Signed-off-by: Chuck Ha <chuckh@vmware.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chuckha The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Chuck Ha <chuckh@vmware.com>
/hold this is not right, rbac changed a fair bit here |
Signed-off-by: Chuck Ha <chuckh@vmware.com>
/hold cancel yay this is finally done |
@@ -379,3 +346,8 @@ func KubeadmReset(clusterName, nodeName string) error { | |||
|
|||
return nil | |||
} | |||
|
|||
// ProviderID formats the provider id needed to set on the node | |||
func ProviderID(name string) string { |
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.
Put this logic in ONE place instead of having it split in two places with the wrong provider ID
// getLoadBalancerPort returns the port on the host on which the APIServer is exposed | ||
func getLoadBalancerPort(allNodes []nodes.Node) (int32, error) { | ||
// GetLoadBalancerHostAndPort returns the port on the host on which the APIServer is exposed | ||
func GetLoadBalancerHostAndPort(allNodes []nodes.Node) (string, int32, error) { |
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.
This gets the docker IP of the load balancer container. We use this to write the Docker IP into the kubeadm config for the node-ref controller
} | ||
|
||
// This is a poor person's kustomize | ||
if strings.HasSuffix(header.Name, "manager.yaml") { |
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.
This makes me sad but it is better than copy and pasting
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.
minor nits, otherwise LGTM
@@ -35,6 +36,9 @@ import ( | |||
) | |||
|
|||
func main() { | |||
flag.Set("v", "0") | |||
flag.Parse() | |||
|
|||
cfg, err := config.GetConfig() | |||
if err != nil { | |||
panic(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.
klog.Fatal?
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.
Yep, This is covered in #8
I'll time that out soon depending on if the contributor contributes or not
@@ -179,7 +179,7 @@ func KubeadmInit(clusterName, version string) error { | |||
} | |||
|
|||
// save the kubeconfig on the host with the loadbalancer endpoint | |||
hostPort, err := getLoadBalancerPort(allNodes) | |||
_, hostPort, err := GetLoadBalancerHostAndPort(allNodes) |
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.
hostPort -> port?
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.
maybe? I don't really see a huge benefit in this rename. I recognize host is a bit inaccurate technically but it may help to think about each container as a host.
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.
ah i refer to host as docker host in other places, i will clarify, good point
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.
Hi @chuckha,
This isn't the review I want to give, but it's the review that time permits at the moment. This is awesome stuff!
lines := bytes.Split(data, []byte("\n")) | ||
for i, line := range lines { | ||
if bytes.Contains(line, []byte("https://")) { | ||
lines[i] = []byte(fmt.Sprintf(" server: https://%s:%d", lbip, 6443)) |
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.
Hi @chuckha,
Should the port always be assumed?
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.
yes, the port should always be assumed as 6443. The apiservers will always be listening on their own IP at port 6443 until we allow users to customize support. This will change when support for that feature is added.
// 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). | ||
lbip, _, err := actions.GetLoadBalancerHostAndPort(allNodes) | ||
lines := bytes.Split(data, []byte("\n")) |
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.
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.
ScanLines would also work, this was just in my head at the time. If this becomes an issue in the future we can address it later.
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.
Fair, but I also don't think there's a good reason for not switching to stdlib.
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 don't understand what you mean, bytes
is in the stdlib
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.
Yeah, sorry, my response was poorly worded. I was referring to how ScanLines
uses a more comprehensive matching pattern. If this won't be an issue here because the line endings are guaranteed, then this is fine.
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.
ah i see what you mean. Yes, that would definitely be more robust. It will be worth fixing if we need to fix it later as I'm not expecting line endings other than \n
at this time. The file we're reading is generated by kubeadm on a unix based system.
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.
FWIW, I know Golang treats \n
as a special character. If you use it in a fmt.Sprintf
(or a variant), Go will always translate \n
to the OS-specific line-ending character(s). I'm not sure if this is the case on scanning though. Either way, as you said, it's a non-issue here.
capdImage := capd.String("capd-image", "gcr.io/kubernetes1-226021/capd-manager:latest", "The capd manager image to run") | ||
capiImage := capd.String("capi-image", "gcr.io/k8s-cluster-api/cluster-api-controller:0.1.3", "The capi manager image to run") | ||
version := setup.String("capi-version", "v0.1.4", "The CRD versions to pull from CAPI") | ||
capdImage := setup.String("capd-image", "gcr.io/kubernetes1-226021/capd-manager:latest", "The capd manager image to run") |
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.
Hi @chuckha,
I'm not personally a fan of latest
as it has unpredictable results. Will using it here result in possible breakage?
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.
Totally agree. I've opened an issue to figure out a better strategy here: #67
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.
/lgtm
Signed-off-by: Chuck Ha chuckh@vmware.com
What this PR does / why we need it:
This PR removes the need to copy and paste RBAC and CRD definitions. Instead we download them from a provided version of CAPI.
This PR also adds many fixes to support cluster-api v0.1.4.
This PR adds a very annoying bug that I've yet to find a good solution for regarding kubeconfig secrets and the cluster endpoint.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #32