sct 0.1.21 → 0.1.22
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/cluster/lib/cluster/commands_generator.rb +10 -10
- data/cluster/lib/cluster/runner.rb +42 -19
- data/sct/lib/sct/version.rb +1 -1
- metadata +2 -2
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
|
@@ -9,7 +9,7 @@ module Cluster
|
|
9
9
|
self.new.run
|
10
10
|
end
|
11
11
|
|
12
|
-
def run
|
12
|
+
def run
|
13
13
|
program :name, 'cluster'
|
14
14
|
program :version, Sct::VERSION
|
15
15
|
program :description, 'CLI for \'cluster\' - Manage your local kubernetes cluster'
|
@@ -22,8 +22,8 @@ module Cluster
|
|
22
22
|
c.description = "Start the cluster"
|
23
23
|
c.option '--clean', 'start a clean cluster. Old cluster will be purged if available.'
|
24
24
|
|
25
|
-
c.action do |args, options|
|
26
|
-
if options.clean
|
25
|
+
c.action do |args, options|
|
26
|
+
if options.clean
|
27
27
|
Cluster::Runner.new.reset
|
28
28
|
else
|
29
29
|
Cluster::Runner.new.launch
|
@@ -37,17 +37,17 @@ module Cluster
|
|
37
37
|
c.syntax = 'sct cluster down'
|
38
38
|
c.description = 'stop the cluster'
|
39
39
|
|
40
|
-
c.action do |args, options|
|
40
|
+
c.action do |args, options|
|
41
41
|
Cluster::Runner.new.down
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
command :reset do |c|
|
45
|
+
command :reset do |c|
|
46
46
|
|
47
47
|
c.syntax = 'sct cluster reset'
|
48
48
|
c.description = 'reset your cluster and start with a clean cluster'
|
49
49
|
|
50
|
-
c.action do |args, options|
|
50
|
+
c.action do |args, options|
|
51
51
|
Cluster::Runner.new.reset
|
52
52
|
end
|
53
53
|
end
|
@@ -59,13 +59,13 @@ module Cluster
|
|
59
59
|
c.syntax = 'sct cluster status'
|
60
60
|
c.description = 'see the status of your cluster'
|
61
61
|
|
62
|
-
c.action do |args, options|
|
62
|
+
c.action do |args, options|
|
63
63
|
Cluster::Runner.new.status
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
command :'update config' do |c|
|
68
|
-
|
68
|
+
|
69
69
|
c.syntax = 'sct cluster update config'
|
70
70
|
c.description = 'update the cluster configuration'
|
71
71
|
|
@@ -84,7 +84,7 @@ module Cluster
|
|
84
84
|
|
85
85
|
Cluster::Runner.new.delete_stalled_pods if options.stalled
|
86
86
|
Cluster::Runner.new.delete_all_pods if options.all
|
87
|
-
|
87
|
+
|
88
88
|
Cluster::Runner.new.delete_pods(args) if !args.empty?
|
89
89
|
|
90
90
|
end
|
@@ -106,4 +106,4 @@ module Cluster
|
|
106
106
|
run!
|
107
107
|
end
|
108
108
|
end
|
109
|
-
end
|
109
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Cluster
|
2
2
|
class Runner
|
3
|
-
|
4
|
-
def launch
|
3
|
+
|
4
|
+
def launch
|
5
5
|
return UI.error("SCT has not been initialized. Run 'sct init' first.") unless SctCore::Config.exists
|
6
6
|
start_cluster
|
7
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(" ")}"
|
@@ -33,10 +33,7 @@ module Cluster
|
|
33
33
|
run_command "#{minikube} delete"
|
34
34
|
start_cluster
|
35
35
|
create_secrets
|
36
|
-
|
37
|
-
run_command "#{minikube} addons enable ingress"
|
38
|
-
run_command "kubectl rollout status -n kube-system deployment/registry-creds"
|
39
|
-
run_command "kubectl rollout status -n kube-system deployment/nginx-ingress-controller"
|
36
|
+
enable_addons
|
40
37
|
wait_for_gcr_secret
|
41
38
|
run_command "kubectl apply -f ~/development/spend-cloud/k8s/ingress.yml"
|
42
39
|
wait_for_ingress_ip
|
@@ -46,6 +43,19 @@ module Cluster
|
|
46
43
|
post_start
|
47
44
|
end
|
48
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
|
+
|
49
59
|
def wait_for_pods
|
50
60
|
UI.important("Waiting for pods to become ready...")
|
51
61
|
|
@@ -71,7 +81,7 @@ module Cluster
|
|
71
81
|
end
|
72
82
|
end
|
73
83
|
|
74
|
-
def delete_all_pods
|
84
|
+
def delete_all_pods
|
75
85
|
run_command "kubectl delete pods --all"
|
76
86
|
end
|
77
87
|
|
@@ -105,12 +115,8 @@ module Cluster
|
|
105
115
|
run_command "kubectl rollout status -n kube-system deployment/coredns"
|
106
116
|
end
|
107
117
|
|
108
|
-
def
|
109
|
-
|
110
|
-
output = `kubectl get pods -n #{namespace}`
|
111
|
-
else
|
112
|
-
output = `kubectl get pods`
|
113
|
-
end
|
118
|
+
def deployments(namespace = "default")
|
119
|
+
output = `kubectl get deployments -n #{namespace}`
|
114
120
|
|
115
121
|
# split output lines
|
116
122
|
lines = output.split "\n"
|
@@ -118,9 +124,26 @@ module Cluster
|
|
118
124
|
# exclude first line (table header)
|
119
125
|
lines = lines[1..-1]
|
120
126
|
|
121
|
-
|
122
|
-
|
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
|
+
}
|
123
136
|
end
|
137
|
+
end
|
138
|
+
|
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]
|
124
147
|
|
125
148
|
# get name and status of each pod
|
126
149
|
lines.map do |line|
|
@@ -216,12 +239,12 @@ module Cluster
|
|
216
239
|
end
|
217
240
|
end
|
218
241
|
|
219
|
-
def print_pods_status(namespace =
|
242
|
+
def print_pods_status(namespace = "default")
|
220
243
|
|
221
244
|
pods_list = pods(namespace)
|
222
245
|
|
223
246
|
if pods_list.to_a.empty?
|
224
|
-
return
|
247
|
+
return
|
225
248
|
end
|
226
249
|
|
227
250
|
rows = pods_list.map do |pod|
|
@@ -231,7 +254,7 @@ module Cluster
|
|
231
254
|
]
|
232
255
|
end
|
233
256
|
|
234
|
-
puts Terminal::Table.new title: "Pods (namespace: #{namespace
|
257
|
+
puts Terminal::Table.new title: "Pods (namespace: #{namespace})".green, headings: ['Name', 'Status'], rows: rows
|
235
258
|
end
|
236
259
|
|
237
260
|
def run_command command
|
@@ -248,4 +271,4 @@ module Cluster
|
|
248
271
|
end
|
249
272
|
end
|
250
273
|
end
|
251
|
-
end
|
274
|
+
end
|
data/sct/lib/sct/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sct
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reshad Farid
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|