<p>I would like to create a cronjob in Kubernetes cluster. I got errors. It seems like errors in my yaml file. But I have no clue what the correct syntax is.</p>
<p>kubectl apply -f converter-86-cron.yaml</p>
<p>error: error validating &quot;converter-86-cron.yaml&quot;: error validating data: ValidationError(CronJob.spec.jobTemplate.spec.template.spec): unknown field &quot;selector&quot; in io.k8s.api.core.v1.PodSpec; if you choose to ignore these errors, turn validation off with --validate=false</p>
<p>code:</p>
<pre><code>  apiVersion: batch/v1
  kind: CronJob
  metadata:
    name: converter-86-cron
    namespace: converter
  spec:
    schedule: &quot;0 10 * * *&quot; # 3 AM PST
    jobTemplate:
      spec:
        template:
          metadata:
            namespace: converter
            labels:
              name: converter-86-cron
          spec:
            selector:
              matchLabels:
                architecture: &quot;8.6&quot;
            containers:
              - name: convert
                image: &quot;accountID.dkr.ecr.ap-northeast-2.amazonaws.com/converter:1.1.1b9.2004.cu114.12345668&quot;
                resources:
                  requests:
                    nvidia.com/gpu: 1
                    cpu: 2
                  limits:
                    nvidia.com/gpu: 1
                args:
                - python3
                - trt-converter.py
                - --awsdev
            tolerations:
            - key: &quot;nvidia.com/gpu&quot;
              operator: &quot;Exists&quot;
              effect: &quot;NoSchedule&quot;
            restartPolicy: Never
</code></pre>
<p>New code with nodeSelector. Not sure if it is correct.</p>
<pre><code>  apiVersion: batch/v1
  kind: CronJob
  metadata:
    name: converter-86-cron
    namespace: converter
  spec:
    schedule: &quot;0 10 * * *&quot; # 3 AM PST
    jobTemplate:
      spec:
        template:
          metadata:
            namespace: converter
            labels:
              name: converter-86-cron
          spec:
            nodeSelector:
              architecture: &quot;8.6&quot;
            containers:
              - name: convert
                image: &quot;accountID.dkr.ecr.ap-northeast-2.amazonaws.com/converter:1.1.1b9.2004.cu114.12345668&quot;
                resources:
                  requests:
                    nvidia.com/gpu: 1
                    cpu: 2
                  limits:
                    nvidia.com/gpu: 1
                args:
                - python3
                - trt-converter.py
                - --awsdev
            tolerations:
            - key: &quot;nvidia.com/gpu&quot;
              operator: &quot;Exists&quot;
              effect: &quot;NoSchedule&quot;
            restartPolicy: Never
</code></pre>

user20208419
<p>You should read <code>CronJob.spec.jobTemplate.spec.template.spec</code> as a tree..
so under CronJob -&gt; spec -&gt; jobTemplate and so on...
so in your case the <code>selector:</code> under <code>spec:</code> at line 16 above is the invalid field.</p>
<p>You should refer to documentation on how exactly or where exactly you should put the selector/label and architecture.</p>
