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

Bug 1806965

Summary: API version for cronjobs is not compatible.
Product: OpenShift Container Platform Reporter: David Hernández Fernández <dahernan>
Component: TemplatesAssignee: Adam Kaplan <adam.kaplan>
Status: CLOSED DUPLICATE QA Contact: XiuJuan Wang <xiuwang>
Severity: low Docs Contact:
Priority: low    
Version: 4.4CC: adam.kaplan, aos-bugs, fminafra, jokerman, wzheng, yinzhou
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-06 14:47:24 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 David Hernández Fernández 2020-02-25 11:22:29 UTC
Description of problem: Alerts in OCP 4.x cluster are flooded as per following: "A client in the cluster is using deprecated apps/v1beta1 API that will be removed soon." 
It is caused by "apiVersion: batch/v1beta1"  used in CronJobs.

- https://docs.openshift.com/container-platform/4.3/nodes/jobs/nodes-nodes-jobs.html#nodes-nodes-jobs-creating-cron_nodes-nodes-jobs
- error: unable to recognize "build-pruner.yml": no matches for kind "CronJob" in version "batch/v1"

Other version does not work neither:
~~~
batch/v1 doesn't work also:
- error: unable to recognize "test.yml": no matches for kind "CronJob" in version "batch/v1"

apps/v1 does not work also:
error: unable to recognize "build-pruner.yml": no matches for kind "CronJob" in version "apps/v1"
~~~

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

How reproducible: 100%


Steps to Reproduce:
1. Following examples of cronjobs on https://docs.openshift.com/container-platform/4.3/nodes/jobs/nodes-nodes-jobs.html#nodes-nodes-jobs-creating-cron_nodes-nodes-jobs

Actual results:
$ oc create -f build-pruner.yml 
error: unable to recognize "build-pruner.yml": no matches for kind "CronJob" in version "apps/v1"

$ oc create -f build-pruner.yml 
error: unable to recognize "build-pruner.yml": no matches for kind "CronJob" in version "batch/v1"

$ oc create -f build-pruner.yml 
error: unable to recognize "build-pruner.yml": no matches for kind "CronJob" in version "batch/v1beta1"

Expected results:
API version recognized.

Additional info: Similar to BZ1748291 in OCP 3.11.

Also, checking all the references by
~~~
$ oc get all --all-namespaces -o 'jsonpath={range .items[*]}{.metadata.annotations.kubectl\.kubernetes\.io/last-applied-configuration}{"\n"}{end}' | grep '"apiVersion":"extensions/v1beta1"'
$ oc get all --all-namespaces -o 'jsonpath={range .items[*]}{.metadata.annotations.kubectl\.kubernetes\.io/last-applied-configuration}{"\n"}{end}' | grep '"apiVersion":"apps/v1beta'
~~~

Until 3.9 it was batch/v2alpha1, now should be batch/v1beta1. This change is not reflected  in the documentation : 
https://docs.openshift.com/container-platform/3.11/rest_api/apis-batch/v2alpha1.CronJob.html

Comment 1 David Hernández Fernández 2020-03-23 14:47:15 UTC
@Adam, might be worth to check if it is a duplicate of https://github.com/openshift/origin/pull/24089 #BZ:1768766
Thanks for your time, i think we could archive this case if you confirm it, thanks.

Comment 2 Adam Kaplan 2020-04-06 14:47:24 UTC
The supported APIVersion for CronJob is still batch/v1beta1. All other API versions are deprecated and/or removed. I doubt that CronJob is the source of these alerts - please check that there are no one-off `Job` objects using the batch/v1beta1 API.

Closing this as a duplicate of 1768766

*** This bug has been marked as a duplicate of bug 1768766 ***