Class: Pfab::Templates::Daemon

Inherits:
Base
  • Object
show all
Defined in:
lib/pfab/templates/daemon.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

#deploymentObject



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
49
50
51
52
53
54
# File 'lib/pfab/templates/daemon.rb', line 8

def deployment
  {
    kind: "Deployment",
    apiVersion: "extensions/v1beta1",
    metadata: {
      name: @data['deployed_name'],
      namespace: @data['env'],
      labels: {
        application: @data['application'],
        "deployed-name" => @data['deployed_name'],
        "application-type" => "daemon",
      }
    },
    spec: {
      replicas: get("replicas") || 1,
      selector: {
        matchLabels: {
          "deployed-name" => @data['deployed_name'],
        },
      },
      strategy: {
        type: "Recreate"
      },
      revisionHistoryLimit: 5,
      template: {
        metadata: {
          labels: {
            application: @data['application'],
            "deployed-name" => @data['deployed_name'],
            "application-type" => "daemon",
          },
        },
        spec: {
          containers: [
            {
              image: image_name,
              name: @data['deployed_name'],
              command: get("command").split(" "),
              env: env_vars,
              resources: resources,
            }
          ]
        },
      },
    },
  }
end

#write_to(f) ⇒ Object



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

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