-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Support cluster API objects in multiple namespaces #481
Conversation
@davidewatson This is still a work in progress but just wanted to share what I have so far. |
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.
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) |
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.
All of the log and error messages should probably reference the namespace to uniquely identify the cluster.
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, agree. Will do that.
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 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. |
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.
s/cerates//g
TIL: cerate comes from the Latin cera, meaning wax.
/unassign philips |
bdb245c
to
a406536
Compare
/ok-to-test |
09de334
to
37b01d8
Compare
add unit tests for multi namespace scenarios
37b01d8
to
da0e454
Compare
ec9081e
to
6f3b124
Compare
/assign @detiber |
/lgtm |
@davidewatson: changing LGTM is restricted to assignees, and only kubernetes-sigs/cluster-api repo collaborators may be assigned issues. In response to this:
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. |
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.
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) { |
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.
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.
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.
Good suggestion. Added comments and log messages.
/lgtm |
/approve |
/assign @roberthbailey |
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 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
/lgtm |
[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 |
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: