uffizzi-cli 2.4.8 → 2.4.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uffizzi/cli/install.rb +9 -33
- data/lib/uffizzi/cli/uninstall.rb +2 -2
- data/lib/uffizzi/services/install_service.rb +12 -12
- data/lib/uffizzi/services/kubeconfig_service.rb +6 -0
- data/lib/uffizzi/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: 208b6ac1dfb59b5b76aac7cc0b4a21c8b4c725e8e843958fe10b98bdd50ec43f
|
4
|
+
data.tar.gz: 7335a86326e93a84dbf67f31b3182d18a6fbf88a9e4ce4a4c04af265c68f3809
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5302d2e8db9c5afb7c2550d45a15125d98efd472f8ae6902739b6900260719d213b1c71d79050e70018ad4381849155a2cc0730ae89d9af1f7268e10f08af7ab
|
7
|
+
data.tar.gz: fbaf9bdba63f98ce1811d70e1388f9823baa32bf6bb28469e6e48a41d41d8b4e477b99addef053b290acfdc606f7ae5600c4ba77c2a5db4fed7356bca28c158c
|
data/lib/uffizzi/cli/install.rb
CHANGED
@@ -71,18 +71,18 @@ module Uffizzi
|
|
71
71
|
}
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
spinner = TTY::Spinner.new('[:spinner] Waiting IP
|
74
|
+
def wait_endpoint
|
75
|
+
spinner = TTY::Spinner.new('[:spinner] Waiting on IP address...', format: :dots)
|
76
76
|
spinner.auto_spin
|
77
77
|
|
78
|
-
|
78
|
+
endpoint = nil
|
79
79
|
try = 0
|
80
80
|
|
81
81
|
loop do
|
82
|
-
|
83
|
-
break if
|
82
|
+
endpoint = InstallService.get_controller_endpoint(namespace)
|
83
|
+
break if endpoint.present?
|
84
84
|
|
85
|
-
if try ==
|
85
|
+
if try == 90
|
86
86
|
spinner.error
|
87
87
|
|
88
88
|
return 'unknown'
|
@@ -94,30 +94,7 @@ module Uffizzi
|
|
94
94
|
|
95
95
|
spinner.success
|
96
96
|
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
def wait_certificate_request_ready(uri)
|
101
|
-
spinner = TTY::Spinner.new('[:spinner] Waiting create certificate for controller host...', format: :dots)
|
102
|
-
spinner.auto_spin
|
103
|
-
|
104
|
-
try = 0
|
105
|
-
|
106
|
-
loop do
|
107
|
-
requests = InstallService.get_certificate_request(namespace, uri)
|
108
|
-
break if requests.all? { |r| r['status'].downcase == 'true' }
|
109
|
-
|
110
|
-
if try == 60
|
111
|
-
spinner.error
|
112
|
-
|
113
|
-
return Uffizzi.ui.say('Stop waiting creation certificate')
|
114
|
-
end
|
115
|
-
|
116
|
-
try += 1
|
117
|
-
sleep(2)
|
118
|
-
end
|
119
|
-
|
120
|
-
spinner.success
|
97
|
+
endpoint
|
121
98
|
end
|
122
99
|
|
123
100
|
def build_helm_values(params)
|
@@ -219,11 +196,10 @@ module Uffizzi
|
|
219
196
|
end
|
220
197
|
|
221
198
|
def say_success(uri)
|
222
|
-
|
223
|
-
wait_certificate_request_ready(uri)
|
199
|
+
endpoint = wait_endpoint
|
224
200
|
|
225
201
|
msg = 'Your Uffizzi controller is ready. To configure DNS,'\
|
226
|
-
" create a record for the hostname '*.#{uri.host}' pointing to '#{
|
202
|
+
" create a record for the hostname '*.#{uri.host}' pointing to '#{endpoint}'"
|
227
203
|
Uffizzi.ui.say(msg)
|
228
204
|
end
|
229
205
|
|
@@ -12,7 +12,7 @@ module Uffizzi
|
|
12
12
|
default_task :controller
|
13
13
|
|
14
14
|
desc 'controller [HOSTNAME]', 'Install uffizzi controller to cluster'
|
15
|
-
method_option :namespace, type: :string
|
15
|
+
method_option :namespace, type: :string, aliases: '-n'
|
16
16
|
method_option :context, type: :string
|
17
17
|
def controller
|
18
18
|
Uffizzi::AuthHelper.check_login
|
@@ -86,7 +86,7 @@ module Uffizzi
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def namespace
|
89
|
-
options[:namespace] || InstallService
|
89
|
+
options[:namespace] || InstallService.current_namespace
|
90
90
|
end
|
91
91
|
|
92
92
|
def server
|
@@ -85,7 +85,7 @@ class InstallService
|
|
85
85
|
execute_command(cmd, say: false) { |stdout| stdout.present? && stdout.chop }
|
86
86
|
end
|
87
87
|
|
88
|
-
def
|
88
|
+
def get_controller_endpoint(namespace)
|
89
89
|
cmd = "kubectl get ingress -n #{namespace} -o json"
|
90
90
|
res = execute_command(cmd, say: false)
|
91
91
|
ingress = JSON.parse(res)['items'].detect { |i| i['metadata']['name'] = INGRESS_NAME }
|
@@ -95,18 +95,10 @@ class InstallService
|
|
95
95
|
load_balancers = ingress.dig('status', 'loadBalancer', 'ingress')
|
96
96
|
return if load_balancers.blank?
|
97
97
|
|
98
|
-
load_balancers.map { |i| i['ip'] }[0]
|
99
|
-
|
100
|
-
|
101
|
-
def get_certificate_request(namespace, uri)
|
102
|
-
cmd = "kubectl get certificaterequests -n #{namespace} -o json"
|
103
|
-
res = execute_command(cmd, say: false)
|
104
|
-
certificate_request = JSON.parse(res)['items'].detect { |i| i['metadata']['name'].include?(uri.host) }
|
105
|
-
|
106
|
-
return [] if certificate_request.nil?
|
98
|
+
ip = load_balancers.map { |i| i['ip'] }[0]
|
99
|
+
return ip if ip.present?
|
107
100
|
|
108
|
-
|
109
|
-
conditions.map { |c| c.slice('type', 'status') }
|
101
|
+
load_balancers.map { |i| i['hostname'] }[0]
|
110
102
|
end
|
111
103
|
|
112
104
|
def build_controller_host(host)
|
@@ -130,6 +122,14 @@ class InstallService
|
|
130
122
|
File.dirname(Uffizzi::ConfigFile.config_path)
|
131
123
|
end
|
132
124
|
|
125
|
+
def current_namespace
|
126
|
+
path = KubeconfigService.default_path
|
127
|
+
kubeconfig = KubeconfigService.read_kubeconfig(path)
|
128
|
+
return if kubeconfig.nil?
|
129
|
+
|
130
|
+
KubeconfigService.get_current_namespace(kubeconfig) || DEFAULT_NAMESPACE
|
131
|
+
end
|
132
|
+
|
133
133
|
private
|
134
134
|
|
135
135
|
def execute_command(command, say: true, skip_error: false)
|
@@ -50,6 +50,12 @@ class KubeconfigService
|
|
50
50
|
.dig('context', 'cluster')
|
51
51
|
end
|
52
52
|
|
53
|
+
def get_current_namespace(kubeconfig)
|
54
|
+
get_cluster_contexts(kubeconfig)
|
55
|
+
.detect { |c| c['name'] == get_current_context(kubeconfig) }
|
56
|
+
.dig('context', 'namespace')
|
57
|
+
end
|
58
|
+
|
53
59
|
def get_cluster_contexts(kubeconfig)
|
54
60
|
kubeconfig.fetch('contexts', [])
|
55
61
|
end
|
data/lib/uffizzi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uffizzi-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Thurman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|