Class: K8sKit::Job
- Inherits:
-
Object
- Object
- K8sKit::Job
- Defined in:
- lib/k8s_kit/job.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #attach(container:, delete_on_completion: true, exit_on_completion: true) ⇒ Object
- #delete ⇒ Object
-
#initialize(context, name) ⇒ Job
constructor
A new instance of Job.
- #pod ⇒ Object
Constructor Details
#initialize(context, name) ⇒ Job
Returns a new instance of Job.
7 8 9 10 |
# File 'lib/k8s_kit/job.rb', line 7 def initialize(context, name) @context = context @name = name end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
5 6 7 |
# File 'lib/k8s_kit/job.rb', line 5 def context @context end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/k8s_kit/job.rb', line 5 def name @name end |
Instance Method Details
#attach(container:, delete_on_completion: true, exit_on_completion: true) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/k8s_kit/job.rb', line 12 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 pod.exit_code(container: container) != nil end exit_code = pod.exit_code(container: container) delete if delete_on_completion exit exit_code if exit_on_completion exit_code end |
#delete ⇒ Object
30 31 32 |
# File 'lib/k8s_kit/job.rb', line 30 def delete context.run("delete job #{name}") end |