Skip to content
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

Migrate to CRDs (and kubebuilder) #37

Merged
merged 17 commits into from
Oct 5, 2018

Conversation

roberthbailey
Copy link
Contributor

What this PR does / why we need it: Picks up kubernetes-sigs/cluster-api#494 and migrates the GCP provider repository to use CRDs and kubebuilder to stay in line with the cluster-api repository.

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 #

Special notes for your reviewer:

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:

The GCP Cluster API provider now uses CRDs instead of an extension apiserver. 

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 27, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: roberthbailey

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 Sep 27, 2018
@roberthbailey
Copy link
Contributor Author

I've verified that this works following the (updated) instructions in the README:

$ ./bin/clusterctl create cluster --provider google -c cmd/clusterctl/examples/google/out/cluster.yaml -m cmd/clusterctl/examples/google/out/machines.yaml -p cmd/clusterctl/examples/google/out/provider-components.yaml -a cmd/clusterctl/examples/google/out/addons.yaml
I0927 15:35:45.038086    3802 clusterdeployer.go:94] Creating bootstrap cluster
I0927 15:38:03.991785    3802 clusterdeployer.go:111] Applying Cluster API stack to bootstrap cluster
I0927 15:38:03.991805    3802 clusterdeployer.go:300] Applying Cluster API Provider Components
I0927 15:38:04.554027    3802 clusterdeployer.go:116] Provisioning target cluster via bootstrap cluster
I0927 15:38:04.554048    3802 clusterdeployer.go:118] Creating cluster object test1-r5dcu on bootstrap cluster in namespace "default"
I0927 15:38:04.559822    3802 clusterdeployer.go:123] Creating master  in namespace "default"
I0927 15:39:34.595833    3802 clusterdeployer.go:128] Updating bootstrap cluster object for cluster test1-r5dcu in namespace "default" with master () endpoint
I0927 15:39:35.289560    3802 clusterdeployer.go:133] Creating target cluster
I0927 15:40:31.664412    3802 clusterdeployer.go:140] Applying Cluster API stack to target cluster
I0927 15:40:31.664430    3802 clusterdeployer.go:309] Applying Cluster API Provider Components
I0927 15:41:14.033701    3802 clusterdeployer.go:314] Pivoting Cluster API objects from bootstrap to target cluster.
I0927 15:41:14.323743    3802 clusterdeployer.go:368] Moved Cluster 'test1-r5dcu'
I0927 15:41:14.423718    3802 clusterdeployer.go:408] Moved Machine 'gce-master-5pps7'
I0927 15:41:14.423743    3802 clusterdeployer.go:145] Saving provider components to the target cluster
I0927 15:41:14.723028    3802 clusterdeployer.go:158] Updating target cluster object with master () endpoint
I0927 15:41:15.139619    3802 clusterdeployer.go:163] Creating node machines in target cluster.
I0927 15:42:45.278062    3802 clusterdeployer.go:169] Creating addons in target cluster.
I0927 15:42:46.684638    3802 clusterdeployer.go:175] Done provisioning cluster. You can now access your cluster with kubectl --kubeconfig kubeconfig
I0927 15:42:46.686093    3802 clusterdeployer.go:223] Cleaning up bootstrap cluster.

Tests pass locally, but we need to update prow to use go 1.10+ and add some of the kubebuilder binaries before CI tests will pass.

@roberthbailey
Copy link
Contributor Author

/test pull-cluster-api-provider-gcp-test

@timothysc
Copy link
Member

@roberthbailey - I'm just trying to figure out how we consume downstream :-/

@roberthbailey
Copy link
Contributor Author

@timothysc and I chatted on slack about his question. Unfortunately, I don't see any easy way for other providers to pick up this change. Each one will need to update deps and migrate to kubebuilder following the same steps. The good news is that the steps aren't too complicated.

Copy link
Contributor

@justinsb justinsb left a comment

Choose a reason for hiding this comment

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

A few suggestions, but nothing that should delay this PR further..

./generate-yaml.sh
cd ../..
cd ../../../..
kustomize build config/default/ > cmd/clusterctl/examples/google/out/provider-components.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

Yay for more kustomize and less bash :-)

)

func main() {
flag.Parse()
Copy link
Contributor

Choose a reason for hiding this comment

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

I always like to do flag.Set("logtostderr", "true"), so don't be surprised to see a PR for that soon!

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 file was generated by kubebuilder - so send it upstream (and then everyone will get the change).

Zone string `json:"zone"`
MachineType string `json:"machineType"`

// The name of the OS to be installed on the machine.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is matching the yaml file, rather than actually installing the OS... so I'm wondering if we should just make it key value pairs. That might actually be generic enough for the Machine type itself. Probably best discussed at the next cluster API meeting!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can discuss these types separately; for this PR they were just copied from the existing types.

SourceTags: []string{cluster.Name + "-worker"},
})
if err != nil {
glog.Warningf("Error creating firewall rule for internal cluster traffic: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just warning feels like we will bury bad news in the logs, and users won't understand why their cluster didn't launch. return error instead?

SourceRanges: []string{"0.0.0.0/0"},
})
if err != nil {
glog.Warningf("Error creating firewall rule for core api server traffic: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same concern here, but will stop commenting on this class of problem for brevity :-)

// Sets the status of the instance identified by the given machine to the given machine
func (gce *GCEClient) updateInstanceStatus(machine *clusterv1.Machine) error {
if gce.client == nil {
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel this should be an error(?)


// Gets the state of the instance stored on the given machine CRD
func (gce *GCEClient) machineInstanceStatus(machine *clusterv1.Machine) (instanceStatus, error) {
if machine.ObjectMeta.Annotations == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think this check could be ommitted, because a nil map is treated the same as an empty map for reading


// The two machines differ in a way that requires an update
func (gce *GCEClient) requiresUpdate(a *clusterv1.Machine, b *clusterv1.Machine) bool {
// Do not want status changes. Do want changes that impact machine provisioning
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I would zero-out the fields you don't care about (after copying!); my fear is that someone adds a field that we do care about and we get hard-to-figure out bugs.


// Otherwise, fall back to the base image.
glog.Infof("Could not find image at %s. Defaulting to %s.", img, defaultImg)
return defaultImg
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an error?


const nodeEnvironmentVars = `
#!/bin/bash
KUBELET_VERSION={{ .Machine.Spec.Versions.Kubelet }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Idea: we should move this to building in code from a map (no template), then we can have some sanity checks around quoting or invalid characters

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 agree that this should be tidied up.

@justinsb
Copy link
Contributor

justinsb commented Oct 5, 2018

Looks great @roberthbailey - a few suggestions, but it sounds like the community needs an existence proof :-)

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 5, 2018
@k8s-ci-robot k8s-ci-robot merged commit f3145d8 into kubernetes-sigs:master Oct 5, 2018
@roberthbailey
Copy link
Contributor Author

Can you send a PR to fix the issues that you found?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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 "Looks good to me", 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.

5 participants