Sha256: d2c7e68e5c97ddda7fa464ac3dfce5f8ca6e0f62b59017f7703e19ca6b5105e9
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require 'waitutil' module K8sKit class Job attr_reader :context, :name def initialize(context, name) @context = context @name = name end def attach(container:, delete_on_completion: true, exit_on_completion: true) pod.wait_until_ready pod.logs(container: container, stream: true) WaitUtil.wait_for_condition("pod has exit code", :timeout_sec => 30, :delay_sec => 0.5) do foo = pod.exit_code(container: container) puts "Checking exit code: #{foo}" Integer(pod.exit_code(container: container)) rescue false end exit_code = pod.exit_code(container: container) puts "Exit code: #{exit_code}" delete if delete_on_completion exit exit_code if exit_on_completion exit_code end def delete context.run("delete job #{name}") end def pod @pod ||= begin pod_name = context.run("get pod -l job-name=#{name} -o jsonpath='{.items[0].metadata.name}'") Pod.new(context, pod_name) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
k9s_kit-0.0.7.pre.pre5 | lib/k8s_kit/job.rb |
k9s_kit-0.0.7.pre.pre4 | lib/k8s_kit/job.rb |