sct 0.1.21 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd0c29ef1fa29ea92d1ecd0e5190b72a10a6b8253c93e3cdea79c6cf02093bc8
4
- data.tar.gz: 987dcdf7f07e610c7c1f5dadf0096dbd006bd4a8da601cdeb59919c5b8fb95ac
3
+ metadata.gz: 61cca19491733244389c6a46e8c8fd8fd226b3cdab4fb8537b17a4e6d51d196e
4
+ data.tar.gz: 3057200714457d8b312f34f542454019155e634137d8a0de5ffe4fee93538d90
5
5
  SHA512:
6
- metadata.gz: 7cef3c668d1ff1bf1e92a0d1363582f6310af7f639c15983168cd5ee03e5885d05a4c409c518d90b53b74fedf3f1ac71945e201772dd131fc97ee3e652b062fe
7
- data.tar.gz: 98ed6109ff77991041a559db372a2a74e45b6693725025e258c020f506df77c355505af0510050fb2269566b994e42e6a247a03ac08f4538e70833904fd6014d
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
- run_command "#{minikube} addons enable registry-creds"
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 pods(namespace = nil)
109
- if namespace
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
- if lines.to_a.empty?
122
- return
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 = nil)
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 || "default"})".green, headings: ['Name', 'Status'], rows: rows
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
@@ -1,3 +1,3 @@
1
1
  module Sct
2
- VERSION = "0.1.21"
2
+ VERSION = "0.1.22"
3
3
  end
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.21
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-04-01 00:00:00.000000000 Z
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored