Class: Eien::Apps::StatusTask

Inherits:
Task
  • Object
show all
Defined in:
lib/eien/apps/status_task.rb

Instance Attribute Summary collapse

Attributes inherited from Task

#context, #namespace, #task_config

Instance Method Summary collapse

Methods included from Helpers::TimeHelpers

#summarize_age

Constructor Details

#initialize(context, name) ⇒ StatusTask

Returns a new instance of StatusTask.



8
9
10
11
# File 'lib/eien/apps/status_task.rb', line 8

def initialize(context, name)
  @name = name
  super(context, nil)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/eien/apps/status_task.rb', line 6

def name
  @name
end

Instance Method Details

#run!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/eien/apps/status_task.rb', line 13

def run!
  v1_client = kubeclient_builder.build_v1_kubeclient(context)
  apps_client = kubeclient_builder.build_apps_v1_kubeclient(context)
  eien_client = kubeclient_builder.build_eien_kubeclient(context)

  app = eien_client.get_app(name)
  target_namespace = app.spec.namespace
  processes = eien_client.get_processes(namespace: target_namespace)

  all_deployments = apps_client.get_deployments(namespace: target_namespace)
  all_services = v1_client.get_services(namespace: target_namespace)

  deployments = all_deployments.each_with_object({}) do |deployment, deployments|
    deployments[deployment..labels["#{::Eien::LABEL_PREFIX}/process"]] = deployment
  end

  services = all_services.each_with_object({}) do |service, services|
    services[service..labels["#{::Eien::LABEL_PREFIX}/process"]] = service
  end

  render_status(app, deployments, processes, services)
end