0

I have a cron job in k8s with cron like

* * * * *

it runs every minute.

In the pod, how can I get when a certain pod was scheduled? I want to get the data time when the pod was gonna scheduled in my container as an env variable. If the pod crashes, I want the value when it was gonna scheduled and not when it started after restarting.

Akshit Bansal
  • 75
  • 1
  • 7
  • You will have to call k8s API explicitly. You can get the json "spec" which will contain the desired info. – oakad Jul 28 '22 at 09:57
  • can I get its value more easily if I use Helm rather than calling k8s API? – Akshit Bansal Jul 28 '22 at 10:05
  • What you seem to ask, is whether the info you seek is available in the downward api. I don't think so: https://kubernetes.io/docs/concepts/workloads/pods/downward-api/ – oakad Jul 28 '22 at 10:49
  • Though, if your helm template allows to copy the cron string into the custom pod annotation value, that is, in fact, available. – oakad Jul 28 '22 at 10:51
  • if I use k8s API, I will get when the pod was started but not when it should have started. I want to know when it should have started. for e.g. if I wanted to run a pod at 11:00 AM and the pod runs and crashes and restarts, I want to get 11:00 AM and not when it started after restarting. – Akshit Bansal Jul 28 '22 at 11:06

0 Answers0