Class: Metatron::Templates::Job

Inherits:
Metatron::Template show all
Includes:
Concerns::Annotated, Concerns::Namespaced, Concerns::PodProducer
Defined in:
lib/metatron/templates/job.rb

Overview

Template for basic Job k8s resource

Instance Attribute Summary collapse

Attributes inherited from Metatron::Template

#additional_labels, #api_version, #kind, #label_namespace, #name

Instance Method Summary collapse

Methods included from Concerns::Namespaced

#formatted_namespace, included, #namespaced_initialize

Methods included from Concerns::PodProducer

#formatted_affinity, #formatted_containers, #formatted_image_pull_secrets, #formatted_init_containers, #formatted_node_selector, #formatted_pod_annotations, #formatted_security_context, #formatted_tolerations, #formatted_volumes, included, #pod_metadata, #pod_producer_initialize, #pod_spec, #pod_template, #volume_claim_templates

Methods included from Concerns::Annotated

#annotated_initialize, #formatted_annotations, included

Methods inherited from Metatron::Template

initializer, initializers, metatron_template_class?, nearest_metatron_ancestor

Constructor Details

#initialize(name) ⇒ Job

Returns a new instance of Job.



21
22
23
24
# File 'lib/metatron/templates/job.rb', line 21

def initialize(name)
  super(name)
  @api_version = "batch/v1"
end

Instance Attribute Details

#active_deadline_secondsObject Also known as: activeDeadlineSeconds

Returns the value of attribute active_deadline_seconds.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def active_deadline_seconds
  @active_deadline_seconds
end

#backoff_limitObject Also known as: backoffLimit

Returns the value of attribute backoff_limit.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def backoff_limit
  @backoff_limit
end

#completionsObject

Returns the value of attribute completions.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def completions
  @completions
end

#parallelismObject

Returns the value of attribute parallelism.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def parallelism
  @parallelism
end

#pod_failure_policyObject Also known as: podFailurePolicy

Returns the value of attribute pod_failure_policy.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def pod_failure_policy
  @pod_failure_policy
end

#restart_policyObject Also known as: restartPolicy

Returns the value of attribute restart_policy.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def restart_policy
  @restart_policy
end

#suspendObject

Returns the value of attribute suspend.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def suspend
  @suspend
end

#ttl_seconds_after_finishedObject Also known as: ttlSecondsAfterFinished

Returns the value of attribute ttl_seconds_after_finished.



11
12
13
# File 'lib/metatron/templates/job.rb', line 11

def ttl_seconds_after_finished
  @ttl_seconds_after_finished
end

Instance Method Details

#renderObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/metatron/templates/job.rb', line 26

def render
  {
    apiVersion:,
    kind:,
    metadata: {
      labels: { "#{label_namespace}/name": name }.merge(additional_labels),
      name:
    }.merge(formatted_annotations).merge(formatted_namespace),
    spec: {
      suspend:,
      backoffLimit:,
      activeDeadlineSeconds:,
      completions:,
      parallelism:,
      podFailurePolicy:,
      ttlSecondsAfterFinished:
    }.merge(pod_template).compact
  }
end