Kubernetes CronJob Generator
Generate a Kubernetes CronJob in YAML with the schedule expression and the container to run. Schedule recurring tasks in your cluster and apply with kubectl.
YAML
—
Schedule a cluster task without nesting mistakes
You want a backup running at two in the morning inside the cluster, and the answer is a CronJob. The obstacle is the shape: a spec inside a jobTemplate inside a spec inside a template inside another spec, five levels before you reach the container. It is the Kubernetes object where indentation goes wrong most often, and where people give up and fall back to a crontab on some random box.
The output uses apiVersion batch/v1, the name you typed, the schedule in quotes and a single container called job running the image you gave it, with restartPolicy OnFailure. The quotes around the schedule are not decoration: without them, some expressions turn into something else in the YAML parser. There is no field for command or args, so the image has to do the right work in its own ENTRYPOINT.
The detail that catches almost everyone: the schedule runs in the controller time zone, usually UTC, unless you declare spec.timeZone. In Sao Paulo, a job set for 2am fires at 11pm the previous day. If the image is generic like alpine, add command and args after copying. And for a task that must never overlap the previous run, add concurrencyPolicy Forbid. The YAML is generated in the browser.
Frequently asked questions
Does the schedule use my local time zone?
How do I pass a command to the container?
Why do old Jobs pile up?
Related Tools
Kubernetes Secret Generator
Generate a Kubernetes Secret in YAML with values already base64-encoded. Store passwords and tokens safely and apply them to your cluster with kubectl.
Kubernetes ConfigMap Generator
Generate a Kubernetes ConfigMap in YAML from key=value pairs, ready to apply with kubectl. Centralize your pod configuration in seconds.
Kubernetes Ingress Generator
Generates a Kubernetes Ingress with host, service and port, using the nginx ingressClassName and a root path. The TLS block is yours to add.