Module: KBE
- Defined in:
- lib/kbe.rb,
lib/kbe/cli.rb,
lib/kbe/version.rb,
lib/kbe/cli/help_command.rb,
lib/kbe/cli/list_command.rb,
lib/kbe/cli/root_command.rb,
lib/kbe/cli/enter_command.rb,
lib/kbe/cli/version_command.rb
Defined Under Namespace
Modules: CLI
Classes: Error
Constant Summary
collapse
- VERSION =
"0.1.4"
Class Method Summary
collapse
Class Method Details
.kubectl(*args) ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'lib/kbe.rb', line 5
def self.kubectl(*args)
cmd = []
cmd << "kubectl"
cmd << args
cmd_string = cmd.join " "
STDERR.puts cmd_string.colorize(:light_black)
exec cmd_string
end
|
.pod_by(selector) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/kbe.rb', line 15
def self.pod_by(selector)
["app", "job-name"].each do |selector_prefix|
magic_selector = if selector.match? "="
selector
else
"#{selector_prefix}=#{selector}"
end
pods = `kubectl get pods --no-headers -o custom-columns=":metadata.name" --field-selector=status.phase=Running --selector=#{magic_selector}`.split("\n")
return pods.first if pods.size == 1
break if magic_selector == selector
next if pods.empty?
STDERR.puts "too many pods"
exit 1
end
STDERR.puts "no pod found"
exit 1
end
|