Class: JamesBond::MissionKubernetes::ServerHandler
- Inherits:
-
Object
- Object
- JamesBond::MissionKubernetes::ServerHandler
- Defined in:
- lib/james_bond/mission_kubernetes/server_handler.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(command, config) ⇒ ServerHandler
constructor
A new instance of ServerHandler.
- #run ⇒ Object
Constructor Details
#initialize(command, config) ⇒ ServerHandler
Returns a new instance of ServerHandler.
9 10 11 12 |
# File 'lib/james_bond/mission_kubernetes/server_handler.rb', line 9 def initialize(command, config) @command = command @config = config.for(env: command.env, command: command.main_command) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/james_bond/mission_kubernetes/server_handler.rb', line 7 def config @config end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/james_bond/mission_kubernetes/server_handler.rb', line 14 def run tag = @command.["tag"] app_name = @config["app_name"] image = @config["image_name"] deploy = "#{app_name}-#{Time.now.to_i}" command = [ "kubectl run #{deploy}", "--image=#{image}:#{tag}", "--restart=Never", "--attach --rm" ].join(" ") Open3.popen3(command) do |stdin, stdout, stderr, thread| Thread.new do until (line = stdout.gets).nil? do puts line end end thread.join end end |