Skip to content

CronJob

Gregory Nickonov edited this page Mar 4, 2019 · 3 revisions

Quick Start

R.cron_job 'logs-cleaner' do
  # Run midnight UTC every single day
  schedule '0 0 * * *'

  # Default restart policy is :OnFailure, see below
  pod_template_spec.restart_policy :Never

  container do
    # Setup main container
  end
end

CronJob is one of the Pod Template Owners, so all methods, like pod_template and container are available.

Default restart policy

By default, Pod's restart_policy is Always, but this value is invalid for CronJobs and leads to the error when creating the CronJob. To simplify development, in Sunstone default value for restart policy is OnFailure, so if you don't want the CronJob to be restarted in case of failure don't' forget to set the value to Never.

CronJob

Kubernetes Documentation

Sunstone property Kubernetes property Type
metadata metadata Kubernetes Object Metadata
spec spec CronJobSpec

schedule

A shortcut to spec.schedule, used to specify a run schedule in the Cron format.

CronJobSpec

Kubernetes Documentation

Sunstone property Kubernetes property Type
concurrency_policy concurrencyPolicy String
failed_jobs_history_limit failedJobsHistoryLimit Integer
job_template jobTemplate JobTemplateSpec
schedule schedule String
successful_jobs_history_limit successfulJobsHistoryLimit Integer
suspend suspend Boolean

JobTemplateSpec

Kubernetes Documentation

Sunstone property Kubernetes property Type
metadata metadata Kubernetes Object Metadata
spec spec JobSpec
Clone this wiki locally