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

All the fixes for cluster api v0.1.4 #62

Merged
merged 4 commits into from
Jul 5, 2019

Conversation

chuckha
Copy link
Contributor

@chuckha chuckha commented Jul 3, 2019

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

Removes `capd` and `crds` command since those were only useful for setting up a management cluster

chuckha added 2 commits July 3, 2019 11:33
Signed-off-by: Chuck Ha <chuckh@vmware.com>
Signed-off-by: Chuck Ha <chuckh@vmware.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 3, 2019
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 3, 2019
@k8s-ci-robot k8s-ci-robot requested review from detiber and justinsb July 3, 2019 15:36
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 3, 2019
Signed-off-by: Chuck Ha <chuckh@vmware.com>
@chuckha
Copy link
Contributor Author

chuckha commented Jul 3, 2019

/hold

this is not right, rbac changed a fair bit here

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 3, 2019
Signed-off-by: Chuck Ha <chuckh@vmware.com>
@chuckha chuckha changed the title Download CAPI CRDs from release tarball All the fixes for cluster api v0.1.4 Jul 3, 2019
@chuckha
Copy link
Contributor Author

chuckha commented Jul 3, 2019

/hold cancel

yay this is finally done

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 3, 2019
actuators/machine.go Show resolved Hide resolved
cmd/capd-manager/main.go Show resolved Hide resolved
@@ -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 {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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") {
Copy link
Contributor Author

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

actuators/actuators.go Show resolved Hide resolved
Copy link

@vincepri vincepri left a 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

actuators/actuators.go Show resolved Hide resolved
cmd/capd-manager/main.go Show resolved Hide resolved
@@ -35,6 +36,9 @@ import (
)

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

cfg, err := config.GetConfig()
if err != nil {
panic(err)
Copy link

Choose a reason for hiding this comment

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

klog.Fatal?

Copy link
Contributor Author

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)
Copy link

Choose a reason for hiding this comment

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

hostPort -> port?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link

@akutz akutz left a 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))
Copy link

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?

Copy link
Contributor Author

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"))
Copy link

Choose a reason for hiding this comment

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

Hi @chuckha,

Why not use ScanLines? Even if not, maybe prefer the Golang regex \r?\n?

Copy link
Contributor Author

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.

Copy link

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.

Copy link
Contributor Author

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

Copy link

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.

Copy link
Contributor Author

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.

Copy link

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.

actuators/machine.go Show resolved Hide resolved
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")
Copy link

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?

Copy link
Contributor Author

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

kind/actions/kind.go Show resolved Hide resolved
Copy link

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 5, 2019
@k8s-ci-robot k8s-ci-robot merged commit 7a0f729 into kubernetes-retired:master Jul 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't copy/paste the CRDs from Cluster API
4 participants