Hi, I was unable to create a cronjob & pv, used the k8 doc template and ende . . .

Poorni:
Hi, I was unable to create a cronjob & pv, used the k8 doc template and ended up error,
"error: unable to recognize “a.yaml”: no matches for kind “CronJob” in version “batch/v1”

Googled and found beta1 needs to be added in api version & due to k8 version
apiVersion: batch/v1beta1 instead of apiVersion: batch/v1

In exam how do we manage these…

Only thought came to me was to create a template using imperative commands.
Not all resources can be created using imperative commands too!! like PV,PVC.
Any thoughts / help. Greatly appreciate…

Tej_Singh_Rana:
Hello, @Poorni
In official exam, we will get 1.21 k8s version. So please check in the official k8s docs, which apiVersion used by cronjob.
For 1.21, It’s definitely “batch/v1”.

Tej_Singh_Rana:
> Only thought came to me was to create a template using imperative commands.
> Not all resources can be created using imperative commands too!! like PV,PVC.
Copy template from k8s docs.

Dhawan Shringi:
@Tej_Singh_Rana I noticed it was incorrect in the docs. @Poorni I think this is one off instance and you just have to keep that in mind and if you face such an issue, just use kubectl api-resources.

unnivkn:
Hi… You need to use apiVersion: batch/v1beta1 to work this in our lab. Where as in exam since its latest version, apiVersion: batch/v1 will work. Use imperative command in our lab, so you won’t get any error.

kubectl create cronjob my-job --image=busybox --schedule="*/1 * * * *" -- dat

https://kodekloud.slack.com/archives/CDR4R9Z7E/p1623644307294400

techlead.93:
If you ever want to find out the apiVersion of a resource in your environment run this:

kubectl explain <resource>