Bug 1748291 - oc new-app --file=<template containing cronjob> fails with valid apiVersion
Summary: oc new-app --file=<template containing cronjob> fails with valid apiVersion
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Templates
Version: 3.11.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: 3.11.z
Assignee: Adam Kaplan
QA Contact: XiuJuan Wang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-09-03 10:04 UTC by German Parente
Modified: 2023-03-24 15:22 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-21 13:45:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 4408671 0 None None None 2019-09-11 09:44:48 UTC

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


Note You need to log in before you can comment on or make changes to this bug.