Kubernetes CronJob Generator

Build a CronJob with the fields that actually decide its behaviour: the timezone, the starting deadline that prevents the 100 missed schedules cliff, and a hard timeout for a job that hangs rather than fails. The output is checked by our own validator as you type.

Job
Schedule

Five fields, and the day-of-month and day-of-week columns are ORed together when both are set.

Retries and cleanup
Resources

cronjob.yaml

updates as you type

    Common mistakes

    These are the ones that fail silently. The config is accepted, nothing raises an error, and the consequence arrives later.

    1. Leaving concurrencyPolicy at Allow

      Runs overlap when one takes longer than the interval, and they accumulate until the node runs out.

      Instead:Forbid for anything not safe to run twice, Replace where the newest run supersedes.

    2. Not setting the history limits

      Completed Jobs and their pods accumulate indefinitely, which clutters the namespace and eventually pressures etcd.

      Instead:Set successfulJobsHistoryLimit and failedJobsHistoryLimit deliberately.

    3. Assuming a missed schedule is caught up

      If the controller is down past startingDeadlineSeconds, the run is skipped entirely and only an event records it.

      Instead:Set startingDeadlineSeconds knowingly, and alert on missed schedules.

    The four things that break a CronJob

    A CronJob is a schedule wrapped around a Job wrapped around a pod, and each layer has its own timeout, its own retry count and its own idea of what failure means. Almost every CronJob problem is one of these four, and none of them produce an error at apply time.

    It runs in UTC unless you say otherwise

    There is no cluster timezone and no inherited one. Without spec.timeZone the schedule is interpreted in UTC by the controller manager, so a job written for 3am local time runs at 3am UTC. The field exists from 1.27; on anything older it is dropped silently and you are back in UTC without being told.

    spec:
      schedule: "0 3 * * *"
      timeZone: "Europe/London"    # 1.27 and later
    
    # without timeZone, "0 3 * * *" is 03:00 UTC, which is
    # 04:00 in London for half the year. The job does not
    # shift with daylight saving unless timeZone is set.

    The 100 missed schedules cliff

    This is the one almost nobody knows about. If startingDeadlineSeconds is unset, the controller counts every schedule it missed since the last successful run. Once that count passes 100 it stops scheduling the CronJob permanently, logs a single line, and sets no condition and no event that a dashboard would pick up. A per-minute job needs less than two hours of controller downtime to trip it.

    # a job every minute, controller down for 2 hours
    #   -> 120 missed schedules -> over the limit
    #   -> "Cannot determine if job needs to be started"
    #   -> never runs again until someone recreates it
    
    spec:
      startingDeadlineSeconds: 300
    
    # with a deadline set, the controller only looks back
    # 300 seconds, so the count can never reach 100.

    Overlapping runs are the default

    concurrencyPolicy defaults to Allow, so if a run takes longer than the interval the next one starts alongside it. For anything touching a database or a shared file this compounds: the slower it gets, the more copies are running, which makes it slower. Forbid skips the run entirely rather than queueing it, and Replace kills the one in flight.

    Allow     run 1 ####################
              run 2     ####################
              run 3         ####################
    
    Forbid    run 1 ####################
              run 2 (skipped, and it does not run later)
    
    Replace   run 1 ######x killed
              run 2       ####################

    Failure and hanging are different, and only one is handled

    backoffLimit counts failures. A job that hangs has not failed, so backoffLimit never fires and the job runs until something else stops it. That something has to be activeDeadlineSeconds. With concurrencyPolicy: Forbid, one hung job also blocks every future run indefinitely, which is how a CronJob stops silently.

    backoffLimit: 3            retries after a failure
    activeDeadlineSeconds: 3600  hard stop, failure or not
    
    # without the deadline:
    #   job hangs -> never fails -> never retried
    #   -> Forbid means run 2, 3, 4... are all skipped
    #   -> the schedule appears to have stopped working

    The name limit is 52, not 63

    The controller builds each Job name by appending a timestamp to the CronJob name, and Job names are limited to 63 characters like everything else. A CronJob name over 52 characters therefore applies cleanly and then fails to create every Job it schedules, with the error appearing only in the controller's events.

    metadata:
      name: a-52-character-name-at-most
    
    # controller creates: <name>-28472910
    #                            ^ up to 11 more characters

    More kubernetes tools

    Kubernetes YAML Generator Answer a few questions, get a manifest Kubernetes YAML Validator Is this YAML valid, and where is it wrong? Kubernetes Rollout & Probe Timing Restart loops, capacity dips and stuck drains Kubernetes Service Checker Will this Service have any endpoints? Kubernetes Network Policy Viewer What can reach what, and what just broke Kubernetes Manifest Diff What actually changed Kubernetes Resource Calculator What these manifests actually reserve Kubernetes RBAC Viewer Who can actually do what Kubernetes Deployment Generator See the capacity dip before you deploy Kubernetes Service Generator port, targetPort, and which one you meant Kubernetes StatefulSet Generator Stable names, and volumes that outlive you Kubernetes QoS Class Calculator And where you sit in the eviction order Kubernetes Node Capacity Planner Allocatable is not capacity Kubernetes Max Pods per Node Calculator The ENI limit, not the 110 default Kubernetes Label Selector Tester Which key failed, not just that one did Kubernetes Taint & Toleration Tester Tolerations permit, they do not attract Kubernetes Resource Name Validator RFC 1123 subdomain, label, or 1035 Kubernetes Label & Annotation Validator Why your image tag is not a legal label Kubernetes CrashLoopBackOff Guide The status is a timer, not a cause Kubernetes TLS Certificate Decoder When it expires, and what it covers Kubernetes ServiceAccount Token Decoder Bound or legacy, and when it dies Kubernetes imagePullSecret Generator The registry URL nobody gets right Kubernetes cert-manager Certificates Issuer scope, and the rate limit that costs a week Kubernetes Flux HelmRelease Generator With the source it cannot work without Kubernetes Helm Chart Generator Chart.yaml, values, and working templates Kubernetes Argo CD Application Generator The defaults that are off, turned on Kubernetes Ingress Generator pathType, and the TLS secret that fails quietly Kubernetes HPA Generator Why it says unknown and never scales Kubernetes SecurityContext Generator Pod level, container level, and which wins Kubernetes Probe Generator How long it gets to start before liveness kills it Kubernetes PVC Generator Access modes your storage can actually do Kubernetes ResourceQuota Generator And the LimitRange that stops it breaking deploys Kubernetes NetworkPolicy Generator With the DNS rule already in it Kubernetes RBAC Generator And what it actually grants Kubernetes PodDisruptionBudget Generator Can this budget ever be satisfied? Kubernetes API Deprecation Checker What breaks on the next upgrade Kubernetes Kubeconfig Viewer Read it without handing it to anyone Kubernetes Quantity Parser What 512Mi, 100m and 1e3 actually mean Kubernetes Multi-Document YAML Splitter One file per object, in apply order Kubernetes .env to ConfigMap & Secret Split the credentials out on the way Kubernetes Secret Decoder See what is actually in there Kubernetes Ingress to Gateway API Which annotations silently stop working Kubernetes Manifest Visualizer What points at what, and what points at nothing Kubernetes Patch Tester Which --type, and what it deletes Kubernetes kubectl JSONPath Tester kubectl's dialect, not generic JSONPath Kubernetes Node Affinity Tester Required excludes, preferred only scores Kubernetes Helm Values Diff A missing key is a third value Kubernetes Pod and Service CIDR Fixed at cluster creation Kubernetes Secret Encoder base64 is not encryption Kubernetes API Version Checker Will this apply on that cluster Kubernetes Go Template Tester Go truthiness is not JavaScript's Kubernetes Cluster Cost Estimator At your rates, not a price table Kubernetes Kustomize Build Transformers run in kustomize's order Kubernetes Helm Chart Validator version is SemVer, appVersion is not

    Elsewhere on the site