<pre><code>$ kubectl api-versions | grep batch
batch/v1
batch/v1beta1
</code></pre>

<p>When attempting to create this CronJob object which has a single container and an empty volume, I get this error:</p>

<pre><code>$ kubectl apply -f test.yaml
error: error parsing test.yaml: error converting YAML to JSON: yaml: line 19: did not find expected key
</code></pre>

<p>The YAML</p>

<pre><code>$ cat test.yaml
apiVersion: batch/v1beta1
  kind: CronJob
  metadata:
    name: dummy
  spec:
    schedule: "*/1 * * * *"
    jobTemplate:
      spec:
        template:
          spec:
            containers:
            - name: app
              image: alpine
              command: 
              - echo
              - Hello World!
              volumeMounts:
              - mountPath: /data
                name: foo
            restartPolicy: OnFailure
            volumes:
            - name: foo
              emptyDir: {}
</code></pre>

<p>Based on my reading of the <a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#cronjob-v1beta1-batch" rel="nofollow noreferrer">API</a>, I believe my schema is legit. Any ideas or help would be greatly appreciated.</p>

windowsrefund
<p>I think it's indentation issue. Below yaml should work.</p>

<pre><code>apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: dummy
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: app
            image: alpine
            command:
            - echo
            - Hello World!
            volumeMounts:
            - mountPath: /data
              name: foo
          restartPolicy: OnFailure
          volumes:
          - name: foo
            emptyDir: {}
</code></pre>
