Sha256: 96dd2d904f2039302fb97dde7fd5af08510b07f97308a1a9f9fbd9218c6fd0e0
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
module Rhea module Kubernetes module Nodes class All def perform api = Rhea::Kubernetes::Api.new pods = api.get_pods hostnames_nodes = {} pods.each do |pod| command_expression = pod.metadata.annotations.rhea_command next if command_expression.nil? hostname = pod.spec.nodeName hostnames_nodes[hostname] ||= {} hostnames_nodes[hostname][:image] = pod[:table][:spec][:containers][0]['image'] started_at = pod.status.startTime if started_at started_at = Time.parse(started_at) last_started_at = hostnames_nodes[hostname][:last_started_at] if last_started_at.nil? || started_at > last_started_at hostnames_nodes[hostname][:last_started_at] = started_at end end phase = pod.status.phase containers = pod.spec.containers containers.each do |container| image = container.image command = Command.new( expression: command_expression, image: image ) hostnames_nodes[hostname][:commands_phases] ||= {} hostnames_nodes[hostname][:commands_phases][command] ||= [] hostnames_nodes[hostname][:commands_phases][command] << phase end end hostnames_nodes.map do |hostname, node| OpenStruct.new(node.merge(hostname: hostname)) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rhea-0.2.0 | lib/rhea/kubernetes/nodes/all.rb |
rhea-0.1.0 | lib/rhea/kubernetes/nodes/all.rb |