<p>Let's say I have such CronJob definition:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: &quot;*/1 * * * *&quot;  # pass this value to container's env
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: cronjob-test
            image: myiamge:latest
            imagePullPolicy: Never
            env:
            - name: schedule
              value: # pass the schedule value here 
          restartPolicy: OnFailure
</code></pre>
<p>How do I pass the <code>schedule</code> value from the <code>CronJob.spec</code> into <code>CronJob.spec.jobTemplate.spec.template.spec.containers.env</code>? Is it even possible?</p>
<p>Normally, I would do something like this:</p>
<pre><code>valueFrom:
  fieldRef:
    fieldPath: spec.timezone
</code></pre>
<p>But in this case, it won't get this value.</p>
<p>Thanks in advance for help!</p>

xaos_xv
<p>Unfortunately,  <code>schedule</code> should be certain value when <code>CronJob</code> defines. And the values referred by <code>fieldRef</code> is passed to its container as the env variables when your pod(container) run, so <code>fieldRef</code> cannot pass the certain value to <code>schedule</code> when the CronJob defines. Usually, in this use case, a template format is appropriate. For instance like Helm and similar ones.</p>
<pre><code>apiVersion: batch/v1beta1
kind: CronJob
:
spec:
  schedule: {{ .Values.schedule }}
</code></pre>
<p>You can replace <code>schedule</code> value using Helm format.</p>
<pre><code>// Values.yaml in the Helm format
schedule: '&quot;*/1 * * * *&quot;'
</code></pre>
