Open steven-herchak opened 7 months ago
This issue is currently awaiting triage.
If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted
label and provide further guidance.
The triage/accepted
label can be added by org members by writing /triage accepted
in a comment.
/sig node for triage
Another related feature is the ability for the batch.kubernetes.io/cronjob-scheduled-timestamp
annotation that gets added to a job to be passed onto the child pod.
Hey @steven-herchak,
I think the first one can be done as a downward API but not sure of reasons why it wasn't included. Maybe @thockin has an idea?
Downward API tends to expose variables in the pod spec. I'm not really sure how that relates to higher level workloads so I'm not sure if cronjobs would fit in that case.
Opened up https://github.com/kubernetes/kubernetes/pull/123533 as I wanted to learn a bit more about how downward API actually works.
I like the idea of annotating the CronJob's timings into the Job and its Pods:
batch.kubernetes.io/cronjob-scheduled-timestamp
However, is it worth putting contributor time into that idea? Only if someone feels it's valuable.
Mostly the reason is that we only exposed things we had concrete demand for, rather than "everything".
We do support annotations in the volume-creating downward API, but not the env-creating one (I think it was not needed and syntax was ambiguous).
I guess one thing to note is that (IIRC) you can't implement the equivalent out of tree, because:
metadata.creationTimestamp
isn't set, so a mutating admission controller can't intervene
I opened up https://github.com/kubernetes/kubernetes/pull/123533 and got some good feedback from @thockin. https://github.com/kubernetes/kubernetes/pull/123533#issuecomment-1972038281
I will be on paternity leave for most of 1.31 so if anyone is interested in bringing this up as a KEP, please feel free! I even have a good starting point if anyone is interested.
The main action items will be to get some RFC (request for comments) on other downward api fields in the podspec and see if we could implement ones that have actual usecases in a KEP.
And for
Another related feature is the ability for the batch.kubernetes.io/cronjob-scheduled-timestamp annotation that gets added to a job to be passed onto the child pod.
I would maybe consider opening that as a separate issue and explore that in the batch CronJob controller. One could add that label/annotation to the PodSpec and you would get that for free as part of the downward api support for labels/annotations.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
What would you like to be added?
A pod's metadata.creationTimestamp would be useful information inside a container. This could be accomplished via downward API similar to other metadata currently available.
Why is this needed?
Consider a cronjob execution. When executed, the cronjob creates a job, and the job creates a pod with container(s). If the containers' logic depends on the time the cronjob was scheduled having the pod creationTime would be more useful than simply obtaining the current time.