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

🌱 Provide namespace of the referenced ClusterClass in TEMPLATENAMESPACE #11802

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Feb 5, 2025

What this PR does / why we need it:

Allow to display ClusterClass and templates namespace in the table output of Cluster objects:

> kubectl get clusters 
NAME              CLUSTERCLASS   PHASE          AGE   VERSION
capi-quickstart   quick-start    Provisioning   96m   v1.32.0
> kubectl get clusters -o wide
NAME              CLUSTERCLASS   TEMPLATENAMESPACE   PHASE          AGE   VERSION
capi-quickstart   quick-start    test                Provisioning   96m   v1.32.0

A cluster without classNamespace:

NAME              CLUSTERCLASS   TEMPLATENAMESPACE   PHASE   AGE   VERSION
capi-quickstart   quick-start    default                     81m   v1.32.0

Using classNamespace as the source for the value, unless is not specified, in which case the metadata.namespace is displayed.

This will improve UX and reduce confusion, when looking up referenced templates or the ClusterClass in the namespace of the Cluster, when those are located elsewhere.

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 5, 2025
@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-area PR is missing an area label label Feb 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fabriziopandini for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 5, 2025
@Danil-Grigorev
Copy link
Member Author

/area api

@k8s-ci-robot k8s-ci-robot added area/api Issues or PRs related to the APIs and removed do-not-merge/needs-area PR is missing an area label labels Feb 5, 2025
@Danil-Grigorev Danil-Grigorev force-pushed the template-namespace-cluster-class branch 2 times, most recently from b07a2cf to ec62646 Compare February 5, 2025 18:48
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 5, 2025
@@ -1037,6 +1037,7 @@ func (v APIEndpoint) String() string {
// +kubebuilder:storageversion
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="ClusterClass",type="string",JSONPath=".spec.topology.class",description="ClusterClass of this Cluster, empty if the Cluster is not using a ClusterClass"
// +kubebuilder:printcolumn:name="TemplateNamespace",type="string",JSONPath="..['spec.topology.classNamespace','metadata.namespace']",description="Template namespace of this Cluster",priority=10
Copy link
Member

@sbueringer sbueringer Feb 6, 2025

Choose a reason for hiding this comment

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

TemplateNamespace seems a bit misleading to me.

We have many templates. Some referenced in control plane / MD / MS objects. Some referenced from the ClusterClass. Wouldn't the more appropriate name be ClusterClassNamespace?

Ideally maybe something that ends up as CLUSTERCLASS_NAMESPACE if that is possible? (not sure if there are naming conventions for columns)

Copy link
Member Author

Choose a reason for hiding this comment

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

I think CLUSTERCLASS_NAMESPACE is better here. The problem is thought that it will be displayed without spec.template.class being set, if queried with kubectl get clusters -o wide. What I wanted to convey is CLUSTER_CLASS_TEMPLATES_NAMESPACE, as the location from where the definitions originate and being cloned. Maybe in combination with ClusterClass field defaulting to empty is not that misleading.

Copy link
Member

Choose a reason for hiding this comment

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

Hm yeah an empty column is probably confusing in all variants. Ideally we could fallback to show the Cluster.Namespace instead of course (I assume with CEL that would be possible, with jsonPath today probably not?)

Copy link
Member Author

@Danil-Grigorev Danil-Grigorev Feb 6, 2025

Choose a reason for hiding this comment

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

This is possible with the expression provided.

  1. If the classNamespace is not set, it uses the namespace of the cluster:
NAME              CLUSTERCLASS   CLUSTERCLASS_NAMESPACE   PHASE   AGE   VERSION
capi-quickstart   quick-start    default                          81m   v1.32.0
  1. If the classNamespace is set, it displays the value
NAME              CLUSTERCLASS   CLUSTERCLASS_NAMESPACE   PHASE   AGE   VERSION
capi-quickstart   quick-start    otherns                          81m   v1.32.0
  1. The only thing it can’t do now, but a CEL will be able (though it will be a while?) is to not display a namespace if topology.class is empty:
NAME              CLUSTERCLASS   CLUSTERCLASS_NAMESPACE   PHASE   AGE   VERSION
capi-quickstart                  default                          81m   v1.32.0

The field is present in the -o wide now anyway, so it is not a problem?

Copy link
Member

Choose a reason for hiding this comment

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

Ah got it, should have seen that.

The field is present in the -o wide now anyway, so it is not a problem?

Not sure, looks a bit awkward for folks not using ClusterClass

Copy link
Member

Choose a reason for hiding this comment

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

I don't know exact timeline, but if CEL is an option in the near future, what if we defer this change?

Copy link
Member

Choose a reason for hiding this comment

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

No strong opinions.

If we wait for CEL we have to wait for this KEP to reach GA + ~ 1,5 years. So we're probably talking by delaying at least by 2 or 2,5 years

Copy link
Member

Choose a reason for hiding this comment

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

But on the other side. I don't see a way to implement this today which is not confusing in some cases

Copy link
Member

Choose a reason for hiding this comment

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

Yep, it feels that we are forcing a solution that doesn't make anyone happy.
Also, we are going to review all the columns is a short term for v1beta2, and we already know that we have space constraints

Copy link
Member

Choose a reason for hiding this comment

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

I would probably go with not adding the column for now.

(Note: I think it's fine if CAPI distributions are adding additional columns like this downstream if they want. They might not have all the use cases so the column might not be confusing there)

@Danil-Grigorev Danil-Grigorev force-pushed the template-namespace-cluster-class branch 3 times, most recently from 9f02d74 to 67efc6e Compare February 6, 2025 14:43
@Danil-Grigorev Danil-Grigorev force-pushed the template-namespace-cluster-class branch from 67efc6e to 23768bd Compare February 7, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Issues or PRs related to the APIs cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants