CronJob¶
A wrapper for defining Kubernetes CronJob resources within Piceli.
CronJobs in Kubernetes allow you to run jobs on a time-based schedule. These jobs can be anything from a simple maintenance task to a batch job that runs at specific intervals. The CronJob class in Piceli extends the Job class, incorporating scheduling capabilities on top of the standard job configuration.
Properties¶
schedule: Defines the schedule on which the job should be run. Uses theCronTabformat to specify the timing.name,labels,backoff_limit, and pod spec are inherited from theJobclass.
Example¶
from piceli.k8s.templates import CronJob, CronTab
my_cron_job = CronJob(
name="example-cronjob",
schedule=CronTab("0 */3 * * *"), # Every 3 hours
labels={"app": "myapp"},
backoff_limit=2,
)
This example defines a CronJob named “example-cronjob” scheduled to run every 3 hours, with a specific set of labels and a backoff limit.