Class: Cloud::Sh::Commands::K8sExec
- Inherits:
-
Base
- Object
- Base
- Cloud::Sh::Commands::K8sExec
show all
- Defined in:
- lib/cloud/sh/commands/k8s_exec.rb
Instance Attribute Summary
Attributes inherited from Base
#args, #options
Instance Method Summary
collapse
Methods inherited from Base
#config, execute, #initialize
#command_chain
Instance Method Details
#execute ⇒ Object
9
10
11
12
13
14
15
16
17
|
# File 'lib/cloud/sh/commands/k8s_exec.rb', line 9
def execute
pod = kubectl.context(options[:context]).namespace(options[:namespace]).get.pod.(true).map(:name).find do |pod|
pod.name.start_with?(options[:pod])
end
raise "Cannot find pod." unless pod
command = kubectl.context(options[:context]).namespace(options[:namespace]).exec.with(pod.name).stdin(true).tty(true).with(options[:cmd])
puts "Command: #{command}\n"
command.replace_current_process
end
|
#kubectl ⇒ Object
19
20
21
|
# File 'lib/cloud/sh/commands/k8s_exec.rb', line 19
def kubectl
command_chain("kubectl").kubeconfig(Cloud::Sh::Providers::DigitalOcean.kube_config)
end
|