Method: Job#initialize

Defined in:
lib/job.rb

#initialize(spec:, namespace:, client:, client_stateful_set:, self_name: ENV['HOSTNAME']) ⇒ Job

Returns a new instance of Job.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/job.rb', line 7

def initialize(spec:, namespace:, client:, client_stateful_set:, self_name: ENV['HOSTNAME'])
  @spec = spec
  @namespace = namespace
  @client = client
  @self_name = self_name
  links = @spec['links'] = KubeLinkSpecs.new(@spec, @namespace, @client, client_stateful_set)

  # Figure out whether _this_ should bootstrap
  pods = @client.get_pods(namespace: @namespace, label_selector: "app.kubernetes.io/component=#{self_role}")
  pods_per_image = links.get_pods_per_image(pods)
  @spec['bootstrap'] = pods_per_image[self_pod..uid] < 2
end