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?
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.
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).
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.
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"
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With