sct 0.1.17 → 0.1.22
Sign up to get free protection for your applications and to get access to all the features.
- 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} +160 -145
- 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} +2 -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/{lib/sct → shell/lib/shell}/docker/composer.rb +4 -3
- data/{lib/sct → shell/lib/shell}/docker/docker.rb +7 -10
- data/{lib/sct → shell/lib/shell}/docker/php.rb +3 -2
- data/{lib/sct → shell/lib/shell}/docker/yarn.rb +4 -3
- 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 -44
- 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/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: 61cca19491733244389c6a46e8c8fd8fd226b3cdab4fb8537b17a4e6d51d196e
|
4
|
+
data.tar.gz: 3057200714457d8b312f34f542454019155e634137d8a0de5ffe4fee93538d90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 721bcf403b7292dad0bec08f9d0198ad64acc9ab5ffa0200299499d51b7fb3b15fb859f5812c03347484fe5175263d73af86072f65138bb3cdda39e3ba532621
|
7
|
+
data.tar.gz: 19386f51a743615e480a579ce3fbb7eb17859a0f8bd2e57c21b9ce57562ac6c6436bcee1d6b845004317d160e2b2d288703a07c5829dfd02374b286cbe8a9a4c
|
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'
|
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'
|
12
|
-
EXAMPLE_DESCRIPTION = 'Perform actions on the minikube cluster.'
|
13
|
-
DESCRIPTION = "sct cluster allows you to start, stop, setup/reset, update the config, or delete the stalled pods 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 up', 'sct cluster down', 'sct cluster setup', 'sct cluster reset', 'sct cluster update-config', or 'sct cluster delete-stalled-pods'.".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 "#{minikube} start --cpus=$(sysctl -n hw.ncpu) --memory=8G"
|
15
|
+
else
|
16
|
+
run_command "#{minikube} start --cpus=$(cat /proc/cpuinfo | grep processor | wc -l) --memory=10G"
|
17
|
+
end
|
18
|
+
run_command "#{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
29
|
run_command "#{minikube} stop"
|
47
30
|
end
|
48
31
|
|
49
32
|
def reset
|
50
33
|
run_command "#{minikube} delete"
|
51
|
-
|
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 "#{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,119 +174,87 @@ 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
|
158
|
-
|
159
|
-
|
160
|
-
system_pods
|
161
|
-
current_contexts
|
162
|
-
end
|
197
|
+
print_contexts
|
198
|
+
print_minikube_status
|
163
199
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
puts Terminal::Table.new :title => "Pods Status".green, :headings => ['Name', 'Status'], :rows => rows
|
171
|
-
end
|
172
|
-
|
173
|
-
def system_pods
|
174
|
-
rows = []
|
175
|
-
pods("kube-system").map do |pod|
|
176
|
-
status = pod[:status] == "Running" ? pod[:status].green : pod[:status].red
|
177
|
-
rows << [pod[:name], status]
|
178
|
-
end
|
179
|
-
puts Terminal::Table.new :title => "System pods Status".green, :headings => ['Name', 'Status'], :rows => rows
|
200
|
+
if get_minikube_status.find_all { |status| status[1] == 'Stopped' }.count == 0
|
201
|
+
print_pods_status("kube-system")
|
202
|
+
print_pods_status
|
203
|
+
else
|
204
|
+
UI.important("Please check your minikube status. If all services are stopped you should start the minikube first.")
|
205
|
+
end
|
180
206
|
end
|
181
207
|
|
182
|
-
def
|
208
|
+
def print_contexts
|
183
209
|
output = `kubectl config get-contexts`
|
184
210
|
|
185
211
|
lines = output.split "\n"
|
186
212
|
lines = lines[1..-1]
|
187
213
|
|
188
|
-
rows =
|
189
|
-
|
190
|
-
columns = line.split(" ")
|
214
|
+
rows = lines.map do |line|
|
215
|
+
columns = line.split(" ")
|
191
216
|
|
192
|
-
|
193
|
-
|
217
|
+
current_context = columns[0] == "*" ? "Yes".green : "No".red
|
218
|
+
|
219
|
+
[columns[2], current_context]
|
194
220
|
end
|
195
|
-
|
221
|
+
|
222
|
+
puts Terminal::Table.new title: "Contexts".green, headings: ['Cluster', 'Using context'], rows: rows
|
196
223
|
end
|
197
224
|
|
198
|
-
def
|
225
|
+
def print_minikube_status
|
226
|
+
|
227
|
+
puts Terminal::Table.new title: "Minikube status".green, headings: ['Name', 'Status'], rows: get_minikube_status
|
228
|
+
end
|
229
|
+
|
230
|
+
def get_minikube_status
|
199
231
|
output = `#{minikube} status`
|
200
232
|
|
201
233
|
lines = output.split "\n"
|
202
234
|
|
203
|
-
rows =
|
204
|
-
lines.map do |line|
|
235
|
+
rows = lines.map do |line|
|
205
236
|
columns = line.split(" ")
|
206
237
|
|
207
|
-
|
238
|
+
[columns[0][0..-2], columns[1]]
|
208
239
|
end
|
209
|
-
puts Terminal::Table.new :title => "Minikube Status".green, :headings => ['Name', 'Status'], :rows => rows
|
210
240
|
end
|
211
241
|
|
212
|
-
def
|
213
|
-
if namespace
|
214
|
-
output = `kubectl get pods -n #{namespace}`
|
215
|
-
else
|
216
|
-
output = `kubectl get pods`
|
217
|
-
end
|
242
|
+
def print_pods_status(namespace = "default")
|
218
243
|
|
219
|
-
|
220
|
-
lines = output.split "\n"
|
221
|
-
|
222
|
-
# exclude first line (table header)
|
223
|
-
lines = lines[1..-1]
|
244
|
+
pods_list = pods(namespace)
|
224
245
|
|
225
|
-
|
226
|
-
|
227
|
-
|
246
|
+
if pods_list.to_a.empty?
|
247
|
+
return
|
248
|
+
end
|
228
249
|
|
229
|
-
|
230
|
-
|
231
|
-
|
250
|
+
rows = pods_list.map do |pod|
|
251
|
+
[
|
252
|
+
pod[:name],
|
253
|
+
pod[:status] == "Running" ? pod[:status].green : pod[:status].red
|
254
|
+
]
|
255
|
+
end
|
232
256
|
|
233
|
-
|
234
|
-
name: name,
|
235
|
-
status: status,
|
236
|
-
stalled: stalled
|
237
|
-
}
|
238
|
-
end
|
257
|
+
puts Terminal::Table.new title: "Pods (namespace: #{namespace})".green, headings: ['Name', 'Status'], rows: rows
|
239
258
|
end
|
240
259
|
|
241
260
|
def run_command command
|
@@ -245,15 +264,11 @@ module Sct
|
|
245
264
|
end
|
246
265
|
|
247
266
|
def minikube
|
248
|
-
if
|
267
|
+
if SctCore::Helper.operatingSystem == SctCore::Helper::WINDOWS
|
249
268
|
return "minikube.exe"
|
250
269
|
else
|
251
270
|
return "minikube"
|
252
271
|
end
|
253
272
|
end
|
254
|
-
|
255
|
-
implements CommandInterface
|
256
|
-
|
257
273
|
end
|
258
|
-
|
259
274
|
end
|