Class: CDK8sPlus25::K8S::CronJobSpec

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
k8_s/cron_job_spec.rb

Overview

CronJobSpec describes how the job execution will look like and when it will actually run.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_template:, schedule:, concurrency_policy: nil, failed_jobs_history_limit: nil, starting_deadline_seconds: nil, successful_jobs_history_limit: nil, suspend: nil, time_zone: nil) ⇒ CronJobSpec

Returns a new instance of CronJobSpec.

Parameters:

  • job_template (CDK8sPlus25::K8S::JobTemplateSpec)

    Specifies the job that will be created when executing a CronJob.

  • schedule (String)

    The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.

  • concurrency_policy (String, nil) (defaults to: nil)

    Specifies how to treat concurrent executions of a Job.

  • failed_jobs_history_limit (Numeric, nil) (defaults to: nil)

    The number of failed finished jobs to retain.

  • starting_deadline_seconds (Numeric, nil) (defaults to: nil)

    Optional deadline in seconds for starting the job if it misses scheduled time for any reason.

  • successful_jobs_history_limit (Numeric, nil) (defaults to: nil)

    The number of successful finished jobs to retain.

  • suspend (Boolean, nil) (defaults to: nil)

    This flag tells the controller to suspend subsequent executions, it does not apply to already started executions.

  • time_zone (String, nil) (defaults to: nil)

    The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. If not specified, this will default to the time zone of the kube-controller-manager process. The set of valid time zone names and the time zone offset is loaded from the system-wide time zone database by the API server during CronJob validation and the controller manager during execution. If no system-wide time zone database can be found a bundled version of the database is used instead. If the time zone name becomes invalid during the lifetime of a CronJob or due to a change in host configuration, the controller will stop creating new new Jobs and will create a system event with the reason UnknownTimeZone. More information can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones This is beta field and must be enabled via the CronJobTimeZone feature gate.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'k8_s/cron_job_spec.rb', line 15

def initialize(job_template:, schedule:, concurrency_policy: nil, failed_jobs_history_limit: nil, starting_deadline_seconds: nil, successful_jobs_history_limit: nil, suspend: nil, time_zone: nil)
  @job_template = job_template.is_a?(Hash) ? ::CDK8sPlus25::K8S::JobTemplateSpec.new(**job_template.transform_keys(&:to_sym)) : job_template
  Jsii::Type.check_type(@job_template, "eyJmcW4iOiJjZGs4cy1wbHVzLTI1Lms4cy5Kb2JUZW1wbGF0ZVNwZWMifQ==", "jobTemplate")
  @schedule = schedule
  Jsii::Type.check_type(@schedule, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "schedule")
  @concurrency_policy = concurrency_policy
  Jsii::Type.check_type(@concurrency_policy, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "concurrencyPolicy") unless @concurrency_policy.nil?
  @failed_jobs_history_limit = failed_jobs_history_limit
  Jsii::Type.check_type(@failed_jobs_history_limit, "eyJwcmltaXRpdmUiOiJudW1iZXIifQ==", "failedJobsHistoryLimit") unless @failed_jobs_history_limit.nil?
  @starting_deadline_seconds = starting_deadline_seconds
  Jsii::Type.check_type(@starting_deadline_seconds, "eyJwcmltaXRpdmUiOiJudW1iZXIifQ==", "startingDeadlineSeconds") unless @starting_deadline_seconds.nil?
  @successful_jobs_history_limit = successful_jobs_history_limit
  Jsii::Type.check_type(@successful_jobs_history_limit, "eyJwcmltaXRpdmUiOiJudW1iZXIifQ==", "successfulJobsHistoryLimit") unless @successful_jobs_history_limit.nil?
  @suspend = suspend
  Jsii::Type.check_type(@suspend, "eyJwcmltaXRpdmUiOiJib29sZWFuIn0=", "suspend") unless @suspend.nil?
  @time_zone = time_zone
  Jsii::Type.check_type(@time_zone, "eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==", "timeZone") unless @time_zone.nil?
end

Instance Attribute Details

#concurrency_policyString? (readonly)

Specifies how to treat concurrent executions of a Job.

Valid values are: - "Allow" (default): allows CronJobs to run concurrently; - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet; - "Replace": cancels currently running job and replaces it with a new one

Returns:

  • (String, nil)


47
48
49
# File 'k8_s/cron_job_spec.rb', line 47

def concurrency_policy
  @concurrency_policy
end

#failed_jobs_history_limitNumeric? (readonly)

Note:

Default: 1.

The number of failed finished jobs to retain.

Value must be non-negative integer. Defaults to 1.

Returns:

  • (Numeric, nil)


54
55
56
# File 'k8_s/cron_job_spec.rb', line 54

def failed_jobs_history_limit
  @failed_jobs_history_limit
end

#job_templateCDK8sPlus25::K8S::JobTemplateSpec (readonly)

Specifies the job that will be created when executing a CronJob.



37
38
39
# File 'k8_s/cron_job_spec.rb', line 37

def job_template
  @job_template
end

#scheduleString (readonly)

The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.

Returns:

  • (String)


41
42
43
# File 'k8_s/cron_job_spec.rb', line 41

def schedule
  @schedule
end

#starting_deadline_secondsNumeric? (readonly)

Optional deadline in seconds for starting the job if it misses scheduled time for any reason.

Missed jobs executions will be counted as failed ones.

Returns:

  • (Numeric, nil)


60
61
62
# File 'k8_s/cron_job_spec.rb', line 60

def starting_deadline_seconds
  @starting_deadline_seconds
end

#successful_jobs_history_limitNumeric? (readonly)

Note:

Default: 3.

The number of successful finished jobs to retain.

Value must be non-negative integer. Defaults to 3.

Returns:

  • (Numeric, nil)


67
68
69
# File 'k8_s/cron_job_spec.rb', line 67

def successful_jobs_history_limit
  @successful_jobs_history_limit
end

#suspendBoolean? (readonly)

Note:

Default: false.

This flag tells the controller to suspend subsequent executions, it does not apply to already started executions.

Defaults to false.

Returns:

  • (Boolean, nil)


74
75
76
# File 'k8_s/cron_job_spec.rb', line 74

def suspend
  @suspend
end

#time_zoneString? (readonly)

The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. If not specified, this will default to the time zone of the kube-controller-manager process. The set of valid time zone names and the time zone offset is loaded from the system-wide time zone database by the API server during CronJob validation and the controller manager during execution. If no system-wide time zone database can be found a bundled version of the database is used instead. If the time zone name becomes invalid during the lifetime of a CronJob or due to a change in host configuration, the controller will stop creating new new Jobs and will create a system event with the reason UnknownTimeZone. More information can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones This is beta field and must be enabled via the CronJobTimeZone feature gate.

Returns:

  • (String, nil)


78
79
80
# File 'k8_s/cron_job_spec.rb', line 78

def time_zone
  @time_zone
end

Class Method Details

.jsii_propertiesObject



80
81
82
83
84
85
86
87
88
89
90
91
# File 'k8_s/cron_job_spec.rb', line 80

def self.jsii_properties
  {
    :job_template => "jobTemplate",
    :schedule => "schedule",
    :concurrency_policy => "concurrencyPolicy",
    :failed_jobs_history_limit => "failedJobsHistoryLimit",
    :starting_deadline_seconds => "startingDeadlineSeconds",
    :successful_jobs_history_limit => "successfulJobsHistoryLimit",
    :suspend => "suspend",
    :time_zone => "timeZone",
  }
end

Instance Method Details

#to_jsiiObject



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'k8_s/cron_job_spec.rb', line 93

def to_jsii
  result = {}
  result.merge!({
    "jobTemplate" => @job_template,
    "schedule" => @schedule,
    "concurrencyPolicy" => @concurrency_policy,
    "failedJobsHistoryLimit" => @failed_jobs_history_limit,
    "startingDeadlineSeconds" => @starting_deadline_seconds,
    "successfulJobsHistoryLimit" => @successful_jobs_history_limit,
    "suspend" => @suspend,
    "timeZone" => @time_zone,
  })
  result.compact
end