In Kubernetes CustomResourceDefinitions
(CRDs), we can specify additionalPrinterColumns
, which (for example) are used for kubectl get
with a CRD. The value for a column is usually extracted from the status of a CRD using a jsonPath
. From the Kubernetes docs, we can also see that timestamps are rendered in a user friendly way (e.g., 5m or 2h, representing the duration from this timestamp to now):
additionalPrinterColumns:
- name: Duration
type: date
jsonPath: .status.completitionTimestamp
The Kubernetes Job resource is an example for a resource, which does not only show since when it exists, but also for long it was running:
NAME COMPLETIONS DURATION AGE
hello-4111706356 0/1 0s
hello-4111706356 0/1 0s 0s
hello-4111706356 1/1 5s 5s
I'm looking for building something similar for my CRD, that is: Showing the duration between two timestamps in the same way. More specific, I would like to get the duration between two status fields such as .status.startTimestamp
and .status.completitionTimestamp
evaluated and formatted by Kubernetes.
As exactly the same thing is done in the Job resource, I'm wondering if this is somehow possible or if this is special behavior built into kubectl
?