kubernetes-sigs / controller-tools

Tools to use with the controller-runtime libraries
Apache License 2.0
734 stars 419 forks source link

feature: support the (X/Y) display mode for the printcolumn field in kubebuilder #1051

Open googs1025 opened 2 months ago

googs1025 commented 2 months ago

/kind feature As mentioned in the title and our discussion here https://github.com/kubernetes-sigs/kubebuilder/discussions/4134, can we support a JsonPath-like way of multiple combinations? This would allow for more flexible and rich display in CRs, for example, in the format of (X/Y).

It seems that there are others who have the same need.

sbueringer commented 2 months ago

If there is a way to do this with CRDs we can generate them accordingly with controller-gen.

If there is not, Kubernetes has to implement support for it first in the apiserver (and this issue should be opened in the kubernetes/kubernetes repo)

camilamacedo86 commented 2 months ago

Hi @sbueringer

Just to clarify the scenario, users are looking for

type FooSpec struct {
       Ready int `json:"ready"`
       Total int `json:"total"`
}

// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="READY",type=string,JSONPath=`{.spec.ready}/{.spec.total}`
type Foo struct {
      metav1.TypeMeta   `json:",inline"`
      metav1.ObjectMeta `json:"metadata,omitempty"`

      Spec   FooSpec   `json:"spec,omitempty"`
      Status FooStatus `json:"status,omitempty"`
}

However, seems that

JSONPath=`{.spec.ready}/{.spec.total}` 

does not work. So, this issue is to ask for add the support to allow operations via JSONPath as the above example.

So, should the request with this example be raised against apiserver?

sbueringer commented 2 months ago

If it is not supported by Kubernetes today, I don't see how we can support it in controller-gen. controller-gen only generates CRD YAMLs.

So yes, if it's not supported by the apiserver today, we should open an issue for the apiserver not for controller-gen

googs1025 commented 2 months ago

Is there a way we could support a MultiJsonPath-like approach, allowing multiple JsonPaths to be combined? This would make the display more flexible, rather than being limited to specific JsonPaths only.

sbueringer commented 2 months ago

Sorry to say this again. This repository only contains controller-gen. controller-gen is a command line tool to generate CRD YAMLs. This repository does not contain any kube-apiserver code.

Because of that we cannot modify controller-gen to implement a feature that is not supported in the kube-apiserver first.

googs1025 commented 2 months ago

Sorry to say this again. This repository only contains controller-gen. controller-gen is a command line tool to generate CRD YAMLs. This repository does not contain any kube-apiserver code.

Because of that we cannot modify controller-gen to implement a feature that is not supported in the kube-apiserver first.

Thanks for the response! I appreciate it. I'm sorry for repeatedly asking you about the same thing. It's because I don't understand how it's generated. Also, if I want a similar feature, I need kube-apiserver support, right? If so, I'll go ahead and submit an issue in kubernetes/kubernetes to discuss and track this matter.

camilamacedo86 commented 2 months ago

Hi @googs1025

If so, I'll go ahead and submit an issue in kubernetes/kubernetes to discuss and track this matter.

Yes, that seems the right thing to do. I think that is the project: https://github.com/kubernetes/apiserver Please, add the code example like https://github.com/kubernetes-sigs/controller-tools/issues/1051#issuecomment-2337392003

To clarify the scenario.

googs1025 commented 2 months ago

Hi @googs1025

If so, I'll go ahead and submit an issue in kubernetes/kubernetes to discuss and track this matter.

Yes, that seems the right thing to do. I think that is the project: https://github.com/kubernetes/apiserver Please, add the code example like #1051 (comment)

To clarify the scenario.

Maybe we should file an issue in kubernetes/kubernetes, since the kubernetes/apiserver repository is the one to sync :)