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…
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”.
> 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.
@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.
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
If you ever want to find out the apiVersion of a resource in your environment run this:
kubectl explain <resource>