Home > Blockchain >  error validating data: [ValidationError(CronJob.spec.jobTemplate.spec.template.spec): unknown field
error validating data: [ValidationError(CronJob.spec.jobTemplate.spec.template.spec): unknown field

Time:02-16

This is my yaml file that i am trying to use for cronJob creation. I am getting error like unknown field "container" in io.k8s.api.core.v1.PodSpec,

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: abc-service-cron-job
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          container:
          - name: abc-service-cron-job
            image: docker.repo1.xyz.com/hui-services/abc-application/REPLACE_ME
            imagePullPolicy: Always
            command:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure  

CodePudding user response:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  ...
spec:
  ...
  jobTemplate:
    spec:
      template:
        spec:
          containers:  # <-- you have spelling error here, should be "containers"
          ...
  • Related