kontena-plugin-digitalocean 0.1.1 → 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-digitalocean.gemspec +1 -1
- data/lib/kontena/machine/digital_ocean/cloudinit.yml +0 -1
- data/lib/kontena/machine/digital_ocean/cloudinit_master.yml +5 -5
- data/lib/kontena/machine/digital_ocean/master_provisioner.rb +20 -16
- data/lib/kontena/machine/digital_ocean/node_destroyer.rb +3 -4
- data/lib/kontena/machine/digital_ocean/node_provisioner.rb +5 -5
- data/lib/kontena/plugin/digital_ocean.rb +1 -1
- data/lib/kontena/plugin/digital_ocean/master/create_command.rb +3 -3
- data/lib/kontena/plugin/digital_ocean/nodes/create_command.rb +1 -1
- data/lib/kontena/plugin/digital_ocean/nodes/restart_command.rb +3 -3
- data/lib/kontena/plugin/digital_ocean/nodes/terminate_command.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTZhZjg5NDVkYzI2ZjZmY2EyMTA0ZDk4YTRjMWU0ZjZhMGNiOGVkYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTVkMjYyZTA1Y2E1NmZiNDVlOThhYWExNWZlODFlOTM2ODFlZWVhZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGUxZjRmNWU3ODBmYjVlMTRkY2JjZWQ2NjRjYmE4YmJkNjJiYjc5ZjJkYTYx
|
10
|
+
ZGYxOWU2MTBjYmI4NzMwN2ZkNTFmODNkNzhmNmQ5ZmRkZmQzY2Y1ZTBiOWM3
|
11
|
+
ZDMzNzM4ZTg2NzM5YWExODFjNTIzNzBiZWM0YzBkNDQ0NDNmMWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDdkY2I3N2I3OGQ0NzJiNDY5ZDEzNjkwOWYyYWMzNTY1MWY2ZGQzYjkwMGE2
|
14
|
+
MzQyYTM5NzhkMjcwNDMwOGRmNTQwMDJhZGRmYWNlZDkyYmE0NDFjZjU1MjQ5
|
15
|
+
ZDIzMDdmOGZhMmM0ZDg4NTQ0ZWExNzJhOWMyNzAzYjQ0MTY5OGU=
|
@@ -17,7 +17,7 @@ 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', '>= 0.
|
20
|
+
spec.add_runtime_dependency 'kontena-cli', '>= 0.16.0.pre2'
|
21
21
|
spec.add_runtime_dependency 'droplet_kit', '~> 1.4', '>= 1.4.1'
|
22
22
|
spec.add_runtime_dependency 'activesupport', '~> 4.0'
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.11"
|
@@ -54,7 +54,6 @@ coreos:
|
|
54
54
|
ExecStart=/usr/bin/docker run --name=kontena-server-mongo \
|
55
55
|
--volumes-from=kontena-server-mongo-data \
|
56
56
|
mongo:3.0 mongod --smallfiles
|
57
|
-
ExecStop=/usr/bin/docker stop kontena-server-mongo
|
58
57
|
<% end -%>
|
59
58
|
- name: kontena-server-api.service
|
60
59
|
command: start
|
@@ -90,12 +89,14 @@ coreos:
|
|
90
89
|
--link kontena-server-mongo:mongodb \
|
91
90
|
-e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
|
92
91
|
<% end -%>
|
93
|
-
<% if
|
94
|
-
-e
|
92
|
+
<% if server_name %>
|
93
|
+
-e KONTENA_SERVER_NAME=<%= server_name %> \
|
94
|
+
<% end -%>
|
95
|
+
<% if initial_admin_code %>
|
96
|
+
-e KONTENA_INITIAL_ADMIN_CODE=<%= initial_admin_code %> \
|
95
97
|
<% end -%>
|
96
98
|
-e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
|
97
99
|
kontena/server:${KONTENA_VERSION}
|
98
|
-
ExecStop=/usr/bin/docker stop kontena-server-api
|
99
100
|
|
100
101
|
- name: kontena-server-haproxy.service
|
101
102
|
command: start
|
@@ -120,4 +121,3 @@ coreos:
|
|
120
121
|
ExecStartPre=-/usr/bin/docker rm kontena-server-haproxy
|
121
122
|
ExecStartPre=-/usr/bin/docker pull kontena/haproxy:latest
|
122
123
|
ExecStart=/opt/bin/kontena-haproxy.sh
|
123
|
-
ExecStop=/usr/bin/docker stop kontena-server-haproxy
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'erb'
|
3
3
|
require 'open3'
|
4
|
-
require 'shell-spinner'
|
5
4
|
|
6
5
|
module Kontena
|
7
6
|
module Machine
|
@@ -9,6 +8,7 @@ module Kontena
|
|
9
8
|
class MasterProvisioner
|
10
9
|
include RandomName
|
11
10
|
include Machine::CertHelper
|
11
|
+
include Kontena::Cli::ShellSpinner
|
12
12
|
|
13
13
|
attr_reader :client, :http_client
|
14
14
|
|
@@ -27,22 +27,19 @@ module Kontena
|
|
27
27
|
abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
|
28
28
|
ssl_cert = File.read(File.expand_path(opts[:ssl_cert]))
|
29
29
|
else
|
30
|
-
|
30
|
+
spinner "Generating self-signed SSL certificate" do
|
31
31
|
ssl_cert = generate_self_signed_cert
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
name = generate_name
|
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
|
droplet = DropletKit::Droplet.new(
|
45
|
-
name:
|
42
|
+
name: name,
|
46
43
|
region: opts[:region],
|
47
44
|
image: 'coreos-stable',
|
48
45
|
size: opts[:size],
|
@@ -51,11 +48,11 @@ module Kontena
|
|
51
48
|
ssh_keys: [ssh_key.id]
|
52
49
|
)
|
53
50
|
|
54
|
-
|
51
|
+
spinner "Creating DigitalOcean droplet #{droplet.name.colorize(:cyan)} " do
|
55
52
|
droplet = client.droplets.create(droplet)
|
56
53
|
until droplet.status == 'active'
|
57
54
|
droplet = client.droplets.find(id: droplet.id)
|
58
|
-
sleep
|
55
|
+
sleep 1
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
@@ -63,12 +60,19 @@ module Kontena
|
|
63
60
|
Excon.defaults[:ssl_verify_peer] = false
|
64
61
|
@http_client = Excon.new("#{master_url}", :connect_timeout => 10)
|
65
62
|
|
66
|
-
|
67
|
-
sleep 5 until master_running?
|
63
|
+
spinner "Waiting for #{droplet.name.colorize(:cyan)} to start" do
|
64
|
+
sleep 0.5 until master_running?
|
68
65
|
end
|
69
66
|
|
70
|
-
puts
|
71
|
-
puts "
|
67
|
+
puts
|
68
|
+
puts "Kontena Master is now running at #{master_url}".colorize(:green)
|
69
|
+
puts
|
70
|
+
|
71
|
+
{
|
72
|
+
name: name.sub('kontena-master-', ''),
|
73
|
+
public_ip: droplet.public_ip,
|
74
|
+
code: opts[:initial_admin_code]
|
75
|
+
}
|
72
76
|
end
|
73
77
|
|
74
78
|
def user_data(vars)
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
1
|
module Kontena
|
4
2
|
module Machine
|
5
3
|
module DigitalOcean
|
6
4
|
class NodeDestroyer
|
7
5
|
include RandomName
|
6
|
+
include Kontena::Cli::ShellSpinner
|
8
7
|
|
9
8
|
attr_reader :client, :api_client
|
10
9
|
|
@@ -18,7 +17,7 @@ module Kontena
|
|
18
17
|
def run!(grid, name)
|
19
18
|
droplet = client.droplets.all.find{|d| d.name == name}
|
20
19
|
if droplet
|
21
|
-
|
20
|
+
spinner "Terminating DigitalOcean droplet #{name.colorize(:cyan)} " do
|
22
21
|
result = client.droplets.delete(id: droplet.id)
|
23
22
|
if result.is_a?(String)
|
24
23
|
abort "Cannot delete droplet #{name.colorize(:cyan)} in DigitalOcean"
|
@@ -29,7 +28,7 @@ module Kontena
|
|
29
28
|
end
|
30
29
|
node = api_client.get("grids/#{grid['id']}/nodes")['nodes'].find{|n| n['name'] == name}
|
31
30
|
if node
|
32
|
-
|
31
|
+
spinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
|
33
32
|
api_client.delete("grids/#{grid['id']}/nodes/#{name}")
|
34
33
|
end
|
35
34
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'erb'
|
3
3
|
require 'open3'
|
4
|
-
require 'shell-spinner'
|
5
4
|
|
6
5
|
module Kontena
|
7
6
|
module Machine
|
8
7
|
module DigitalOcean
|
9
8
|
class NodeProvisioner
|
10
9
|
include RandomName
|
10
|
+
include Kontena::Cli::ShellSpinner
|
11
11
|
|
12
12
|
attr_reader :client, :api_client
|
13
13
|
|
@@ -40,12 +40,12 @@ module Kontena
|
|
40
40
|
ssh_keys: [ssh_key.id]
|
41
41
|
)
|
42
42
|
created = client.droplets.create(droplet)
|
43
|
-
|
44
|
-
sleep
|
43
|
+
spinner "Creating DigitalOcean droplet #{droplet.name.colorize(:cyan)} " do
|
44
|
+
sleep 1 until client.droplets.find(id: created.id).status == 'active'
|
45
45
|
end
|
46
46
|
node = nil
|
47
|
-
|
48
|
-
sleep
|
47
|
+
spinner "Waiting for node #{droplet.name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
|
48
|
+
sleep 1 until node = droplet_exists_in_grid?(opts[:grid], droplet)
|
49
49
|
end
|
50
50
|
set_labels(
|
51
51
|
node,
|
@@ -4,6 +4,7 @@ module Kontena::Plugin::DigitalOcean::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", "DigitalOcean API token", required: true
|
8
9
|
option "--ssh-key", "SSH_KEY", "Path to ssh public key", default: '~/.ssh/id_rsa.pub'
|
9
10
|
option "--ssl-cert", "SSL CERT", "SSL certificate file"
|
@@ -13,11 +14,10 @@ module Kontena::Plugin::DigitalOcean::Master
|
|
13
14
|
option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
|
14
15
|
option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
|
15
16
|
option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
|
16
|
-
option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
|
17
17
|
|
18
18
|
|
19
19
|
def execute
|
20
|
-
|
20
|
+
require 'kontena/machine/digital_ocean'
|
21
21
|
|
22
22
|
provisioner = provisioner(token)
|
23
23
|
provisioner.run!(
|
@@ -26,9 +26,9 @@ module Kontena::Plugin::DigitalOcean::Master
|
|
26
26
|
size: size,
|
27
27
|
region: region,
|
28
28
|
version: version,
|
29
|
-
auth_server: auth_provider_url,
|
30
29
|
vault_secret: vault_secret || SecureRandom.hex(24),
|
31
30
|
vault_iv: vault_iv || SecureRandom.hex(24),
|
31
|
+
initial_admin_code: SecureRandom.hex(16),
|
32
32
|
mongodb_uri: mongodb_uri
|
33
33
|
)
|
34
34
|
end
|
@@ -14,7 +14,7 @@ module Kontena::Plugin::DigitalOcean::Nodes
|
|
14
14
|
require_api_url
|
15
15
|
require_current_grid
|
16
16
|
|
17
|
-
|
17
|
+
require 'kontena/machine/digital_ocean'
|
18
18
|
grid = fetch_grid
|
19
19
|
provisioner = provisioner(client(require_token), token)
|
20
20
|
provisioner.run!(
|
@@ -10,14 +10,14 @@ module Kontena::Plugin::DigitalOcean::Nodes
|
|
10
10
|
require_api_url
|
11
11
|
require_current_grid
|
12
12
|
|
13
|
-
|
13
|
+
require 'kontena/machine/digital_ocean'
|
14
14
|
|
15
15
|
client = DropletKit::Client.new(access_token: token)
|
16
16
|
droplet = client.droplets.all.find{|d| d.name == name}
|
17
17
|
if droplet
|
18
|
-
|
18
|
+
spinner "Restarting DigitalOcean droplet #{name.colorize(:cyan)} " do
|
19
19
|
client.droplet_actions.reboot(droplet_id: droplet.id)
|
20
|
-
sleep
|
20
|
+
sleep 1 until client.droplets.find(id: droplet.id).status == 'active'
|
21
21
|
end
|
22
22
|
else
|
23
23
|
abort "Cannot find droplet #{name.colorize(:cyan)} in DigitalOcean"
|
@@ -10,7 +10,7 @@ module Kontena::Plugin::DigitalOcean::Nodes
|
|
10
10
|
require_api_url
|
11
11
|
require_current_grid
|
12
12
|
|
13
|
-
|
13
|
+
require 'kontena/machine/digital_ocean'
|
14
14
|
grid = client(require_token).get("grids/#{current_grid}")
|
15
15
|
destroyer = destroyer(client(require_token), token)
|
16
16
|
destroyer.run!(grid, name)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kontena-plugin-digitalocean
|
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.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kontena-cli
|
@@ -16,14 +16,14 @@ dependencies:
|
|
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: droplet_kit
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,9 +131,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
131
131
|
version: '0'
|
132
132
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- - ! '
|
134
|
+
- - ! '>'
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
136
|
+
version: 1.3.1
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
139
|
rubygems_version: 2.4.5
|