kontena-plugin-packet 0.1.2 → 0.2.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/kontena-plugin-packet.gemspec +2 -2
- data/lib/kontena/machine/packet/cloudinit_master.yml +5 -2
- data/lib/kontena/machine/packet/master_provisioner.rb +20 -16
- data/lib/kontena/machine/packet/node_destroyer.rb +3 -4
- data/lib/kontena/machine/packet/node_provisioner.rb +5 -6
- data/lib/kontena/machine/packet/node_restarter.rb +3 -4
- data/lib/kontena/plugin/packet/master/create_command.rb +2 -2
- data/lib/kontena/plugin/packet.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTE0NzVkM2EzYzQxMDEyNTE5YTUxMzEwZWYyYTZiYWRjYzZhOTJlOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzcxYjQ1ZDM5ZTIzNzdkNDQ0NmJmODQwYTZlZmQwNmJkMGEwOTI1Yw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODM5OTNkMTE1NDk4NDY1Y2U4YTQwZTdiOTIxN2U0MmI3NjRmZGM3NmI2MzUx
|
10
|
+
ZjEzODYyNzU0YWVkMGYxYWRmYmQxZjlmNjZkMmNlZjgyZWVjOTM3NjdlMGVm
|
11
|
+
OTVmMDk1YTc1M2FiYzRkMTc4NDg5MTQyNDc4MDgwYjk2NWRlOWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjFjNjAwNzg5NTFkZTI2MzIwY2ZkNTkyZDZiZTJiODc0ZTRhODJmZjk2MWFk
|
14
|
+
Y2I5NWI1ZWE1ZDM2MGVjN2IzODJiYmRkNDI3YjBjM2UyNTgwNDAzYjA3NzM2
|
15
|
+
MDAxYzZkYzhhMzczYWYzNmZmYmQyZGJjZjI4NGYzYTU5ZDc0NzI=
|
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.add_runtime_dependency 'kontena-cli', '
|
21
|
-
spec.add_runtime_dependency 'packethost', '>= 0.0.
|
20
|
+
spec.add_runtime_dependency 'kontena-cli', '>= 0.16.0.pre2'
|
21
|
+
spec.add_runtime_dependency 'packethost', '>= 0.0.6'
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.11"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
24
24
|
end
|
@@ -88,8 +88,11 @@ coreos:
|
|
88
88
|
--link kontena-server-mongo:mongodb \
|
89
89
|
-e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
|
90
90
|
<% end -%>
|
91
|
-
<% if
|
92
|
-
-e
|
91
|
+
<% if server_name %>
|
92
|
+
-e KONTENA_SERVER_NAME=<%= server_name %> \
|
93
|
+
<% end -%>
|
94
|
+
<% if initial_admin_code %>
|
95
|
+
-e KONTENA_INITIAL_ADMIN_CODE=<%= initial_admin_code %> \
|
93
96
|
<% end -%>
|
94
97
|
-e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
|
95
98
|
kontena/server:${KONTENA_VERSION}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
1
|
module Kontena
|
4
2
|
module Machine
|
5
3
|
module Packet
|
@@ -7,6 +5,7 @@ module Kontena
|
|
7
5
|
include RandomName
|
8
6
|
include Machine::CertHelper
|
9
7
|
include PacketCommon
|
8
|
+
include Kontena::Cli::ShellSpinner
|
10
9
|
|
11
10
|
attr_reader :client, :http_client
|
12
11
|
|
@@ -27,22 +26,20 @@ module Kontena
|
|
27
26
|
abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
|
28
27
|
ssl_cert = File.read(File.expand_path(opts[:ssl_cert]))
|
29
28
|
else
|
30
|
-
|
29
|
+
spinner "Generating self-signed SSL certificate" do
|
31
30
|
ssl_cert = generate_self_signed_cert
|
32
31
|
end
|
33
32
|
end
|
34
33
|
|
35
|
-
|
34
|
+
name = generate_name
|
35
|
+
|
36
|
+
userdata_vars = opts.merge(
|
36
37
|
ssl_cert: ssl_cert,
|
37
|
-
|
38
|
-
|
39
|
-
vault_secret: opts[:vault_secret],
|
40
|
-
vault_iv: opts[:vault_iv],
|
41
|
-
mongodb_uri: opts[:mongodb_uri]
|
42
|
-
}
|
38
|
+
server_name: name.sub('kontena-master-', '')
|
39
|
+
)
|
43
40
|
|
44
41
|
device = project.new_device(
|
45
|
-
hostname:
|
42
|
+
hostname: name,
|
46
43
|
facility: facility.to_hash,
|
47
44
|
operating_system: os.to_hash,
|
48
45
|
plan: plan.to_hash,
|
@@ -51,7 +48,7 @@ module Kontena
|
|
51
48
|
userdata: user_data(userdata_vars, 'cloudinit_master.yml')
|
52
49
|
)
|
53
50
|
|
54
|
-
|
51
|
+
spinner "Creating Packet device #{device.hostname.colorize(:cyan)} " do
|
55
52
|
api_retry "Packet API reported an error, please try again" do
|
56
53
|
response = client.create_device(device)
|
57
54
|
raise response.body unless response.success?
|
@@ -69,12 +66,19 @@ module Kontena
|
|
69
66
|
Excon.defaults[:ssl_verify_peer] = false
|
70
67
|
@http_client = Excon.new("#{master_url}", :connect_timeout => 10)
|
71
68
|
|
72
|
-
|
73
|
-
sleep 5 until master_running?
|
69
|
+
spinner "Waiting for #{device.hostname.colorize(:cyan)} to start (estimate 4 minutes)" do
|
70
|
+
sleep 0.5 until master_running?
|
74
71
|
end
|
75
72
|
|
76
|
-
puts
|
77
|
-
puts "
|
73
|
+
puts
|
74
|
+
puts "Kontena Master is now running at #{master_url}".colorize(:green)
|
75
|
+
puts
|
76
|
+
|
77
|
+
{
|
78
|
+
name: name.sub('kontena-master-', ''),
|
79
|
+
public_ip: public_ip['address'],
|
80
|
+
code: opts[:initial_admin_code]
|
81
|
+
}
|
78
82
|
end
|
79
83
|
|
80
84
|
def generate_name
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
1
|
module Kontena
|
4
2
|
module Machine
|
5
3
|
module Packet
|
6
4
|
class NodeDestroyer
|
7
5
|
include RandomName
|
8
6
|
include PacketCommon
|
7
|
+
include Kontena::Cli::ShellSpinner
|
9
8
|
|
10
9
|
attr_reader :client, :api_client
|
11
10
|
|
@@ -20,7 +19,7 @@ module Kontena
|
|
20
19
|
device = client.list_devices(project_id).find{|d| d.hostname == name}
|
21
20
|
abort("Device #{name.colorize(:cyan)} not found in Packet") unless device
|
22
21
|
|
23
|
-
|
22
|
+
spinner "Terminating Packet device #{name.colorize(:cyan)} " do
|
24
23
|
begin
|
25
24
|
response = client.delete_device(device.id)
|
26
25
|
raise unless response.success?
|
@@ -31,7 +30,7 @@ module Kontena
|
|
31
30
|
|
32
31
|
node = api_client.get("grids/#{grid['id']}/nodes")['nodes'].find{|n| n['name'] == name}
|
33
32
|
if node
|
34
|
-
|
33
|
+
spinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
|
35
34
|
api_client.delete("grids/#{grid['id']}/nodes/#{name}")
|
36
35
|
end
|
37
36
|
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
1
|
module Kontena
|
4
2
|
module Machine
|
5
3
|
module Packet
|
6
4
|
class NodeProvisioner
|
7
5
|
include RandomName
|
8
6
|
include PacketCommon
|
7
|
+
include Kontena::Cli::ShellSpinner
|
9
8
|
|
10
9
|
attr_reader :client, :api_client
|
11
10
|
|
@@ -40,7 +39,7 @@ module Kontena
|
|
40
39
|
userdata: user_data(userdata_vars, 'cloudinit.yml')
|
41
40
|
)
|
42
41
|
|
43
|
-
|
42
|
+
spinner "Creating Packet device #{device.hostname.colorize(:cyan)} " do
|
44
43
|
api_retry "Packet API reported an error, please try again" do
|
45
44
|
response = client.create_device(device)
|
46
45
|
raise response.body unless response.success?
|
@@ -48,13 +47,13 @@ module Kontena
|
|
48
47
|
|
49
48
|
until device && [:active, :provisioning, :powering_on].include?(device.state)
|
50
49
|
device = find_device(project.id, device.hostname) rescue nil
|
51
|
-
sleep
|
50
|
+
sleep 1
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
55
54
|
node = nil
|
56
|
-
|
57
|
-
sleep
|
55
|
+
spinner "Waiting for node #{device.hostname.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} (estimate 4 minutes) " do
|
56
|
+
sleep 0.5 until node = device_exists_in_grid?(opts[:grid], device)
|
58
57
|
end
|
59
58
|
set_labels(node, ["region=#{opts[:facility]}", "provider=packet"])
|
60
59
|
end
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
1
|
module Kontena
|
4
2
|
module Machine
|
5
3
|
module Packet
|
6
4
|
class NodeRestarter
|
7
5
|
include RandomName
|
8
6
|
include PacketCommon
|
7
|
+
include Kontena::Cli::ShellSpinner
|
9
8
|
|
10
9
|
attr_reader :client
|
11
10
|
|
@@ -21,7 +20,7 @@ module Kontena
|
|
21
20
|
abort("Device #{name.colorize(:cyan)} not found in Packet") unless device
|
22
21
|
abort("Your version of 'packethost' gem does not support rebooting servers") unless client.respond_to?(:reboot_device)
|
23
22
|
|
24
|
-
|
23
|
+
spinner "Restarting Packet device #{device.hostname.colorize(:cyan)} " do
|
25
24
|
begin
|
26
25
|
response = client.reboot_device(device)
|
27
26
|
raise unless response.success?
|
@@ -31,7 +30,7 @@ module Kontena
|
|
31
30
|
sleep 5
|
32
31
|
until device && device.state == :active
|
33
32
|
device = find_device(project.id, device.hostname) rescue nil
|
34
|
-
sleep
|
33
|
+
sleep 1
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
@@ -4,6 +4,7 @@ module Kontena::Plugin::Packet::Master
|
|
4
4
|
class CreateCommand < Kontena::Command
|
5
5
|
include Kontena::Cli::Common
|
6
6
|
|
7
|
+
option "--name", "[NAME]", "Set master name"
|
7
8
|
option "--token", "TOKEN", "Packet API token", required: true
|
8
9
|
option "--project", "PROJECT ID", "Packet project id", required: true
|
9
10
|
option "--ssl-cert", "PATH", "SSL certificate file (optional)"
|
@@ -15,7 +16,6 @@ module Kontena::Plugin::Packet::Master
|
|
15
16
|
option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
|
16
17
|
option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
|
17
18
|
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
18
|
-
option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
|
19
19
|
|
20
20
|
def execute
|
21
21
|
require_relative '../../../machine/packet'
|
@@ -29,9 +29,9 @@ module Kontena::Plugin::Packet::Master
|
|
29
29
|
plan: plan,
|
30
30
|
facility: facility,
|
31
31
|
version: version,
|
32
|
-
auth_server: auth_provider_url,
|
33
32
|
vault_secret: vault_secret || SecureRandom.hex(24),
|
34
33
|
vault_iv: vault_iv || SecureRandom.hex(24),
|
34
|
+
initial_admin_code: SecureRandom.hex(16),
|
35
35
|
mongodb_uri: mongodb_uri
|
36
36
|
)
|
37
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kontena-plugin-packet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kontena, Inc.
|
@@ -14,30 +14,30 @@ dependencies:
|
|
14
14
|
name: kontena-cli
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.16.0.pre2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.16.0.pre2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: packethost
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.6
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.
|
40
|
+
version: 0.0.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -113,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - ! '
|
116
|
+
- - ! '>'
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
118
|
+
version: 1.3.1
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
121
|
rubygems_version: 2.4.5
|