kontena-plugin-aws 0.1.0 → 0.2.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzEzZWQwNDVlMDA5ODZmMmU4NzBkM2FjMDhjYWZmYjk0ZWRlNjZjZg==
4
+ MjkzMTFkZDliMjJjNTI1NzhjYWFmMGZkYzllMzFmZDM2NjQxMzgwMQ==
5
5
  data.tar.gz: !binary |-
6
- M2UzYWZmMmU2YzcwN2RlZmZjYzBmOTkxYWMwZTgzMDNhNDUxMDU2NA==
6
+ ODIyMjJlNDM3NTRhOWNiM2UwZTJkZDRmZmEyY2U2ZDM0NjM1YTcxNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmFmMTA5NDFjN2U4NjFjMjU5MDQxNDFmN2MwNzY3M2Q3MWRmY2Y5MjdhZWEy
10
- MzMwZTg2ZTM4YjljNTAzNjBkMWIxY2NkYzk1NWRmMzZmYzYxZmRmMzc1YTQ0
11
- ZmZmNjI2ZTFiYmU3ZjhkYjU2MzBkZTlhMTc2MGMxZjMzZjZkOGU=
9
+ MmUwNDkwZTdjNjRkMWQyNGYzYjM0M2ZmYjc0ODI3MDczYzA5YWQxZWFiODcx
10
+ ZDBhMzI0OTEyMWY4N2M1MmRlYzI2ZjRmNjE5ZGExZjEwY2E1OWE1NWYxMzk4
11
+ NTYxYjY1OTUxNWU4ZTg1MTgyMjUyNTJiZDgwODM0MjQ4ZDljY2Y=
12
12
  data.tar.gz: !binary |-
13
- MmM5NzMyZjBhNmQ4NWM5M2Q2MWYzM2Y3NjVjNDIyZGVmNGNlNDkzY2ZiYTM4
14
- NzNjYmFkYmQ3NmY4Njc5YmIyY2I5NzBkZjNkOTMzOGQ2ZTU3ZGFhM2IyNDE5
15
- N2M5MDRlNzNmNWViMzg0NDBhNGUzNjc2ZDM5ZDQ2YjJmMmEzMGQ=
13
+ NjM4MGQ2YjMzZjUxMGE2ZTY3ODQ4ZTAzYmYzNDE5YmQ1Njc3OGQ3Nzg4YTcx
14
+ MTk3NzA1OWI0OWE4MjI4NjQyZWQ5ZTMxODIwM2M2MjYwYzJkOWE4Nzc5NDNl
15
+ ZjBlZDllOWVmNmY3MDY5MjI5YjM0MGMwZTVmM2MxOWJlNWM0NzY=
@@ -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.15.0.rc1'
20
+ spec.add_runtime_dependency 'kontena-cli', '~> 0.16.0.pre2'
21
21
  spec.add_runtime_dependency 'aws-sdk', '~> 2.3', '>= 2.3.11'
22
22
  spec.add_development_dependency "bundler", "~> 1.11"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
@@ -89,8 +89,11 @@ coreos:
89
89
  --link kontena-server-mongo:mongodb \
90
90
  -e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
91
91
  <% end -%>
92
- <% if auth_server %>
93
- -e AUTH_API_URL=<%= auth_server %> \
92
+ <% if server_name %>
93
+ -e KONTENA_SERVER_NAME=<%= server_name %> \
94
+ <% end -%>
95
+ <% if initial_admin_code %>
96
+ -e KONTENA_INITIAL_ADMIN_CODE=<%= intial_admin_code %> \
94
97
  <% end -%>
95
98
  -e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
96
99
  kontena/server:${KONTENA_VERSION}
@@ -1,7 +1,8 @@
1
1
  require 'fileutils'
2
2
  require 'erb'
3
3
  require 'open3'
4
- require 'shell-spinner'
4
+ require 'securerandom'
5
+
5
6
  require_relative 'common'
6
7
 
7
8
  module Kontena::Machine::Aws
@@ -9,6 +10,8 @@ module Kontena::Machine::Aws
9
10
  include Kontena::Machine::RandomName
10
11
  include Kontena::Machine::CertHelper
11
12
  include Common
13
+ include Kontena::Cli::ShellSpinner
14
+
12
15
  attr_reader :ec2, :http_client, :region
13
16
 
14
17
  # @param [String] access_key_id aws_access_key_id
@@ -27,7 +30,7 @@ module Kontena::Machine::Aws
27
30
  abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
28
31
  ssl_cert = File.read(File.expand_path(opts[:ssl_cert]))
29
32
  else
30
- ShellSpinner "Generating self-signed SSL certificate" do
33
+ spinner "Generating self-signed SSL certificate" do
31
34
  ssl_cert = generate_self_signed_cert
32
35
  end
33
36
  end
@@ -41,20 +44,18 @@ module Kontena::Machine::Aws
41
44
  subnet = ec2.subnet(opts[:subnet])
42
45
  end
43
46
  abort('Failed to find subnet!') unless subnet
44
- userdata_vars = {
47
+
48
+ name = opts[:name] || generate_name
49
+
50
+ userdata_vars = opts.merge(
45
51
  ssl_cert: ssl_cert,
46
- auth_server: opts[:auth_server],
47
- version: opts[:version],
48
- vault_secret: opts[:vault_secret],
49
- vault_iv: opts[:vault_iv],
50
- mongodb_uri: opts[:mongodb_uri]
51
- }
52
+ server_name: name.sub('kontena-master-', '')
53
+ )
52
54
 
53
55
  security_groups = opts[:security_groups] ?
54
56
  resolve_security_groups_to_ids(opts[:security_groups], opts[:vpc]) :
55
57
  ensure_security_group(opts[:vpc])
56
58
 
57
- name = generate_name
58
59
  ec2_instance = ec2.create_instances({
59
60
  image_id: ami,
60
61
  min_count: 1,
@@ -88,8 +89,8 @@ module Kontena::Machine::Aws
88
89
  ]
89
90
  })
90
91
 
91
- ShellSpinner "Creating AWS instance #{name.colorize(:cyan)} " do
92
- sleep 5 until ec2_instance.reload.state.name == 'running'
92
+ spinner "Creating AWS instance #{name.colorize(:cyan)} " do
93
+ sleep 1 until ec2_instance.reload.state.name == 'running'
93
94
  end
94
95
  public_ip = ec2_instance.reload.public_ip_address
95
96
  if public_ip.nil?
@@ -99,13 +100,18 @@ module Kontena::Machine::Aws
99
100
  master_url = "https://#{ec2_instance.public_ip_address}"
100
101
  Excon.defaults[:ssl_verify_peer] = false
101
102
  http_client = Excon.new(master_url, :connect_timeout => 10)
102
- ShellSpinner "Waiting for #{name.colorize(:cyan)} to start " do
103
- sleep 5 until master_running?(http_client)
103
+ spinner "Waiting for #{name.colorize(:cyan)} to start " do
104
+ sleep 1 until master_running?(http_client)
104
105
  end
105
106
  end
106
-
107
- puts "Kontena Master is now running at #{master_url}"
108
- puts "Use #{"kontena login --name=#{name.sub('kontena-master-', '')} #{master_url}".colorize(:light_black)} to complete Kontena Master setup"
107
+ puts
108
+ puts "Kontena Master is now running at #{master_url}".colorize(:green)
109
+ puts
110
+ {
111
+ name: name.sub('kontena-master-', ''),
112
+ public_ip: public_ip,
113
+ code: opts[:initial_admin_code]
114
+ }
109
115
  end
110
116
 
111
117
  ##
@@ -116,7 +122,7 @@ module Kontena::Machine::Aws
116
122
  group_id = resolve_security_groups_to_ids(group_name, vpc_id)
117
123
 
118
124
  if group_id.empty?
119
- ShellSpinner "Creating AWS security group" do
125
+ spinner "Creating AWS security group" do
120
126
  sg = create_security_group(group_name, vpc_id)
121
127
  group_id = [sg.group_id]
122
128
  end
@@ -1,10 +1,10 @@
1
- require 'shell-spinner'
2
-
3
1
  module Kontena
4
2
  module Machine
5
3
  module Aws
6
4
  class NodeDestroyer
7
5
 
6
+ include Kontena::Cli::ShellSpinner
7
+
8
8
  attr_reader :ec2, :api_client
9
9
 
10
10
  # @param [Kontena::Client] api_client Kontena api client
@@ -29,10 +29,10 @@ module Kontena
29
29
  abort("There are multiple instances with name #{name}") if instances.to_a.size > 1
30
30
  instance = instances.first
31
31
  if instance
32
- ShellSpinner "Terminating AWS instance #{name.colorize(:cyan)} " do
32
+ spinner "Terminating AWS instance #{name.colorize(:cyan)} " do
33
33
  instance.terminate
34
34
  until instance.reload.state.name.to_s == 'terminated'
35
- sleep 2
35
+ sleep 1
36
36
  end
37
37
  end
38
38
  else
@@ -40,7 +40,7 @@ module Kontena
40
40
  end
41
41
  node = api_client.get("grids/#{grid['id']}/nodes")['nodes'].find{|n| n['name'] == name}
42
42
  if node
43
- ShellSpinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
43
+ spinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
44
44
  api_client.delete("grids/#{grid['id']}/nodes/#{name}")
45
45
  end
46
46
  end
@@ -1,12 +1,12 @@
1
1
  require 'fileutils'
2
2
  require 'erb'
3
3
  require 'open3'
4
- require 'shell-spinner'
5
4
  require_relative 'common'
6
5
 
7
6
  module Kontena::Machine::Aws
8
7
  class NodeProvisioner
9
8
  include Kontena::Machine::RandomName
9
+ include Kontena::Cli::ShellSpinner
10
10
  include Common
11
11
 
12
12
  attr_reader :ec2, :api_client
@@ -83,12 +83,12 @@ module Kontena::Machine::Aws
83
83
  ]
84
84
  })
85
85
 
86
- ShellSpinner "Creating AWS instance #{name.colorize(:cyan)} " do
87
- sleep 5 until ec2_instance.reload.state.name == 'running'
86
+ spinner "Creating AWS instance #{name.colorize(:cyan)} " do
87
+ sleep 1 until ec2_instance.reload.state.name == 'running'
88
88
  end
89
89
  node = nil
90
- ShellSpinner "Waiting for node #{name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
91
- sleep 2 until node = instance_exists_in_grid?(opts[:grid], name)
90
+ spinner "Waiting for node #{name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
91
+ sleep 1 until node = instance_exists_in_grid?(opts[:grid], name)
92
92
  end
93
93
  labels = [
94
94
  "region=#{region}",
@@ -106,7 +106,7 @@ module Kontena::Machine::Aws
106
106
  group_id = resolve_security_groups_to_ids(group_name, vpc_id)
107
107
 
108
108
  if group_id.empty?
109
- ShellSpinner "Creating AWS security group" do
109
+ spinner "Creating AWS security group" do
110
110
  sg = create_security_group(group_name, vpc_id)
111
111
  group_id = [sg.group_id]
112
112
  end
@@ -1,9 +1,9 @@
1
- require 'shell-spinner'
2
1
  require_relative 'common'
3
2
 
4
3
  module Kontena::Machine::Aws
5
4
  class NodeRestarter
6
5
  include Common
6
+ include Kontena::Cli::ShellSpinner
7
7
 
8
8
  attr_reader :ec2, :api_client
9
9
 
@@ -26,7 +26,7 @@ module Kontena::Machine::Aws
26
26
  abort("There are multiple instances with name #{name}") if instances.to_a.size > 1
27
27
  instance = instances.first
28
28
  if instance
29
- ShellSpinner "Restarting AWS instance #{name.colorize(:cyan)} " do
29
+ spinner "Restarting AWS instance #{name.colorize(:cyan)} " do
30
30
  instance.reboot(dry_run: false)
31
31
  end
32
32
  else
@@ -1,7 +1,7 @@
1
1
  module Kontena
2
2
  module Plugin
3
3
  module Aws
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0.pre1"
5
5
  end
6
6
  end
7
7
  end
@@ -4,6 +4,7 @@ module Kontena::Plugin::Aws::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 "--access-key", "ACCESS_KEY", "AWS access key ID", required: true
8
9
  option "--secret-key", "SECRET_KEY", "AWS secret key", required: true
9
10
  option "--key-pair", "KEY_PAIR", "EC2 key pair name", required: true
@@ -18,16 +19,15 @@ module Kontena::Plugin::Aws::Master
18
19
  option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (default: generate random iv)"
19
20
  option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
20
21
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
21
- option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url (optional)"
22
22
  option "--associate-public-ip-address", :flag, "Whether to associated public IP in case the VPC defaults to not doing it", default: true, attribute_name: :associate_public_ip
23
23
  option "--security-groups", "SECURITY_GROUPS", "Comma separated list of security groups (names) where the new instance will be attached (default: create 'kontena_master' group if not already existing)"
24
24
 
25
-
26
25
  def execute
27
26
  require 'kontena/machine/aws'
28
27
 
29
28
  provisioner = provisioner(access_key, secret_key, region)
30
29
  provisioner.run!(
30
+ name: name,
31
31
  type: type,
32
32
  vpc: vpc_id,
33
33
  zone: zone,
@@ -36,12 +36,12 @@ module Kontena::Plugin::Aws::Master
36
36
  storage: storage,
37
37
  version: version,
38
38
  key_pair: key_pair,
39
- auth_server: auth_provider_url,
40
39
  vault_secret: vault_secret || SecureRandom.hex(24),
41
40
  vault_iv: vault_iv || SecureRandom.hex(24),
42
41
  mongodb_uri: mongodb_uri,
43
42
  associate_public_ip: associate_public_ip?,
44
- security_groups: security_groups
43
+ security_groups: security_groups,
44
+ initial_admin_code: SecureRandom.hex(16)
45
45
  )
46
46
  end
47
47
 
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-plugin-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.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-08-11 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
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.15.0.rc1
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.15.0.rc1
26
+ version: 0.16.0.pre2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: aws-sdk
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -119,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ! '>'
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 1.3.1
125
125
  requirements: []
126
126
  rubyforge_project:
127
127
  rubygems_version: 2.4.5