Replies: 2 comments 1 reply
-
To achieve the desired output where the READY column displays as a fraction (e.g., 1/1), you'd need to use the JSONPath feature in kubebuilder:printcolumn. Here's how you can set it up for a single field: // +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".spec.ready" For your desired output, you may have to look into extending kubectl or writing a custom script to fetch and format the resources in your desired way. If the core Kubernetes project or the controller-tools project (which handles the generation of CRD manifests from the kubebuilder annotations) so you might want check the documentation and raise issues for their projects as well as raise questions in the controller-runtime slack channel. I hope that it answered your question. |
Beta Was this translation helpful? Give feedback.
-
Following an example if the above explanation is not clear enough: 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"`
} Please, let us know if that is not what you are looking for. If not please, could you please clarify what is missing? |
Beta Was this translation helpful? Give feedback.
-
I wander how to set the printcolum to make ready column like this.
Beta Was this translation helpful? Give feedback.
All reactions