Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1748291

Summary: oc new-app --file=<template containing cronjob> fails with valid apiVersion
Product: OpenShift Container Platform Reporter: German Parente <gparente>
Component: TemplatesAssignee: Adam Kaplan <adam.kaplan>
Status: CLOSED WONTFIX QA Contact: XiuJuan Wang <xiuwang>
Severity: low Docs Contact:
Priority: unspecified    
Version: 3.11.0CC: aos-bugs, csekar, jokerman, mfojtik, wzheng
Target Milestone: ---   
Target Release: 3.11.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-21 13:45:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description German Parente 2019-09-03 10:04:03 UTC
Description of problem:

seems that creating a cronjob from a template fails not matching the right apiversion:

1)  kubectl api-versions | grep batch
batch/v1
batch/v1beta1

2) cat cronjob.yaml


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

3) 

oc new-app --file=./cronjob.yaml
--> Deploying template "mytest/test-cronjob" for "./cronjob.yaml" to project mytest

--> Creating resources ...
    error: no kind "CronJob" is registered for version "batch/v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:29"
--> Failed


Version-Release number of selected component (if applicable):

oc version
oc v3.11.135
kubernetes v1.11.0+d4cacc0
features: Basic-Auth GSSAPI Kerberos SPNEGO

Server https://openshift.internal.newparente.lab.pnq2.cee.redhat.com:443
openshift v3.11.135
kubernetes v1.11.0+d4cacc0



Additional info:


The workaround is:

oc process -f cronjob.yaml -o yaml  | oc apply -f -

or define only a cronjob resource and:

oc apply -f ./cronjob.yaml

Comment 1 Maciej Szulik 2019-09-03 14:46:51 UTC
This part of oc belongs to devexp, sending it that way. This looks to work fine with oc 4.x