Cron Job in Openshift not a valid Template but *batch.CronJob with yml

7/6/2018

I am trying to make a cron job in Openshift but I got this error:

error: unable to parse "openshift/cronJob-template.yml", not a valid Template but *batch.CronJob

I ran this command:

oc process -f openshift/cronJob-template.yml -p namespace=test-project | oc apply -f -

My yml looks like:

apiVersion: batch/v2alpha1
kind: CronJob
metadata:
  name: demo
spec:
  schedule: "*/30 2 * * *"
  jobTemplate:
    spec:
      template:
        metadata:
          labels:
            parent: "demo"
        spec:
          containers:
          - name: demo
            image: demo
            command: ["java",  "-jar", "test.jar"]
          restartPolicy: OnFailure

I did have my schedule looking like the following but I am not sure if it is correct in a yml file schedule: "*/30 2 * * * /tmp/logs"

This is my first time creating a cron job via ymland on Openshift so I apologise.

-- Mike3355
kubernetes
openshift
openshift-enterprise
yaml

1 Answer

7/6/2018

The template looks ok. Try run oc create -f openshift/cronJob-template.yml -n test-project instead.

-- PhilipGough
Source: StackOverflow