<p>I'm applying a <strong>Kubernetes CronJob</strong>.
So far it works.
Now I want to <strong>add the environment variables</strong>. (env: -name... see below)
While tryng to apply I get the error </p>

<blockquote>
  <p>unknown field "configMapRef" in io.k8s.api.core.v1.EnvVarSource</p>
</blockquote>

<p>I don't like to set all singles variables here. I prefer to link the configmap to not to double the variables. <strong>How is it possible set a link to the configmap.yaml variables in a CronJob file, how to code it?</strong></p>

<p>Frank</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: ad-sync
  creationTimestamp: 2019-02-15T09:10:20Z
  namespace: default
  selfLink: /apis/batch/v1beta1/namespaces/default/cronjobs/ad-sync
spec:
  concurrencyPolicy: Allow
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 3
  suspend: false
  schedule: "0 */1 * * *"
  jobTemplate:
    metadata:
      labels:
        job: ad-sync
    spec:
      template:
        spec:
          containers:
          - name: ad-sync
            image: foo.azurecr.io/foobar/ad-sync
            command: ["dotnet", "AdSyncService.dll"]
            args: []
            env:
              - name: AdSyncService
                valueFrom:
                  configMapRef:
                    name: ad-sync-service-configmap
          restartPolicy: OnFailure</code></pre>
</div>
</div>
</p>

Frank Mehlhop
<p>There is no such field <strong>configMapRef</strong> in <strong>env field</strong> instead there is a field called <strong>configMapKeyRef</strong></p>

<p>in order to get more detail about <strong>kubernetes objects</strong>, its convenient to use <strong>kubectl explain --help</strong>  </p>

<p>for example if you would like to check all of the keys and their types you can use following command </p>

<pre><code>kubectl explain cronJob --recursive

kubectl explain cronjob.spec.jobTemplate.spec.template.spec.containers.env.valueFrom.configMapKeyRef
</code></pre>
