uffizzi-cli 2.4.7 → 2.4.9
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/lib/uffizzi/cli/cluster.rb +0 -3
- data/lib/uffizzi/cli/install.rb +5 -26
- data/lib/uffizzi/cli/uninstall.rb +2 -2
- data/lib/uffizzi/services/install_service.rb +8 -11
- data/lib/uffizzi/services/kubeconfig_service.rb +6 -0
- data/lib/uffizzi/version.rb +1 -1
- data/lib/uffizzi.rb +1 -0
- 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: 744480393ee81d335802bcb1008333c1e6c9b6f9870d7710dfff294698a1eb7a
|
4
|
+
data.tar.gz: cf43c7519e0621f9be3fbb18d9fd89fd0cf2a6ea0dc56d0b41662428e6d4b46c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef39ee4ce26c553068d279f3960ba924b7458fbf439a4ffd0abbed363fa359cbf9707df59e8ee439ff06f091894836f67d7bcdb8f2c78879caa7b52120e2dfb2
|
7
|
+
data.tar.gz: 6c0471f16b076c5c8dedd2b714416c6514e03f9ee96b6d6aead5d5fca19556ac6f09e73b44a050ef07f7cdcfd3a72d9bb2b14902eda9931b5251830389aacc57
|
data/lib/uffizzi/cli/cluster.rb
CHANGED
@@ -35,7 +35,6 @@ module Uffizzi
|
|
35
35
|
method_option :output, required: false, type: :string, aliases: '-o', enum: ['json', 'pretty-json']
|
36
36
|
method_option :'creation-source', required: false, type: :string
|
37
37
|
method_option :'k8s-version', required: false, type: :string
|
38
|
-
method_option :'node-selector', required: false, type: :string
|
39
38
|
def create(name = nil)
|
40
39
|
run('create', { name: name })
|
41
40
|
end
|
@@ -262,7 +261,6 @@ module Uffizzi
|
|
262
261
|
manifest_content = load_manifest_file(options[:manifest])
|
263
262
|
creation_source = options[:"creation-source"] || ClusterService::MANUAL_CREATION_SOURCE
|
264
263
|
k8s_version = options[:"k8s-version"]
|
265
|
-
node_selector = options[:"node-selector"]
|
266
264
|
|
267
265
|
{
|
268
266
|
cluster: {
|
@@ -270,7 +268,6 @@ module Uffizzi
|
|
270
268
|
manifest: manifest_content,
|
271
269
|
creation_source: creation_source,
|
272
270
|
k8s_version: k8s_version,
|
273
|
-
node_selector: node_selector,
|
274
271
|
},
|
275
272
|
token: oidc_token,
|
276
273
|
}
|
data/lib/uffizzi/cli/install.rb
CHANGED
@@ -17,6 +17,7 @@ module Uffizzi
|
|
17
17
|
method_option :context, type: :string
|
18
18
|
method_option :issuer, type: :string, enum: ['letsencrypt', 'zerossl']
|
19
19
|
method_option :'repo-url', type: :string
|
20
|
+
method_option :'node-selector-template', required: false, type: :string
|
20
21
|
def controller(hostname)
|
21
22
|
Uffizzi::AuthHelper.check_login
|
22
23
|
|
@@ -66,11 +67,12 @@ module Uffizzi
|
|
66
67
|
controller_password: generate_password,
|
67
68
|
cert_email: options[:email],
|
68
69
|
cluster_issuer: options[:issuer] || InstallService::DEFAULT_CLUSTER_ISSUER,
|
70
|
+
node_selector_template: options[:"node-selector-template"],
|
69
71
|
}
|
70
72
|
end
|
71
73
|
|
72
74
|
def wait_ip
|
73
|
-
spinner = TTY::Spinner.new('[:spinner] Waiting IP
|
75
|
+
spinner = TTY::Spinner.new('[:spinner] Waiting on IP address...', format: :dots)
|
74
76
|
spinner.auto_spin
|
75
77
|
|
76
78
|
ip = nil
|
@@ -80,7 +82,7 @@ module Uffizzi
|
|
80
82
|
ip = InstallService.get_controller_ip(namespace)
|
81
83
|
break if ip.present?
|
82
84
|
|
83
|
-
if try ==
|
85
|
+
if try == 90
|
84
86
|
spinner.error
|
85
87
|
|
86
88
|
return 'unknown'
|
@@ -95,29 +97,6 @@ module Uffizzi
|
|
95
97
|
ip
|
96
98
|
end
|
97
99
|
|
98
|
-
def wait_certificate_request_ready(uri)
|
99
|
-
spinner = TTY::Spinner.new('[:spinner] Waiting create certificate for controller host...', format: :dots)
|
100
|
-
spinner.auto_spin
|
101
|
-
|
102
|
-
try = 0
|
103
|
-
|
104
|
-
loop do
|
105
|
-
requests = InstallService.get_certificate_request(namespace, uri)
|
106
|
-
break if requests.all? { |r| r['status'].downcase == 'true' }
|
107
|
-
|
108
|
-
if try == 60
|
109
|
-
spinner.error
|
110
|
-
|
111
|
-
return Uffizzi.ui.say('Stop waiting creation certificate')
|
112
|
-
end
|
113
|
-
|
114
|
-
try += 1
|
115
|
-
sleep(2)
|
116
|
-
end
|
117
|
-
|
118
|
-
spinner.success
|
119
|
-
end
|
120
|
-
|
121
100
|
def build_helm_values(params)
|
122
101
|
{
|
123
102
|
global: {
|
@@ -212,12 +191,12 @@ module Uffizzi
|
|
212
191
|
managed_dns_zone: uri.host,
|
213
192
|
login: installation_options[:controller_username],
|
214
193
|
password: installation_options[:controller_password],
|
194
|
+
node_selector_template: installation_options[:node_selector_template],
|
215
195
|
}
|
216
196
|
end
|
217
197
|
|
218
198
|
def say_success(uri)
|
219
199
|
ip_address = wait_ip
|
220
|
-
wait_certificate_request_ready(uri)
|
221
200
|
|
222
201
|
msg = 'Your Uffizzi controller is ready. To configure DNS,'\
|
223
202
|
" create a record for the hostname '*.#{uri.host}' pointing to '#{ip_address}'"
|
@@ -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
|
@@ -98,17 +98,6 @@ class InstallService
|
|
98
98
|
load_balancers.map { |i| i['ip'] }[0]
|
99
99
|
end
|
100
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?
|
107
|
-
|
108
|
-
conditions = certificate_request.dig('status', 'conditions') || []
|
109
|
-
conditions.map { |c| c.slice('type', 'status') }
|
110
|
-
end
|
111
|
-
|
112
101
|
def build_controller_host(host)
|
113
102
|
[DEFAULT_CONTROLLER_DOMAIN_PREFIX, host].join('.')
|
114
103
|
end
|
@@ -130,6 +119,14 @@ class InstallService
|
|
130
119
|
File.dirname(Uffizzi::ConfigFile.config_path)
|
131
120
|
end
|
132
121
|
|
122
|
+
def current_namespace
|
123
|
+
path = KubeconfigService.default_path
|
124
|
+
kubeconfig = KubeconfigService.read_kubeconfig(path)
|
125
|
+
return if kubeconfig.nil?
|
126
|
+
|
127
|
+
KubeconfigService.get_current_namespace(kubeconfig) || DEFAULT_NAMESPACE
|
128
|
+
end
|
129
|
+
|
133
130
|
private
|
134
131
|
|
135
132
|
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
data/lib/uffizzi.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.9
|
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-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|