Class: Pfab::Templates::Job

Inherits:
Base
  • Object
show all
Defined in:
lib/pfab/templates/job.rb

Instance Method Summary collapse

Methods inherited from Base

#app_vars, #cpu, #env_vars, #get, #image_name, #initialize, #load_env_vars, #load_secrets, #memory, #resources

Constructor Details

This class inherits a constructor from Pfab::Templates::Base

Instance Method Details

#jobObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pfab/templates/job.rb', line 8

def job
  {
    apiVersion: "batch/v1",
    kind: "Job",
    metadata: {
      name: "job-#{@data['deployed_name']}-#{@data['sha']}",
      namespace: @data['env'],
      labels: {
        application: @data['application'],
        "deployed-name" => @data['deployed_name'],
        "application-type" => "job",
      }
    },
    spec: {
      template: {
        metadata: {
          name: "#{@data['deployed_name']}-#{@data['sha']}",
          namespace: @data['env'],
          labels: {
            application: @data['application'],
            "deployed-name" => @data['deployed_name'],
            "application-type" => "job",
          },
        },
        spec: {
          containers: [
            {
              image: image_name,
              name: @data['deployed_name'],
              command: app_vars["command"].split(" "),
              env: env_vars,
              resources: resources,
            },
          ],
          restartPolicy: "Never",
        },
      },
      backoffLimit: 0,
    },
  }
end

#write_to(f) ⇒ Object



4
5
6
# File 'lib/pfab/templates/job.rb', line 4

def write_to(f)
  f << YAML.dump(job.deep_stringify_keys)
end