1 min read | by Jordi Prats
If we use //+kubebuilder:printcolumn to add fields to print with kubectl get we'll notice that the AGE colum goes away with it. We can use an additional //+kubebuilder:printcolumn to add the AGE column back.
$ kubectl get example NAME ID demo 1234
To do so we just need to find the field in the object that contains it's age. That is: .metadata.creationTimestamp:
//+kubebuilder:object:root=true //+kubebuilder:subresource:status //+kubebuilder:printcolumn:name="ID",type="integer",JSONPath=".spec.exampleID",description="example ID" //+kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
Once installed we'll get the AGE column back:
$ kubectl get example NAME ID AGE demo 1234 32s
Posted on 29/08/2023