sct 0.1.18 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/sct +3 -4
- data/{.DS_Store → cluster/lib/.DS_Store} +0 -0
- data/cluster/lib/cluster.rb +6 -0
- data/cluster/lib/cluster/commands_generator.rb +109 -0
- data/cluster/lib/cluster/module.rb +7 -0
- data/{lib/sct → cluster/lib/cluster/resources}/.DS_Store +0 -0
- data/{resources → cluster/lib/cluster/resources}/corefile.yml +0 -0
- data/{lib/sct/commands/cluster.rb → cluster/lib/cluster/runner.rb} +137 -132
- data/{lib → sct/lib}/.DS_Store +0 -0
- data/sct/lib/sct.rb +17 -0
- data/sct/lib/sct/.DS_Store +0 -0
- data/sct/lib/sct/cli_tools_distributor.rb +50 -0
- data/{lib → sct/lib}/sct/command.rb +0 -0
- data/{lib → sct/lib}/sct/commands/hostfile.rb +7 -23
- data/sct/lib/sct/commands/init.rb +37 -0
- data/sct/lib/sct/commands/mysqlproxy.rb +20 -0
- data/sct/lib/sct/commands_generator.rb +56 -0
- data/sct/lib/sct/tools.rb +12 -0
- data/sct/lib/sct/version.rb +3 -0
- data/sct_core/lib/.DS_Store +0 -0
- data/sct_core/lib/sct_core.rb +14 -0
- data/sct_core/lib/sct_core/.DS_Store +0 -0
- data/sct_core/lib/sct_core/command_executor.rb +104 -0
- data/{lib/sct → sct_core/lib/sct_core}/config.rb +3 -3
- data/sct_core/lib/sct_core/core_ext/string.rb +9 -0
- data/{lib/sct/setup/helpers.rb → sct_core/lib/sct_core/helper.rb} +10 -2
- data/sct_core/lib/sct_core/module.rb +0 -0
- data/sct_core/lib/sct_core/sct_pty.rb +53 -0
- data/sct_core/lib/sct_core/ui/implementations/shell.rb +129 -0
- data/sct_core/lib/sct_core/ui/interface.rb +120 -0
- data/sct_core/lib/sct_core/ui/ui.rb +26 -0
- data/sct_core/lib/sct_core/update_checker/update_checker.rb +76 -0
- data/shell/README.md +0 -0
- data/shell/lib/shell.rb +3 -0
- data/{lib/sct → shell/lib/shell}/ClassLevelInheritableAttributes.rb +0 -0
- data/shell/lib/shell/commands_generator.rb +14 -0
- data/shell/lib/shell/docker/composer.rb +16 -0
- data/{lib/sct → shell/lib/shell}/docker/docker.rb +54 -38
- data/shell/lib/shell/docker/php.rb +52 -0
- data/shell/lib/shell/docker/yarn.rb +17 -0
- data/shell/lib/shell/module.rb +9 -0
- data/shell/lib/shell/runner.rb +34 -0
- data/shell/lib/shell/tools.rb +7 -0
- metadata +126 -53
- data/.gitignore +0 -12
- data/.gitlab/merge_request_templates/DefinitionOfDone.md +0 -14
- data/.rspec +0 -3
- data/.travis.yml +0 -7
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -48
- data/LICENSE.txt +0 -21
- data/README.md +0 -134
- data/Rakefile +0 -6
- data/lib/sct.rb +0 -61
- data/lib/sct/command_interface.rb +0 -18
- data/lib/sct/command_option.rb +0 -14
- data/lib/sct/commands/composer.rb +0 -29
- data/lib/sct/commands/init.rb +0 -51
- data/lib/sct/commands/mysqlproxy.rb +0 -38
- data/lib/sct/commands/php.rb +0 -37
- data/lib/sct/commands/yarn.rb +0 -26
- data/lib/sct/docker/composer.rb +0 -15
- data/lib/sct/docker/php.rb +0 -14
- data/lib/sct/docker/yarn.rb +0 -16
- data/lib/sct/version.rb +0 -3
- data/sct.gemspec +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 795f84864a77f3e67efdbba2318ba62ca9958f665512f8d0b0f52eaffef5d191
|
4
|
+
data.tar.gz: 91ca3561de5f9418aaad5d99faf4f2d38cedf5e0063723ddad774345c96bff1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feffcc74dba1ebdcce727e9718f70d88d22bacc6643d17a69f2dc05716bd7c440e95988a2387421185f6e0d0ea0294ad83cad166759a570fa70cd649120943fc
|
7
|
+
data.tar.gz: e40cbed1e28216b1e68190eef67e383966015bae5c6ad24ddcac745826279a01175ce42021aa175fe93e755aa154f2e6f51effc0c5a2e3a2c88f7623de2aa118
|
data/bin/sct
CHANGED
@@ -1,8 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'commander/import'
|
4
|
-
require 'sct'
|
5
|
-
|
6
3
|
if RUBY_VERSION < '2.0.0'
|
7
4
|
abort("sct requires Ruby 2.0.0 or higher")
|
8
5
|
end
|
@@ -11,6 +8,8 @@ def self.windows?
|
|
11
8
|
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
12
9
|
end
|
13
10
|
|
11
|
+
require 'sct/cli_tools_distributor'
|
12
|
+
|
14
13
|
if ARGV.include?('-v') || ARGV.include?('--version')
|
15
14
|
# This will print out the sct binary path right above the
|
16
15
|
# version number. Very often, users are not aware they have
|
@@ -20,4 +19,4 @@ if ARGV.include?('-v') || ARGV.include?('--version')
|
|
20
19
|
puts("-----------------------------")
|
21
20
|
end
|
22
21
|
|
23
|
-
Sct::
|
22
|
+
Sct::CLIToolsDistributor.take_off
|
Binary file
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'commander'
|
2
|
+
require_relative 'runner'
|
3
|
+
|
4
|
+
module Cluster
|
5
|
+
class CommandsGenerator
|
6
|
+
include Commander::Methods
|
7
|
+
|
8
|
+
def self.start
|
9
|
+
self.new.run
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
program :name, 'cluster'
|
14
|
+
program :version, Sct::VERSION
|
15
|
+
program :description, 'CLI for \'cluster\' - Manage your local kubernetes cluster'
|
16
|
+
|
17
|
+
global_option('--verbose') { $verbose = true }
|
18
|
+
|
19
|
+
command :up do |c|
|
20
|
+
|
21
|
+
c.syntax = "sct cluster up"
|
22
|
+
c.description = "Start the cluster"
|
23
|
+
c.option '--clean', 'start a clean cluster. Old cluster will be purged if available.'
|
24
|
+
|
25
|
+
c.action do |args, options|
|
26
|
+
if options.clean
|
27
|
+
Cluster::Runner.new.reset
|
28
|
+
else
|
29
|
+
Cluster::Runner.new.launch
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
command :down do |c|
|
36
|
+
|
37
|
+
c.syntax = 'sct cluster down'
|
38
|
+
c.description = 'stop the cluster'
|
39
|
+
|
40
|
+
c.action do |args, options|
|
41
|
+
Cluster::Runner.new.down
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
command :reset do |c|
|
46
|
+
|
47
|
+
c.syntax = 'sct cluster reset'
|
48
|
+
c.description = 'reset your cluster and start with a clean cluster'
|
49
|
+
|
50
|
+
c.action do |args, options|
|
51
|
+
Cluster::Runner.new.reset
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
alias_command :'setup', :'reset'
|
56
|
+
|
57
|
+
command :status do |c|
|
58
|
+
|
59
|
+
c.syntax = 'sct cluster status'
|
60
|
+
c.description = 'see the status of your cluster'
|
61
|
+
|
62
|
+
c.action do |args, options|
|
63
|
+
Cluster::Runner.new.status
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
command :'update config' do |c|
|
68
|
+
|
69
|
+
c.syntax = 'sct cluster update config'
|
70
|
+
c.description = 'update the cluster configuration'
|
71
|
+
|
72
|
+
c.action do |args, options|
|
73
|
+
Cluster::Runner.new.update_config
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
command :'delete pods' do |c|
|
78
|
+
c.syntax = 'sct cluster delete stalled pods'
|
79
|
+
c.description = 'delete stalled pods from the cluster'
|
80
|
+
c.option '--stalled', 'delete stalled pods'
|
81
|
+
c.option '--all', 'delete all pods'
|
82
|
+
|
83
|
+
c.action do |args, options|
|
84
|
+
|
85
|
+
Cluster::Runner.new.delete_stalled_pods if options.stalled
|
86
|
+
Cluster::Runner.new.delete_all_pods if options.all
|
87
|
+
|
88
|
+
Cluster::Runner.new.delete_pods(args) if !args.empty?
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
command :'apply pods' do |c|
|
94
|
+
c.syntax = 'sct cluster apply pods'
|
95
|
+
c.description = 'apply pods from the k8s folder'
|
96
|
+
|
97
|
+
c.action do |args, options|
|
98
|
+
|
99
|
+
Cluster::Runner.new.apply_pods
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
default_command :status
|
105
|
+
|
106
|
+
run!
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
Binary file
|
File without changes
|
@@ -1,59 +1,39 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
module Sct
|
5
|
-
|
6
|
-
class ClusterCommand
|
7
|
-
|
8
|
-
IS_PUBLIC_COMMAND = true
|
9
|
-
SYNTAX = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods | sct cluster status'
|
10
|
-
SUMMARY = 'Perform actions on the minikube cluster.'
|
11
|
-
EXAMPLE = 'sct cluster up | sct cluster down | sct cluster setup | sct cluster reset | sct cluster update-config | sct cluster delete-stalled-pods | sct cluster status'
|
12
|
-
EXAMPLE_DESCRIPTION = 'Perform actions on the minikube cluster.'
|
13
|
-
DESCRIPTION = "sct cluster allows you to start, stop, setup/reset, update the config, delete the stalled pods, or status of the Spend Cloud minikube cluster."
|
14
|
-
|
15
|
-
OPTIONS = []
|
16
|
-
|
17
|
-
def execute(args, options)
|
18
|
-
return puts "SCT has not been initialized. Run 'sct init' first.".red unless Sct::Config.exists
|
19
|
-
|
20
|
-
case args[0]
|
21
|
-
when "up"
|
22
|
-
up
|
23
|
-
when "down"
|
24
|
-
down
|
25
|
-
when "update-config"
|
26
|
-
update_config
|
27
|
-
when "setup", "reset"
|
28
|
-
reset
|
29
|
-
when "delete-stalled-pods"
|
30
|
-
delete_stalled_pods(feedback: true)
|
31
|
-
when "status"
|
32
|
-
status
|
33
|
-
else
|
34
|
-
puts "Unknown or missing argument. Please run 'sct cluster --help'.".red
|
35
|
-
end
|
36
|
-
end
|
1
|
+
module Cluster
|
2
|
+
class Runner
|
37
3
|
|
38
|
-
def
|
39
|
-
|
4
|
+
def launch
|
5
|
+
return UI.error("SCT has not been initialized. Run 'sct init' first.") unless SctCore::Config.exists
|
6
|
+
start_cluster
|
40
7
|
run_command "kubectl delete pod -n kube-system #{pods("kube-system").map { |pod| pod[:name] if pod[:name].start_with? "registry-creds" } .compact.join(" ")}"
|
41
8
|
run_command "kubectl rollout status -n kube-system deployment/registry-creds"
|
42
9
|
post_start
|
43
10
|
end
|
44
11
|
|
12
|
+
def start_cluster
|
13
|
+
if SctCore::Helper.operatingSystem == SctCore::Helper::MAC_OS
|
14
|
+
run_command "#{SctCore::Helper.minikube} start --cpus=$(sysctl -n hw.ncpu) --memory=8G"
|
15
|
+
else
|
16
|
+
run_command "#{SctCore::Helper.minikube} start --cpus=$(cat /proc/cpuinfo | grep processor | wc -l) --memory=10G"
|
17
|
+
end
|
18
|
+
run_command "#{SctCore::Helper.minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'"
|
19
|
+
update_config
|
20
|
+
end
|
21
|
+
|
22
|
+
def post_start
|
23
|
+
wait_for_pods
|
24
|
+
run_command "sudo sct hostfile"
|
25
|
+
UI.success("\n✔️ You can visit your environment at 👉 https://spend-cloud.spend.cloud.local 👌")
|
26
|
+
end
|
27
|
+
|
45
28
|
def down
|
46
|
-
run_command "#{minikube} stop"
|
29
|
+
run_command "#{SctCore::Helper.minikube} stop"
|
47
30
|
end
|
48
31
|
|
49
32
|
def reset
|
50
|
-
run_command "#{minikube} delete"
|
51
|
-
|
33
|
+
run_command "#{SctCore::Helper.minikube} delete"
|
34
|
+
start_cluster
|
52
35
|
create_secrets
|
53
|
-
|
54
|
-
run_command "#{minikube} addons enable ingress"
|
55
|
-
run_command "kubectl rollout status -n kube-system deployment/registry-creds"
|
56
|
-
run_command "kubectl rollout status -n kube-system deployment/nginx-ingress-controller"
|
36
|
+
enable_addons
|
57
37
|
wait_for_gcr_secret
|
58
38
|
run_command "kubectl apply -f ~/development/spend-cloud/k8s/ingress.yml"
|
59
39
|
wait_for_ingress_ip
|
@@ -63,51 +43,122 @@ module Sct
|
|
63
43
|
post_start
|
64
44
|
end
|
65
45
|
|
46
|
+
def enable_addons
|
47
|
+
enable_addon "registry-creds"
|
48
|
+
enable_addon "ingress"
|
49
|
+
end
|
50
|
+
|
51
|
+
def enable_addon(addon)
|
52
|
+
run_command "#{SctCore::Helper.minikube} addons enable #{addon}"
|
53
|
+
|
54
|
+
deployment = deployments("kube-system").find { |deployment| deployment[:name].include? addon }
|
55
|
+
|
56
|
+
run_command "kubectl rollout status -n kube-system deployment/#{deployment[:name]}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def wait_for_pods
|
60
|
+
UI.important("Waiting for pods to become ready...")
|
61
|
+
|
62
|
+
while ! pods.all? { |pod| pod[:status] == "Running" }
|
63
|
+
delete_stalled_pods
|
64
|
+
|
65
|
+
sleep 5
|
66
|
+
end
|
67
|
+
|
68
|
+
UI.success("Pods are now ready.")
|
69
|
+
end
|
70
|
+
|
71
|
+
def delete_stalled_pods(feedback: false)
|
72
|
+
|
73
|
+
return UI.success("No stalled pods found") unless !pods.to_a.empty?
|
74
|
+
|
75
|
+
stalled_pods = pods.select { |pod| pod[:stalled] }
|
76
|
+
|
77
|
+
if stalled_pods.empty?
|
78
|
+
UI.success("There are no stalled pods.") if feedback
|
79
|
+
else
|
80
|
+
run_command "kubectl delete pods #{stalled_pods.map { |pod| pod[:name] } .join(" ")}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def delete_all_pods
|
85
|
+
run_command "kubectl delete pods --all"
|
86
|
+
end
|
87
|
+
|
88
|
+
def delete_pods(args)
|
89
|
+
run_command "kubectl delete pods #{args.join(" ")}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def apply_pods
|
93
|
+
run_command "kubectl apply -f ~/development/spend-cloud/k8s/"
|
94
|
+
end
|
95
|
+
|
66
96
|
def update_config
|
67
|
-
if
|
68
|
-
windows_home_path =
|
97
|
+
if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
|
98
|
+
windows_home_path = SctCore::Helper.windowsHomePath
|
69
99
|
kube_file_path = windows_home_path+"/.kube/config"
|
70
100
|
|
71
101
|
if !File.exists?(kube_file_path)
|
72
|
-
return
|
102
|
+
return UI.error("#{kube_file_path} doesn't exist")
|
73
103
|
end
|
74
104
|
|
75
105
|
run_command "sed -e 's~\\\\~/~g' -e 's~C:~/mnt/c~g' < #{kube_file_path} > ~/.kube/minikube-config"
|
76
106
|
|
77
|
-
|
107
|
+
UI.success("#{kube_file_path} copied to ~/.kube/minikube-config")
|
78
108
|
end
|
79
109
|
|
80
110
|
run_command "kubectl config use-context minikube"
|
81
111
|
|
82
|
-
run_command "kubectl replace -n kube-system -f #{File.expand_path('
|
83
|
-
|
112
|
+
run_command "kubectl replace -n kube-system -f #{File.expand_path('resources/corefile.yml', __dir__)}"
|
113
|
+
old_list = pods("kube-system").map { |pod| pod[:name] if pod[:name].start_with? "coredns" }.compact
|
114
|
+
run_command "kubectl delete pod -n kube-system #{old_list.join(" ")}" unless old_list.to_a.empty?
|
84
115
|
run_command "kubectl rollout status -n kube-system deployment/coredns"
|
85
116
|
end
|
86
117
|
|
87
|
-
def
|
88
|
-
|
118
|
+
def deployments(namespace = "default")
|
119
|
+
output = `kubectl get deployments -n #{namespace}`
|
89
120
|
|
90
|
-
|
91
|
-
|
92
|
-
else
|
93
|
-
run_command "kubectl delete pods #{stalled_pods.map { |pod| pod[:name] } .join(" ")}"
|
94
|
-
end
|
95
|
-
end
|
121
|
+
# split output lines
|
122
|
+
lines = output.split "\n"
|
96
123
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
124
|
+
# exclude first line (table header)
|
125
|
+
lines = lines[1..-1]
|
126
|
+
|
127
|
+
# get name and status of each pod
|
128
|
+
lines.map do |line|
|
129
|
+
columns = line.split(" ")
|
130
|
+
|
131
|
+
name = columns[0]
|
132
|
+
|
133
|
+
{
|
134
|
+
name: name
|
135
|
+
}
|
102
136
|
end
|
103
|
-
run_command "#{minikube} ssh -- 'sudo su -c \"echo 10048576 > /proc/sys/fs/inotify/max_user_watches\"'"
|
104
|
-
update_config
|
105
137
|
end
|
106
138
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
139
|
+
def pods(namespace = "default")
|
140
|
+
output = `kubectl get pods -n #{namespace}`
|
141
|
+
|
142
|
+
# split output lines
|
143
|
+
lines = output.split "\n"
|
144
|
+
|
145
|
+
# exclude first line (table header)
|
146
|
+
lines = lines[1..-1]
|
147
|
+
|
148
|
+
# get name and status of each pod
|
149
|
+
lines.map do |line|
|
150
|
+
columns = line.split(" ")
|
151
|
+
|
152
|
+
name = columns[0]
|
153
|
+
status = columns[2]
|
154
|
+
stalled = status == "ErrImagePull" || status == "ImagePullBackOff"
|
155
|
+
|
156
|
+
{
|
157
|
+
name: name,
|
158
|
+
status: status,
|
159
|
+
stalled: stalled
|
160
|
+
}
|
161
|
+
end
|
111
162
|
end
|
112
163
|
|
113
164
|
def create_secrets
|
@@ -123,35 +174,23 @@ module Sct
|
|
123
174
|
end
|
124
175
|
|
125
176
|
def wait_for_gcr_secret
|
126
|
-
|
177
|
+
UI.important("Waiting for Google Cloud Registry secret to become available...")
|
127
178
|
|
128
179
|
while ! `kubectl get secrets`.include? "gcr-secret"
|
129
180
|
sleep 5
|
130
181
|
end
|
131
182
|
|
132
|
-
|
183
|
+
UI.success("Google Cloud Registry secret is now available.")
|
133
184
|
end
|
134
185
|
|
135
186
|
def wait_for_ingress_ip
|
136
|
-
|
187
|
+
UI.important("Waiting for ingress IP to become available...")
|
137
188
|
|
138
189
|
while `kubectl describe ingress | grep "Address" | awk '{print $2}'`.empty?
|
139
190
|
sleep 5
|
140
191
|
end
|
141
192
|
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
def wait_for_pods
|
146
|
-
puts "Waiting for pods to become ready...".yellow
|
147
|
-
|
148
|
-
while ! pods.all? { |pod| pod[:status] == "Running" }
|
149
|
-
delete_stalled_pods
|
150
|
-
|
151
|
-
sleep 5
|
152
|
-
end
|
153
|
-
|
154
|
-
puts "Pods are now ready.".green
|
193
|
+
UI.success("Ingress IP is now available.")
|
155
194
|
end
|
156
195
|
|
157
196
|
def status
|
@@ -162,7 +201,7 @@ module Sct
|
|
162
201
|
print_pods_status("kube-system")
|
163
202
|
print_pods_status
|
164
203
|
else
|
165
|
-
|
204
|
+
UI.important("Please check your minikube status. If all services are stopped you should start the minikube first.")
|
166
205
|
end
|
167
206
|
end
|
168
207
|
|
@@ -189,7 +228,7 @@ module Sct
|
|
189
228
|
end
|
190
229
|
|
191
230
|
def get_minikube_status
|
192
|
-
output = `#{minikube} status`
|
231
|
+
output = `#{SctCore::Helper.minikube} status`
|
193
232
|
|
194
233
|
lines = output.split "\n"
|
195
234
|
|
@@ -200,44 +239,22 @@ module Sct
|
|
200
239
|
end
|
201
240
|
end
|
202
241
|
|
203
|
-
def print_pods_status(namespace =
|
204
|
-
|
242
|
+
def print_pods_status(namespace = "default")
|
243
|
+
|
244
|
+
pods_list = pods(namespace)
|
245
|
+
|
246
|
+
if pods_list.to_a.empty?
|
247
|
+
return
|
248
|
+
end
|
249
|
+
|
250
|
+
rows = pods_list.map do |pod|
|
205
251
|
[
|
206
252
|
pod[:name],
|
207
253
|
pod[:status] == "Running" ? pod[:status].green : pod[:status].red
|
208
254
|
]
|
209
255
|
end
|
210
256
|
|
211
|
-
puts Terminal::Table.new title: "Pods (namespace: #{namespace
|
212
|
-
end
|
213
|
-
|
214
|
-
def pods(namespace = nil)
|
215
|
-
if namespace
|
216
|
-
output = `kubectl get pods -n #{namespace}`
|
217
|
-
else
|
218
|
-
output = `kubectl get pods`
|
219
|
-
end
|
220
|
-
|
221
|
-
# split output lines
|
222
|
-
lines = output.split "\n"
|
223
|
-
|
224
|
-
# exclude first line (table header)
|
225
|
-
lines = lines[1..-1]
|
226
|
-
|
227
|
-
# get name and status of each pod
|
228
|
-
lines.map do |line|
|
229
|
-
columns = line.split(" ")
|
230
|
-
|
231
|
-
name = columns[0]
|
232
|
-
status = columns[2]
|
233
|
-
stalled = status == "ErrImagePull" || status == "ImagePullBackOff"
|
234
|
-
|
235
|
-
{
|
236
|
-
name: name,
|
237
|
-
status: status,
|
238
|
-
stalled: stalled
|
239
|
-
}
|
240
|
-
end
|
257
|
+
puts Terminal::Table.new title: "Pods (namespace: #{namespace})".green, headings: ['Name', 'Status'], rows: rows
|
241
258
|
end
|
242
259
|
|
243
260
|
def run_command command
|
@@ -245,17 +262,5 @@ module Sct
|
|
245
262
|
raise command.red
|
246
263
|
end
|
247
264
|
end
|
248
|
-
|
249
|
-
def minikube
|
250
|
-
if Sct::Helpers.operatingSystem == Sct::Helpers::WINDOWS
|
251
|
-
return "minikube.exe"
|
252
|
-
else
|
253
|
-
return "minikube"
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
implements CommandInterface
|
258
|
-
|
259
265
|
end
|
260
|
-
|
261
266
|
end
|