Class: Kubernetes::V1JobSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/kubernetes/models/v1_job_spec.rb

Overview

JobSpec describes how the job execution will look like.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ V1JobSpec

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# File 'lib/kubernetes/models/v1_job_spec.rb', line 120

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Kubernetes::V1JobSpec` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `Kubernetes::V1JobSpec`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'active_deadline_seconds')
    self.active_deadline_seconds = attributes[:'active_deadline_seconds']
  end

  if attributes.key?(:'backoff_limit')
    self.backoff_limit = attributes[:'backoff_limit']
  end

  if attributes.key?(:'backoff_limit_per_index')
    self.backoff_limit_per_index = attributes[:'backoff_limit_per_index']
  end

  if attributes.key?(:'completion_mode')
    self.completion_mode = attributes[:'completion_mode']
  end

  if attributes.key?(:'completions')
    self.completions = attributes[:'completions']
  end

  if attributes.key?(:'managed_by')
    self.managed_by = attributes[:'managed_by']
  end

  if attributes.key?(:'manual_selector')
    self.manual_selector = attributes[:'manual_selector']
  end

  if attributes.key?(:'max_failed_indexes')
    self.max_failed_indexes = attributes[:'max_failed_indexes']
  end

  if attributes.key?(:'parallelism')
    self.parallelism = attributes[:'parallelism']
  end

  if attributes.key?(:'pod_failure_policy')
    self.pod_failure_policy = attributes[:'pod_failure_policy']
  end

  if attributes.key?(:'pod_replacement_policy')
    self.pod_replacement_policy = attributes[:'pod_replacement_policy']
  end

  if attributes.key?(:'selector')
    self.selector = attributes[:'selector']
  end

  if attributes.key?(:'success_policy')
    self.success_policy = attributes[:'success_policy']
  end

  if attributes.key?(:'suspend')
    self.suspend = attributes[:'suspend']
  end

  if attributes.key?(:'template')
    self.template = attributes[:'template']
  end

  if attributes.key?(:'ttl_seconds_after_finished')
    self.ttl_seconds_after_finished = attributes[:'ttl_seconds_after_finished']
  end
end

Instance Attribute Details

#active_deadline_secondsObject

Specifies the duration in seconds relative to the startTime that the job may be continuously active before the system tries to terminate it; value must be positive integer. If a Job is suspended (at creation or through an update), this timer will effectively be stopped and reset when the Job is resumed again.



20
21
22
# File 'lib/kubernetes/models/v1_job_spec.rb', line 20

def active_deadline_seconds
  @active_deadline_seconds
end

#backoff_limitObject

Specifies the number of retries before marking this job failed. Defaults to 6, unless backoffLimitPerIndex (only Indexed Job) is specified. When backoffLimitPerIndex is specified, backoffLimit defaults to 2147483647.



23
24
25
# File 'lib/kubernetes/models/v1_job_spec.rb', line 23

def backoff_limit
  @backoff_limit
end

#backoff_limit_per_indexObject

Specifies the limit for the number of retries within an index before marking this index as failed. When enabled the number of failures per index is kept in the pod’s batch.kubernetes.io/job-index-failure-count annotation. It can only be set when Job’s completionMode=Indexed, and the Pod’s restart policy is Never. The field is immutable.



26
27
28
# File 'lib/kubernetes/models/v1_job_spec.rb', line 26

def backoff_limit_per_index
  @backoff_limit_per_index
end

#completion_modeObject

completionMode specifies how Pod completions are tracked. It can be ‘NonIndexed` (default) or `Indexed`. `NonIndexed` means that the Job is considered complete when there have been .spec.completions successfully completed Pods. Each Pod completion is homologous to each other. `Indexed` means that the Pods of a Job get an associated completion index from 0 to (.spec.completions - 1), available in the annotation batch.kubernetes.io/job-completion-index. The Job is considered complete when there is one successfully completed Pod for each index. When value is `Indexed`, .spec.completions must be specified and `.spec.parallelism` must be less than or equal to 10^5. In addition, The Pod name takes the form `$(job-name)-$(index)-$(random-string)`, the Pod hostname takes the form `$(job-name)-$(index)`. More completion modes can be added in the future. If the Job controller observes a mode that it doesn’t recognize, which is possible during upgrades due to version skew, the controller skips updates for the Job.



29
30
31
# File 'lib/kubernetes/models/v1_job_spec.rb', line 29

def completion_mode
  @completion_mode
end

#completionsObject

Specifies the desired number of successfully finished pods the job should be run with. Setting to null means that the success of any pod signals the success of all pods, and allows parallelism to have any positive value. Setting to 1 means that parallelism is limited to 1 and the success of that pod signals the success of the job. More info: kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/



32
33
34
# File 'lib/kubernetes/models/v1_job_spec.rb', line 32

def completions
  @completions
end

#managed_byObject

ManagedBy field indicates the controller that manages a Job. The k8s Job controller reconciles jobs which don’t have this field at all or the field value is the reserved string ‘kubernetes.io/job-controller`, but skips reconciling Jobs with a custom value for this field. The value must be a valid domain-prefixed path (e.g. acme.io/foo) - all characters before the first "/" must be a valid subdomain as defined by RFC 1123. All characters trailing the first "/" must be valid HTTP Path characters as defined by RFC 3986. The value cannot exceed 63 characters. This field is immutable.



35
36
37
# File 'lib/kubernetes/models/v1_job_spec.rb', line 35

def managed_by
  @managed_by
end

#manual_selectorObject

manualSelector controls generation of pod labels and pod selectors. Leave ‘manualSelector` unset unless you are certain what you are doing. When false or unset, the system pick labels unique to this job and appends those labels to the pod template. When true, the user is responsible for picking unique labels and specifying the selector. Failure to pick a unique label may cause this and other jobs to not function correctly. However, You may see `manualSelector=true` in jobs that were created with the old `extensions/v1beta1` API. More info: kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#specifying-your-own-pod-selector



38
39
40
# File 'lib/kubernetes/models/v1_job_spec.rb', line 38

def manual_selector
  @manual_selector
end

#max_failed_indexesObject

Specifies the maximal number of failed indexes before marking the Job as failed, when backoffLimitPerIndex is set. Once the number of failed indexes exceeds this number the entire Job is marked as Failed and its execution is terminated. When left as null the job continues execution of all of its indexes and is marked with the ‘Complete` Job condition. It can only be specified when backoffLimitPerIndex is set. It can be null or up to completions. It is required and must be less than or equal to 10^4 when is completions greater than 10^5.



41
42
43
# File 'lib/kubernetes/models/v1_job_spec.rb', line 41

def max_failed_indexes
  @max_failed_indexes
end

#parallelismObject

Specifies the maximum desired number of pods the job should run at any given time. The actual number of pods running in steady state will be less than this number when ((.spec.completions - .status.successful) < .spec.parallelism), i.e. when the work left to do is less than max parallelism. More info: kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/



44
45
46
# File 'lib/kubernetes/models/v1_job_spec.rb', line 44

def parallelism
  @parallelism
end

#pod_failure_policyObject

Returns the value of attribute pod_failure_policy.



46
47
48
# File 'lib/kubernetes/models/v1_job_spec.rb', line 46

def pod_failure_policy
  @pod_failure_policy
end

#pod_replacement_policyObject

podReplacementPolicy specifies when to create replacement Pods. Possible values are: - TerminatingOrFailed means that we recreate pods when they are terminating (has a metadata.deletionTimestamp) or failed. - Failed means to wait until a previously created Pod is fully terminated (has phase Failed or Succeeded) before creating a replacement Pod. When using podFailurePolicy, Failed is the the only allowed value. TerminatingOrFailed and Failed are allowed values when podFailurePolicy is not in use.



49
50
51
# File 'lib/kubernetes/models/v1_job_spec.rb', line 49

def pod_replacement_policy
  @pod_replacement_policy
end

#selectorObject

Returns the value of attribute selector.



51
52
53
# File 'lib/kubernetes/models/v1_job_spec.rb', line 51

def selector
  @selector
end

#success_policyObject

Returns the value of attribute success_policy.



53
54
55
# File 'lib/kubernetes/models/v1_job_spec.rb', line 53

def success_policy
  @success_policy
end

#suspendObject

suspend specifies whether the Job controller should create Pods or not. If a Job is created with suspend set to true, no Pods are created by the Job controller. If a Job is suspended after creation (i.e. the flag goes from false to true), the Job controller will delete all active Pods associated with this Job. Users must design their workload to gracefully handle this. Suspending a Job will reset the StartTime field of the Job, effectively resetting the ActiveDeadlineSeconds timer too. Defaults to false.



56
57
58
# File 'lib/kubernetes/models/v1_job_spec.rb', line 56

def suspend
  @suspend
end

#templateObject

Returns the value of attribute template.



58
59
60
# File 'lib/kubernetes/models/v1_job_spec.rb', line 58

def template
  @template
end

#ttl_seconds_after_finishedObject

ttlSecondsAfterFinished limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. When the Job is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the Job won’t be automatically deleted. If this field is set to zero, the Job becomes eligible to be deleted immediately after it finishes.



61
62
63
# File 'lib/kubernetes/models/v1_job_spec.rb', line 61

def ttl_seconds_after_finished
  @ttl_seconds_after_finished
end

Class Method Details

.acceptable_attributesObject

Returns all the JSON keys this model knows about



86
87
88
# File 'lib/kubernetes/models/v1_job_spec.rb', line 86

def self.acceptable_attributes
  attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/kubernetes/models/v1_job_spec.rb', line 64

def self.attribute_map
  {
    :'active_deadline_seconds' => :'activeDeadlineSeconds',
    :'backoff_limit' => :'backoffLimit',
    :'backoff_limit_per_index' => :'backoffLimitPerIndex',
    :'completion_mode' => :'completionMode',
    :'completions' => :'completions',
    :'managed_by' => :'managedBy',
    :'manual_selector' => :'manualSelector',
    :'max_failed_indexes' => :'maxFailedIndexes',
    :'parallelism' => :'parallelism',
    :'pod_failure_policy' => :'podFailurePolicy',
    :'pod_replacement_policy' => :'podReplacementPolicy',
    :'selector' => :'selector',
    :'success_policy' => :'successPolicy',
    :'suspend' => :'suspend',
    :'template' => :'template',
    :'ttl_seconds_after_finished' => :'ttlSecondsAfterFinished'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



254
255
256
# File 'lib/kubernetes/models/v1_job_spec.rb', line 254

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



113
114
115
116
# File 'lib/kubernetes/models/v1_job_spec.rb', line 113

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/kubernetes/models/v1_job_spec.rb', line 91

def self.openapi_types
  {
    :'active_deadline_seconds' => :'Integer',
    :'backoff_limit' => :'Integer',
    :'backoff_limit_per_index' => :'Integer',
    :'completion_mode' => :'String',
    :'completions' => :'Integer',
    :'managed_by' => :'String',
    :'manual_selector' => :'Boolean',
    :'max_failed_indexes' => :'Integer',
    :'parallelism' => :'Integer',
    :'pod_failure_policy' => :'V1PodFailurePolicy',
    :'pod_replacement_policy' => :'String',
    :'selector' => :'V1LabelSelector',
    :'success_policy' => :'V1SuccessPolicy',
    :'suspend' => :'Boolean',
    :'template' => :'V1PodTemplateSpec',
    :'ttl_seconds_after_finished' => :'Integer'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/kubernetes/models/v1_job_spec.rb', line 218

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      active_deadline_seconds == o.active_deadline_seconds &&
      backoff_limit == o.backoff_limit &&
      backoff_limit_per_index == o.backoff_limit_per_index &&
      completion_mode == o.completion_mode &&
      completions == o.completions &&
      managed_by == o.managed_by &&
      manual_selector == o.manual_selector &&
      max_failed_indexes == o.max_failed_indexes &&
      parallelism == o.parallelism &&
      pod_failure_policy == o.pod_failure_policy &&
      pod_replacement_policy == o.pod_replacement_policy &&
      selector == o.selector &&
      success_policy == o.success_policy &&
      suspend == o.suspend &&
      template == o.template &&
      ttl_seconds_after_finished == o.ttl_seconds_after_finished
end

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/kubernetes/models/v1_job_spec.rb', line 284

def _deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Kubernetes.const_get(type)
    klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/kubernetes/models/v1_job_spec.rb', line 355

def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map { |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/kubernetes/models/v1_job_spec.rb', line 261

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end
  end

  self
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


241
242
243
# File 'lib/kubernetes/models/v1_job_spec.rb', line 241

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



247
248
249
# File 'lib/kubernetes/models/v1_job_spec.rb', line 247

def hash
  [active_deadline_seconds, backoff_limit, backoff_limit_per_index, completion_mode, completions, managed_by, manual_selector, max_failed_indexes, parallelism, pod_failure_policy, pod_replacement_policy, selector, success_policy, suspend, template, ttl_seconds_after_finished].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



200
201
202
203
204
205
206
207
# File 'lib/kubernetes/models/v1_job_spec.rb', line 200

def list_invalid_properties
  invalid_properties = Array.new
  if @template.nil?
    invalid_properties.push('invalid value for "template", template cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



331
332
333
# File 'lib/kubernetes/models/v1_job_spec.rb', line 331

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/kubernetes/models/v1_job_spec.rb', line 337

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



325
326
327
# File 'lib/kubernetes/models/v1_job_spec.rb', line 325

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



211
212
213
214
# File 'lib/kubernetes/models/v1_job_spec.rb', line 211

def valid?
  return false if @template.nil?
  true
end