Unable to create CronJob using a Template : no kind "CronJob" is registered for version "batch/v1beta1"

Solution Verified - Updated -

Issue

Create a Cronjob as part of a template is failing.

  • create template Template.yaml including a Cronjob
kind: Template
apiVersion: "template.openshift.io/v1"
metadata:
  creationTimestamp: null
  name: test-cronjob
objects:
- apiVersion: batch/v1beta1
  kind: CronJob
  metadata:
    name: cronjobtest
  spec:
    concurrencyPolicy: Allow
    failedJobsHistoryLimit: 7
    jobTemplate:
      metadata:
        creationTimestamp: null
      spec:
        template:
          metadata:
            creationTimestamp: null
          spec:
            containers:
            - command:
              - /bin/bash
              - -c
              - pwd
              image: test
              imagePullPolicy: Always
              name: job-publier
              terminationMessagePath: /dev/termination-log
              terminationMessagePolicy: File
            dnsPolicy: ClusterFirst
            restartPolicy: OnFailure
            schedulerName: default-scheduler
            securityContext: {}
            terminationGracePeriodSeconds: 30
    schedule: 00 09 * * 1
    successfulJobsHistoryLimit: 7
    suspend: false
  • Create a new application from the template:
oc new-app --file=./Template.yaml

It will fail with the mentioned error.

Environment

Red Hat OpenShift Container Platform 3.11

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content