Skip to content

Support cluster API objects in multiple namespaces #481

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

Merged

Conversation

ashish-amarnath
Copy link
Contributor

What this PR does / why we need it:
Supporting multiple clusters requires, cluster and machine to be stored in multiple namespaces, clusterctl create currently assumes default namespace which will not work in a multi-cluster setup.

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 #252

Special notes for your reviewer:

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

Release note:


@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 20, 2018
@k8s-ci-robot k8s-ci-robot requested review from philips and spew August 20, 2018 18:07
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 20, 2018
@ashish-amarnath
Copy link
Contributor Author

ashish-amarnath commented Aug 20, 2018

@davidewatson This is still a work in progress but just wanted to share what I have so far.
The unit tests don't pass atm there is that and other work that needs to go into this PR

Copy link
Contributor

@davidewatson davidewatson left a comment

Choose a reason for hiding this comment

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

Thanks, Ashish, this is looking good!

Currently, the Delete() functions assume a single cluster per namespace. This is no worse than the status quo, though since we are exporting this interface, I wonder if we should add a cluster name to the arguments (and require labels). I'll add a comment to one of #41, #145, #177. ...

clusters := []*clusterv1.Cluster{}
// TODO: Iterate over all namespaces where we could have Cluster API Objects https://github.com/kubernetes-sigs/cluster-api/issues/252
clusterlist, err := c.clientSet.ClusterV1alpha1().Clusters(apiv1.NamespaceDefault).List(metav1.ListOptions{})
clusterlist, err := c.clientSet.ClusterV1alpha1().Clusters(ns).List(metav1.ListOptions{})
if err != nil {
return nil, fmt.Errorf("error listing cluster objects: %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.

All of the log and error messages should probably reference the namespace to uniquely identify the cluster.

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, agree. Will do that.

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 took a pass for this. I will do another pass before calling this PR done.

@@ -110,12 +117,11 @@ const (
timeoutKubeconfigReady = 20 * time.Minute
)

// Creates the a cluster from the provided cluster definition and machine list.

// Create cerates the a cluster from the provided cluster definition and machine list.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/cerates//g

TIL: cerate comes from the Latin cera, meaning wax.

@philips
Copy link

philips commented Aug 20, 2018

/unassign philips

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 23, 2018
@roberthbailey
Copy link

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 23, 2018
@ashish-amarnath ashish-amarnath force-pushed the iss-252-muli-ns branch 2 times, most recently from 09de334 to 37b01d8 Compare August 23, 2018 22:29
add unit tests for multi namespace scenarios
@ashish-amarnath ashish-amarnath changed the title [WIP] Support cluster API objects in multiple namespaces Support cluster API objects in multiple namespaces Aug 24, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 24, 2018
@ashish-amarnath
Copy link
Contributor Author

/assign @detiber

@davidewatson
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@davidewatson: changing LGTM is restricted to assignees, and only kubernetes-sigs/cluster-api repo collaborators may be assigned issues.

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@detiber detiber left a comment

Choose a reason for hiding this comment

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

Overall these changes look good to me, but should clusterctl/cmd/create_cluster.go and clusterctl/cmd/validate_cluster.go also be updated to add support for setting the namespace?

@@ -118,11 +171,15 @@ func (c *clusterClient) GetClusterObjects() ([]*clusterv1.Cluster, error) {
return clusters, nil
}

func (c *clusterClient) GetMachineDeploymentObjects() ([]*clusterv1.MachineDeployment, error) {
func (c *clusterClient) GetClusterObjects() ([]*clusterv1.Cluster, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add comments to these preserved methods to indicate that they are deprecated and to be removed in the future? It might be good to also log the deprecation as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion. Added comments and log messages.

@detiber
Copy link
Member

detiber commented Aug 30, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 30, 2018
@ashish-amarnath
Copy link
Contributor Author

/approve

@ashish-amarnath
Copy link
Contributor Author

/assign @roberthbailey

Copy link

@roberthbailey roberthbailey left a comment

Choose a reason for hiding this comment

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

I didn't review the test code too closely.

Fix: cluster client should not attempt deletion of the default namespace
Make logs and error messages consistent when referring to cluster.Namespace
Update unit tests
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 5, 2018
@roberthbailey
Copy link

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 6, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashish-amarnath, 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

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.

Support cluster and machine in multiple namespaces in clusterctl create
6 participants