kontena-plugin-digitalocean 0.2.5 → 0.3.0

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
  SHA1:
3
- metadata.gz: deadff953354c92fab1891f6e1fca0f725120205
4
- data.tar.gz: 9b54bb0396371c0c79d19db0274c52fcc80ad720
3
+ metadata.gz: 1bb6451500eb7cd117546fb2f5079745ea23773f
4
+ data.tar.gz: 5383038aeb7fa4a3e638d40a4d93b9d4ecb2f9f4
5
5
  SHA512:
6
- metadata.gz: a51766a402fcc963ef828b887c7c0035d75c90bc37b4dedd6fda06cc55272f3897324c07a7598c7c8810b46fbf37e5a3d6378164fcc33a874618d9efdae7931c
7
- data.tar.gz: abf406883e010a9b9d068730ec438819cba343b45a79cb95fb32abc35df4deefbb886a7f42796a35f46f202e67123b27e48f53e04a73716e5c9ebbdf31b99235
6
+ metadata.gz: 071c61535e2a8ba9caf1f39a06ba95828b338bf69a61d937828f6c1d5592dd1853efe4adaa9d10661bb6a20b1837b0e905c126e0fe27159c056963321fd0d0c7
7
+ data.tar.gz: 0d7d1e867703e1a800696d1421fa67062fc7663c38f161e4e67103b273b692fc29727c02d0594d03b46451fd8250bedc43f157cec823939c517c47ddbe96eb9d
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_runtime_dependency 'kontena-cli', '>= 1.0'
21
- spec.add_runtime_dependency 'droplet_kit', '~> 1.4', '>= 1.4.1'
21
+ spec.add_runtime_dependency 'droplet_kit', '~> 2.0', '>= 2.0.1'
22
22
  spec.add_runtime_dependency 'activesupport', '~> 4.0'
23
23
  spec.add_development_dependency "bundler", "~> 1.11"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
@@ -4,3 +4,4 @@ require 'kontena/machine/cert_helper'
4
4
  require_relative 'digital_ocean/node_provisioner'
5
5
  require_relative 'digital_ocean/node_destroyer'
6
6
  require_relative 'digital_ocean/master_provisioner'
7
+ require_relative 'digital_ocean/master_destroyer'
@@ -11,7 +11,7 @@ write_files:
11
11
  - path: /etc/systemd/system/docker.service.d/50-kontena.conf
12
12
  content: |
13
13
  [Service]
14
- Environment='DOCKER_OPTS=--insecure-registry="10.81.0.0/16" --bip="172.17.43.1/16"'
14
+ Environment='DOCKER_OPTS=--insecure-registry="10.81.0.0/16" --bip="172.17.43.1/16" -s overlay2'
15
15
  Environment='DOCKER_CGROUPS=--exec-opt native.cgroupdriver=cgroupfs'
16
16
  - path: /etc/sysctl.d/99-inotify.conf
17
17
  owner: root
@@ -0,0 +1,30 @@
1
+ module Kontena
2
+ module Machine
3
+ module DigitalOcean
4
+ class MasterDestroyer
5
+ include Kontena::Cli::ShellSpinner
6
+
7
+ attr_reader :client, :api_client
8
+
9
+ # @param [String] token Digital Ocean token
10
+ def initialize(token)
11
+ @client = DropletKit::Client.new(access_token: token)
12
+ end
13
+
14
+ def run!(name)
15
+ droplet = client.droplets.all.find{|d| d.name == name}
16
+ if droplet
17
+ spinner "Terminating DigitalOcean droplet #{name.colorize(:cyan)} " do
18
+ result = client.droplets.delete(id: droplet.id)
19
+ if result.is_a?(String)
20
+ abort "Cannot delete droplet #{name.colorize(:cyan)} in DigitalOcean"
21
+ end
22
+ end
23
+ else
24
+ abort "Cannot find droplet #{name.colorize(:cyan)} in DigitalOcean"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -32,10 +32,10 @@ module Kontena
32
32
  end
33
33
  end
34
34
 
35
- name = generate_name
35
+ name = opts[:name]
36
36
  userdata_vars = opts.merge(
37
37
  ssl_cert: ssl_cert,
38
- server_name: name.sub('kontena-master-', '')
38
+ server_name: name
39
39
  )
40
40
 
41
41
  droplet = DropletKit::Droplet.new(
@@ -45,7 +45,8 @@ module Kontena
45
45
  size: opts[:size],
46
46
  private_networking: true,
47
47
  user_data: user_data(userdata_vars),
48
- ssh_keys: [ssh_key.id]
48
+ ssh_keys: [ssh_key.id],
49
+ tags: ['master']
49
50
  )
50
51
 
51
52
  spinner "Creating DigitalOcean droplet #{droplet.name.colorize(:cyan)} " do
@@ -88,10 +89,6 @@ module Kontena
88
89
  erb(File.read(cloudinit_template), vars)
89
90
  end
90
91
 
91
- def generate_name
92
- "kontena-master-#{super}-#{rand(1..9)}"
93
- end
94
-
95
92
  def ssh_key(public_key)
96
93
  client.ssh_keys.all.find{|key| key.public_key == public_key}
97
94
  end
@@ -29,16 +29,18 @@ module Kontena
29
29
  master_uri: opts[:master_uri],
30
30
  grid_token: opts[:grid_token],
31
31
  }
32
+ image = "coreos-#{opts[:channel]}"
32
33
  droplets = []
33
34
  opts[:count].to_i.times do
34
35
  droplet = DropletKit::Droplet.new(
35
36
  name: opts[:name] || generate_name,
36
37
  region: opts[:region],
37
- image: 'coreos-stable',
38
+ image: image,
38
39
  size: opts[:size],
39
40
  private_networking: true,
40
41
  user_data: user_data(userdata_vars),
41
- ssh_keys: [ssh_key.id]
42
+ ssh_keys: [ssh_key.id],
43
+ tags: [opts[:grid]]
42
44
  )
43
45
  created = client.droplets.create(droplet)
44
46
  spinner "Creating DigitalOcean droplet #{droplet.name.colorize(:cyan)} " do
@@ -1,7 +1,7 @@
1
1
  module Kontena
2
2
  module Plugin
3
3
  module DigitalOcean
4
- VERSION = "0.2.5"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -7,7 +7,7 @@ module Kontena::Plugin::DigitalOcean::Master
7
7
  include Kontena::Plugin::DigitalOcean::Prompts
8
8
 
9
9
  option "--name", "[NAME]", "Set master name"
10
- option "--token", "TOKEN", "DigitalOcean API token", environment_variable: "DO_TOKEN"
10
+ option "--token", "TOKEN", "DigitalOcean API token", environment_variable: "DO_TOKEN"
11
11
  option "--region", "REGION", "Region"
12
12
  option "--size", "SIZE", "Droplet size"
13
13
  option "--ssh-key", "SSH_KEY", "Path to ssh public key", default: '~/.ssh/id_rsa.pub'
@@ -28,15 +28,16 @@ module Kontena::Plugin::DigitalOcean::Master
28
28
 
29
29
  provisioner = provisioner(do_token)
30
30
  provisioner.run!(
31
- ssh_key: ssh_key,
32
- ssl_cert: ssl_cert,
33
- size: do_size,
34
- region: do_region,
35
- version: version,
36
- vault_secret: vault_secret || SecureRandom.hex(24),
37
- vault_iv: vault_iv || SecureRandom.hex(24),
38
- initial_admin_code: SecureRandom.hex(16),
39
- mongodb_uri: mongodb_uri
31
+ name: name,
32
+ ssh_key: ssh_key,
33
+ ssl_cert: ssl_cert,
34
+ size: do_size,
35
+ region: do_region,
36
+ version: version,
37
+ vault_secret: vault_secret || SecureRandom.hex(24),
38
+ vault_iv: vault_iv || SecureRandom.hex(24),
39
+ initial_admin_code: SecureRandom.hex(16),
40
+ mongodb_uri: mongodb_uri
40
41
  )
41
42
  end
42
43
 
@@ -0,0 +1,25 @@
1
+ module Kontena::Plugin::DigitalOcean::Master
2
+ class TerminateCommand < Kontena::Command
3
+ include Kontena::Cli::Common
4
+ include Kontena::Cli::GridOptions
5
+ include Kontena::Plugin::DigitalOcean::Prompts
6
+
7
+ parameter "NAME", "Master name"
8
+ option "--token", "TOKEN", "DigitalOcean API token", environment_variable: "DO_TOKEN"
9
+ option "--force", :flag, "Force remove", default: false, attribute_name: :forced
10
+
11
+ def execute
12
+ do_token = ask_do_token
13
+ confirm_command(name) unless forced?
14
+
15
+ require_relative '../../../machine/digital_ocean'
16
+ destroyer = destroyer(do_token)
17
+ destroyer.run!(name)
18
+ end
19
+
20
+ # @param [String] token
21
+ def destroyer(token)
22
+ Kontena::Machine::DigitalOcean::MasterDestroyer.new(token)
23
+ end
24
+ end
25
+ end
@@ -1,8 +1,10 @@
1
1
  require_relative 'master/create_command'
2
+ require_relative 'master/terminate_command'
2
3
 
3
4
  class Kontena::Plugin::DigitalOcean::MasterCommand < Kontena::Command
4
5
 
5
6
  subcommand "create", "Create a new master to DigitalOcean", Kontena::Plugin::DigitalOcean::Master::CreateCommand
7
+ subcommand "terminate", "Terminate DigitalOcean master", Kontena::Plugin::DigitalOcean::Master::TerminateCommand
6
8
 
7
9
  def execute
8
10
  end
@@ -13,6 +13,7 @@ module Kontena::Plugin::DigitalOcean::Nodes
13
13
  option "--size", "SIZE", "Droplet size"
14
14
  option "--count", "COUNT", "How many droplets to create"
15
15
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
16
+ option "--channel", "CHANNEL", "Define CoreOS image channel"
16
17
 
17
18
  def execute
18
19
  require_api_url
@@ -23,6 +24,7 @@ module Kontena::Plugin::DigitalOcean::Nodes
23
24
  require_relative '../../../machine/digital_ocean'
24
25
 
25
26
  do_region = ask_droplet_region(do_token)
27
+ coreos_channel = self.channel || ask_channel
26
28
  do_size = ask_droplet_size(do_token, do_region)
27
29
  do_count = ask_droplet_count
28
30
 
@@ -37,7 +39,8 @@ module Kontena::Plugin::DigitalOcean::Nodes
37
39
  size: do_size,
38
40
  count: do_count,
39
41
  region: do_region,
40
- version: version
42
+ version: version,
43
+ channel: coreos_channel
41
44
  )
42
45
  end
43
46
 
@@ -53,4 +53,12 @@ module Kontena::Plugin::DigitalOcean::Prompts
53
53
  self.name
54
54
  end
55
55
  end
56
+
57
+ def ask_channel
58
+ prompt.select('Select CoreOS channel') do |menu|
59
+ menu.choice 'Stable', 'stable'
60
+ menu.choice 'Beta', 'beta'
61
+ menu.choice 'Alpha', 'alpha'
62
+ end
63
+ end
56
64
  end
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.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kontena-cli
@@ -30,20 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.4'
33
+ version: '2.0'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 1.4.1
36
+ version: 2.0.1
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '1.4'
43
+ version: '2.0'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.4.1
46
+ version: 2.0.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activesupport
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -104,11 +104,13 @@ files:
104
104
  - lib/kontena/machine/digital_ocean.rb
105
105
  - lib/kontena/machine/digital_ocean/cloudinit.yml
106
106
  - lib/kontena/machine/digital_ocean/cloudinit_master.yml
107
+ - lib/kontena/machine/digital_ocean/master_destroyer.rb
107
108
  - lib/kontena/machine/digital_ocean/master_provisioner.rb
108
109
  - lib/kontena/machine/digital_ocean/node_destroyer.rb
109
110
  - lib/kontena/machine/digital_ocean/node_provisioner.rb
110
111
  - lib/kontena/plugin/digital_ocean.rb
111
112
  - lib/kontena/plugin/digital_ocean/master/create_command.rb
113
+ - lib/kontena/plugin/digital_ocean/master/terminate_command.rb
112
114
  - lib/kontena/plugin/digital_ocean/master_command.rb
113
115
  - lib/kontena/plugin/digital_ocean/node_command.rb
114
116
  - lib/kontena/plugin/digital_ocean/nodes/create_command.rb