Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

no matches for kind "CronJob" in version "batch/v1"

I use Kubernetes which v1.19.7, when I run the CronJob sample

apiVersion: batch/v1
kind: CronJob
metadata:
  name: express-learn-cronjob
spec:
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
            - name: hello
              image: busybox
              command:
                - /bin/sh
                - -c
                - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

get unable to recognize "app-cronjob.yml": no matches for kind "CronJob" in version "batch/v1"

I can get the batch info by run kubectl api-versions | grep batch

batch/v1
batch/v1beta1

is there anything I missed? how can I fix it?

like image 658
seven Avatar asked May 13 '21 14:05

seven


People also ask

What are Kubernetes Cronjobs?

A CronJob creates Jobs on a repeating schedule. One CronJob object is like one line of a crontab (cron table) file. It runs a job periodically on a given schedule, written in Cron format.

How do you deploy a CronJob?

In order to configure your deployment cron job, you must use the correct repository path. To locate the desired repository's directory, navigate to cPanel's Git Version Control interface (cPanel >> Home >> Files >> Git Version Control).

What version of Kubernetes does batch/v1 support cronjob?

get unable to recognize "app-cronjob.yml": no matches for kind "CronJob" in version "batch/v1" is there anything I missed? how can I fix it? Show activity on this post. For Kubernetes version 1.19.x you need to use batch/v1beta1 as apiVersion for your CronJob. It is stable only on k8s version 1.21.

What are some common cronjob errors?

Error from server (BadRequest): error when creating "cronjob.yml": CronJob in version "v2alpha1" cannot be handled as a ScheduledJob: no kind "CronJob" is registered for version "batch/v2alpha1"

What is a cronjob?

One CronJob object is like one line of a crontab (cron table) file. It runs a job periodically on a given schedule, written in Cron format. Note: All CronJob schedule: times are denoted in UTC.

How to generate cronjob schedule expressions?

To generate CronJob schedule expressions, you can also use web tools like crontab.guru. A cron job creates a job object about once per execution time of its schedule. We say "about" because there are certain circumstances where two jobs might be created, or no job might be created. We attempt to make these rare, but do not completely prevent them.


Video Answer


1 Answers

For Kubernetes version 1.19.x you need to use batch/v1beta1 as apiVersion for your CronJob.

That is documented in the doc version 1-19:

https://v1-19.docs.kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/

It is stable only on k8s version 1.21.

like image 80
Juliano Costa Avatar answered Oct 24 '22 09:10

Juliano Costa