<p>I'm trying run a cron job with Kubernetes. The job executes a program that performs some computation based on the job's scheduled start time. How can my program get access to this value during its execution?</p>

<p>Option 1 (easiest): Put the same value to job container environment variable. I assume you install with helm or similar mechanism, so it should be easy to reuse <code>schedule</code> variable in 2 places.</p>

<p>Option 2: Use a combination of a <code>Role</code>, <code>RoleBinding</code> and <code>ServiceAccount</code>, then use <code>kubectl</code> / <code>language k8s client</code> to retrieve cronjob (you will need to know its name if there's multiple in a namespace) and get schedule from its parameters.</p>

<p>Option 3: <a href="https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/</a> This is a variation of 1 but using the resourceFieldRef. Not sure you can refer a cronjob resource tho :(</p>
