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

✨ ClusterClass: ensure templates are created in the Cluster namespace #11366

Merged

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Nov 1, 2024

What this PR does / why we need it:

Creation of the infrastructure template in desired state for the Cluster is always using namespace of the template, while Cluster object namespace is ignored. This changes behavior to use Cluster namespace for the generated template, which allows referencing ClusterClass from a Cluster resource located in different namespace, if validating policy allows it.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Related to #5673

/area clusterclass

@k8s-ci-robot
Copy link
Contributor

@Danil-Grigorev: The label(s) area/kubeadm cannot be applied, because the repository doesn't have them.

In response to this:

What this PR does / why we need it:

Creation of template in desired state is always using namespace of the template, while Cluster object namespace is ignored. This changes behavior to use Cluster namespace for the generated template, which allows referencing ClusterClass from a Cluster resource, located in different namespace, if validating policy allows it.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Related to #5673

/area clusterclass
/area kubeadm

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added area/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 1, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Nov 1, 2024
@Danil-Grigorev Danil-Grigorev changed the title Allow cross-namespace template instances ✨ Allow cross-namespace template instances Nov 1, 2024
@JoelSpeed
Copy link
Contributor

How do owner references work presently for Cluster and ClutserClass objects? Is there any relation between the two with respect to owner references?

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 2, 2024
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Nov 2, 2024
@Danil-Grigorev
Copy link
Member Author

Danil-Grigorev commented Nov 3, 2024

Hi @JoelSpeed 👋. I think in this case relationships are unchanged. This change touches creation of InfrastructureMachineTemplate owned by Cluster type, and since a cluster might be in a different namespace, this patch ensures that the relationship holds. Tests were already setting this expectation, but a different namespace combination was not covered.

@JoelSpeed
Copy link
Contributor

OK, so the intention of this patch, is that if the ClusterClass exists in a different namespace, we make sure to create a copy of the InfrastructureMachineTemplate in the Cluster namespace? Whereas today, the template would be created in the ClusterClass namespace?

@Danil-Grigorev
Copy link
Member Author

Yes, these are 2 other PRs which, once combined, make this change permit what the title says.

I tried to split the changes, so that it will be less complex to review, and does not introduce full scope of modifications in a single PR. Unfortunately, as a consequence, until these changes are merged (this PR and #11361), it is hard to introduce added e2e coverage which was requested by Fabrizio.

@sbueringer
Copy link
Member

Makes sense to me!

/lgtm
/approve

/test pull-cluster-api-e2e-main

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

LGTM label has been added.

Git tree hash: 0644d22508d6ec3e192aa77170bee85962c13f99

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Nov 4, 2024
@sbueringer sbueringer changed the title ✨ Allow cross-namespace template instances ✨ ClusterClass: ensure templates are created in the Cluster namespace Nov 4, 2024
@k8s-ci-robot k8s-ci-robot merged commit 3b9a0e5 into kubernetes-sigs:main Nov 4, 2024
30 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Nov 4, 2024
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. area/clusterclass Issues or PRs related to clusterclass 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants