Kubernetes Create Job from Cronjob not working

Gautam S. K. Singhania picture Gautam S. K. Singhania · Aug 24, 2021 · Viewed 8.5k times · Source

I have a Kubernetes cluster with following versions:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.1", GitCommit:"632ed300f2c34f6d6d15ca4cef3d3c7073412212", GitTreeState:"clean", BuildDate:"2021-08-19T15:38:26Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.13", GitCommit:"aac5f64a5218b0b1d0138a57d273a12db99390c9", GitTreeState:"clean", BuildDate:"2021-01-18T07:43:30Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}
WARNING: version difference between client (1.22) and server (1.16) exceeds the supported minor version skew of +/-1

I have a cron job in my Kubernetes cluster.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
   name: abc-cronjob
   namespace: abc-namespace
...

The Kubernetes cluster recognizes the api resource for the cron job.

$ kubernetes -n abc-namespace api-resources
NAME                              SHORTNAMES   APIVERSION                        NAMESPACED   KIND
...
cronjobs                          cj           batch/v1beta1                     true         CronJob
...

I am trying to create a manual job for this, but am facing this error.

$ kubernetes -n abc-namespace create job abc-job --from=cronjob/abc-cronjob
error: unknown object type *v1beta1.CronJob

Can anyone help in this?

Answer

Gautam S. K. Singhania picture Gautam S. K. Singhania · Aug 24, 2021

Got the issue now. The version difference was causing the main problem. Installed the version matching the one in server side and ran the query again without issues.