Class: Kube::Cluster::Standard::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/kube/cluster/standard/job.rb

Instance Method Summary collapse

Constructor Details

#initialize(name:, image:, env: {}, command: nil, backoff_limit: 3, ttl: 300, &block) ⇒ Job

Returns a new instance of Job.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kube/cluster/standard/job.rb', line 10

def initialize(name:, image:, env: {}, command: nil, backoff_limit: 3, ttl: 300, &block)
  processed_env = EnvProcessing.process(env)

  super() do
    .name = name

    spec.backoffLimit = backoff_limit
    spec.ttlSecondsAfterFinished = ttl
    spec.template.spec.restartPolicy = 'OnFailure'

    container = {
      name: name,
      image: image,
      env: processed_env
    }
    container[:command] = command if command

    spec.template.spec.containers = [container]

    instance_exec(&block) if block
  end
end