kontena-plugin-azure 0.2.5 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7eb0bae5a7d6c9367edd39c2bc9e1f582f7a1403
4
- data.tar.gz: 97ea749df64bbd363f6a9342094494e219ed9612
3
+ metadata.gz: ed37995c9d3102552fd3191c64daa79c00a26e0d
4
+ data.tar.gz: 3b722e2faceac42808618b62af6fad7d332b36ee
5
5
  SHA512:
6
- metadata.gz: 22803c8c155cccd5cf3461c346e9240c56b7ade8063aa57a148c0ab4849d200785f4562d6620016e2dda6727bc4c8389c4204507a413f01c78730e4631f8a3d7
7
- data.tar.gz: 84b2a7e39bd0ad22288a973fc479e3b128afe0a3636c371639f749e99f58c7297a30324b42100b9530e887d4eb6cc9865b8c9cf6a56c1146eee92a8a12d97e04
6
+ metadata.gz: 6661770c294512dcce55ccc1c7f8287599950405c0a2ef387f5b93daf7840c338b699b381ad3f7995ca384e1d26e73d2e5d6d2fbe3ed554421acea88605101ec
7
+ data.tar.gz: e9c900a5deb4b288242ebf45c9322fd91320b8f398ff085d55a2b092650e857fda92bab1384ae3135474fd33d60dda9520d9ad671a533ddf08731288e5d8a382
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Kontena, Inc."]
10
10
  spec.email = ["info@kontena.io"]
11
11
 
12
- spec.summary = "Kontena Azure plugin"
13
- spec.description = "Kontena Microsoft Azure plugin"
12
+ spec.summary = "Kontena Azure (classic) plugin"
13
+ spec.description = "Kontena Microsoft Azure (classic) plugin"
14
14
  spec.homepage = "https://github.com/kontena/kontena-plugin-azure"
15
15
  spec.license = "Apache-2.0"
16
16
 
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_runtime_dependency 'kontena-cli', '>= 1.0'
21
21
  spec.add_runtime_dependency 'nokogiri', '~> 1.6.0'
22
- spec.add_runtime_dependency 'azure', '0.7.0'
22
+ spec.add_runtime_dependency 'azure', '0.7.7'
23
23
  spec.add_development_dependency "bundler", "~> 1.11"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  end
@@ -1,5 +1,6 @@
1
1
  require 'azure'
2
2
  require 'kontena/machine/random_name'
3
+ require 'kontena/machine/cert_helper'
3
4
  require_relative 'azure/logger'
4
5
  require_relative 'azure/node_provisioner'
5
6
  require_relative 'azure/node_destroyer'
@@ -6,7 +6,7 @@ write_files:
6
6
  content: |
7
7
  KONTENA_URI="<%= master_uri %>"
8
8
  KONTENA_TOKEN="<%= grid_token %>"
9
- KONTENA_PEER_INTERFACE=eth1
9
+ KONTENA_PEER_INTERFACE=eth0
10
10
  KONTENA_VERSION=<%= version %>
11
11
  - path: /etc/systemd/system/docker.service.d/50-kontena.conf
12
12
  content: |
@@ -37,14 +37,21 @@ coreos:
37
37
  Restart=always
38
38
  RestartSec=5
39
39
  ExecStart=/usr/bin/docker logs --tail=10 -f kontena-etcd
40
- - name: 10-weave.network
40
+ - name: 50-docker.network
41
+ mask: true
42
+ - name: 50-docker-veth.network
43
+ mask: true
44
+ - name: zz-default.network
41
45
  runtime: false
42
46
  content: |
47
+ # default should only match real network interfaces
43
48
  [Match]
44
- Type=bridge
45
- Name=weave*
46
-
49
+ Name=eth*
47
50
  [Network]
51
+ DHCP=yes
52
+ [DHCP]
53
+ UseMTU=true
54
+ UseDomains=true
48
55
  - name: kontena-agent.service
49
56
  command: start
50
57
  enable: true
@@ -62,6 +69,7 @@ coreos:
62
69
  Restart=always
63
70
  RestartSec=5
64
71
  EnvironmentFile=/etc/kontena-agent.env
72
+ EnvironmentFile=-/etc/kontena-agent.custom.env
65
73
  ExecStartPre=-/usr/bin/docker stop kontena-agent
66
74
  ExecStartPre=-/usr/bin/docker rm kontena-agent
67
75
  ExecStartPre=/usr/bin/docker pull kontena/agent:${KONTENA_VERSION}
@@ -73,3 +81,4 @@ coreos:
73
81
  -v=/etc/kontena-agent.env:/etc/kontena.env \
74
82
  --net=host \
75
83
  kontena/agent:${KONTENA_VERSION}
84
+ ExecStop=/usr/bin/docker stop kontena-agent
@@ -53,6 +53,7 @@ coreos:
53
53
  ExecStart=/usr/bin/docker run --name=kontena-server-mongo \
54
54
  --volumes-from=kontena-server-mongo-data \
55
55
  mongo:3.0 mongod --smallfiles
56
+ ExecStop=/usr/bin/docker stop kontena-server-mongo
56
57
 
57
58
  - name: kontena-server-api.service
58
59
  command: start
@@ -82,9 +83,9 @@ coreos:
82
83
  -e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
83
84
  -e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
84
85
  <% if server_name %>-e SERVER_NAME=<%= server_name %><% end %> \
85
- <% if initial_admin_code %>-e INITIAL_ADMIN_CODE=<%= intial_admin_code %><% end %> \
86
+ <% if initial_admin_code %>-e INITIAL_ADMIN_CODE=<%= initial_admin_code %><% end %> \
86
87
  kontena/server:${KONTENA_VERSION}
87
-
88
+ ExecStop=/usr/bin/docker stop kontena-server-api
88
89
  - name: kontena-server-haproxy.service
89
90
  command: start
90
91
  enable: true
@@ -107,3 +108,4 @@ coreos:
107
108
  ExecStartPre=-/usr/bin/docker rm kontena-server-haproxy
108
109
  ExecStartPre=-/usr/bin/docker pull kontena/haproxy:latest
109
110
  ExecStart=/opt/bin/kontena-haproxy.sh
111
+ ExecStop=/usr/bin/docker stop kontena-server-haproxy
@@ -0,0 +1,33 @@
1
+ module Kontena
2
+ module Machine
3
+ module Azure
4
+ module Common
5
+
6
+ def create_virtual_network(name, location)
7
+ address_space = ['10.0.0.0/20']
8
+ options = {subnet: [{:name => 'subnet-1', :ip_address=>'10.0.0.0', :cidr=>23}]}
9
+ client.network_management.set_network_configuration(name, location, address_space, options)
10
+ end
11
+
12
+ def virtual_network_exist?(name)
13
+ client.network_management.list_virtual_networks.find{|n| n.name == name}
14
+ end
15
+
16
+ def erb(template, vars)
17
+ ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
18
+ end
19
+
20
+ # @return [String]
21
+ def find_coreos_image
22
+ images = client.vm_image_management.list_os_images.select { |i|
23
+ i.name.include?('__CoreOS-Stable-')
24
+ }.sort_by { |i|
25
+ i.name.split('__CoreOS-Stable-')[1].to_i
26
+ }
27
+ image = images[-1]
28
+ image.name
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -2,13 +2,16 @@ require 'fileutils'
2
2
  require 'erb'
3
3
  require 'open3'
4
4
  require 'json'
5
+ require_relative 'common'
5
6
 
6
7
  module Kontena
7
8
  module Machine
8
9
  module Azure
9
10
  class MasterProvisioner
10
11
  include Kontena::Machine::RandomName
12
+ include Kontena::Machine::CertHelper
11
13
  include Kontena::Cli::ShellSpinner
14
+ include Common
12
15
 
13
16
  attr_reader :client, :http_client
14
17
 
@@ -19,29 +22,44 @@ module Kontena
19
22
  abort('Invalid management certificate') unless File.exists?(File.expand_path(certificate))
20
23
 
21
24
  @client = ::Azure
22
- client.management_certificate = certificate
25
+ client.management_certificate = File.expand_path(certificate)
23
26
  client.subscription_id = subscription_id
24
27
  client.vm_management.initialize_external_logger(Logger.new) # We don't want all the output
25
28
  end
26
29
 
27
30
  def run!(opts)
28
31
  abort('Invalid ssh key') unless File.exists?(File.expand_path(opts[:ssh_key]))
32
+ ssl_cert = nil
29
33
  if opts[:ssl_cert]
30
- abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
34
+ abort('Invalid ssl cert (file not found)') unless File.exists?(File.expand_path(opts[:ssl_cert]))
31
35
  ssl_cert = File.read(File.expand_path(opts[:ssl_cert]))
36
+ else
37
+ spinner "Generating a self-signed SSL certificate" do
38
+ ssl_cert = generate_self_signed_cert
39
+ end
40
+ end
41
+
42
+ coreos_image = nil
43
+ spinner "Finding latest #{'CoreOS stable'.colorize(:cyan)} image" do
44
+ coreos_image = find_coreos_image
32
45
  end
46
+ abort('Cannot find CoreOS image') if coreos_image.nil?
47
+
33
48
  cloud_service_name = generate_cloud_service_name
34
49
  vm_name = cloud_service_name
35
50
  master_url = ''
36
51
  public_ip = nil
37
- spinner "Creating an Azure Virtual Machine #{vm_name.colorize(:cyan)}" do
38
- if opts[:virtual_network].nil?
39
- location = opts[:location].downcase.gsub(' ', '-')
40
- default_network_name = "kontena-#{location}"
52
+ if opts[:virtual_network].nil?
53
+ location = opts[:location].downcase.gsub(' ', '-')
54
+ default_network_name = "kontena-#{location}"
55
+ spinner "Creating a virtual network #{default_network_name.colorize(:cyan)}" do
41
56
  create_virtual_network(default_network_name, opts[:location]) unless virtual_network_exist?(default_network_name)
42
- opts[:virtual_network] = default_network_name
43
- opts[:subnet] = 'subnet-1'
44
57
  end
58
+ opts[:virtual_network] = default_network_name
59
+ opts[:subnet] = 'subnet-1'
60
+ end
61
+
62
+ spinner "Creating an Azure Virtual Machine #{vm_name.colorize(:cyan)} to #{opts[:location].colorize(:cyan)}" do
45
63
 
46
64
  userdata_vars = opts.merge(
47
65
  ssl_cert: ssl_cert,
@@ -52,7 +70,7 @@ module Kontena
52
70
  vm_name: vm_name,
53
71
  vm_user: 'core',
54
72
  location: opts[:location],
55
- image: '2b171e93f07c4903bcad35bda10acf22__CoreOS-Stable-1010.5.0',
73
+ image: coreos_image,
56
74
  custom_data: Base64.encode64(user_data(userdata_vars)),
57
75
  ssh_key: opts[:ssh_key]
58
76
  }
@@ -62,27 +80,20 @@ module Kontena
62
80
  deployment_name: vm_name,
63
81
  virtual_network_name: opts[:virtual_network],
64
82
  subnet_name: opts[:subnet],
65
- tcp_endpoints: '80,443',
83
+ tcp_endpoints: '443',
66
84
  private_key_file: File.expand_path(opts[:ssh_key]),
67
85
  ssh_port: 22,
68
86
  vm_size: opts[:size],
69
87
  }
70
88
 
71
-
72
89
  virtual_machine = client.vm_management.create_virtual_machine(params,options)
73
90
  public_ip = virtual_machine.ipaddress
74
-
75
- if opts[:ssl_cert]
76
- master_url = "https://#{virtual_machine.ipaddress}"
77
- else
78
- master_url = "http://#{virtual_machine.ipaddress}"
79
- end
80
-
91
+ master_url = "https://#{virtual_machine.ipaddress}"
81
92
  end
82
93
  Excon.defaults[:ssl_verify_peer] = false
83
94
  @http_client = Excon.new("#{master_url}", :connect_timeout => 10)
84
95
 
85
- spinner "Waiting for #{vm_name.colorize(:cyan)} to start" do
96
+ spinner "Waiting for #{vm_name.colorize(:cyan)} to start (#{master_url})" do
86
97
  sleep 0.5 until master_running?
87
98
  end
88
99
 
@@ -93,17 +104,18 @@ module Kontena
93
104
 
94
105
  spinner "Kontena Master #{master_version} is now running at #{master_url}".colorize(:green)
95
106
 
96
- {
107
+ data = {
97
108
  name: opts[:name] || cloud_service_name.sub('kontena-master-', ''),
98
109
  public_ip: public_ip,
99
110
  provider: 'azure',
100
111
  version: master_version,
101
112
  code: opts[:initial_admin_code]
102
113
  }
103
- end
114
+ if respond_to?(:certificate_public_key) && !opts[:ssl_cert]
115
+ data[:ssl_certificate] = certificate_public_key(ssl_cert)
116
+ end
104
117
 
105
- def erb(template, vars)
106
- ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
118
+ data
107
119
  end
108
120
 
109
121
  def user_data(vars)
@@ -120,20 +132,6 @@ module Kontena
120
132
  def generate_cloud_service_name
121
133
  "kontena-master-#{generate_name}-#{rand(1..99)}"
122
134
  end
123
-
124
- def cloud_service(name)
125
- client.cloud_service_management.get_cloud_service(name)
126
- end
127
-
128
- def virtual_network_exist?(name)
129
- client.network_management.list_virtual_networks.find{|n| n.name == name}
130
- end
131
-
132
- def create_virtual_network(name, location)
133
- address_space = ['10.0.0.0/20']
134
- options = {subnet: [{:name => 'subnet-1', :ip_address=>'10.0.0.0', :cidr=>23}]}
135
- client.network_management.set_network_configuration(name, location, address_space, options)
136
- end
137
135
  end
138
136
  end
139
137
  end
@@ -23,24 +23,26 @@ module Kontena
23
23
  end
24
24
 
25
25
  def run!(grid, name)
26
- spinner "Terminating Azure Virtual Machine #{name.colorize(:cyan)} " do
27
- vm = client.vm_management.get_virtual_machine(name, cloud_service_name(name, grid['name']))
28
- if vm
29
- out = StringIO.new
30
- $stdout = out # to avoid debug data (https://github.com/Azure/azure-sdk-for-ruby/issues/200)
26
+
27
+ vm = client.vm_management.get_virtual_machine(name, cloud_service_name(name, grid['name']))
28
+ if vm
29
+ spinner "Terminating Azure Virtual Machine #{name.colorize(:cyan)} " do
31
30
  client.vm_management.delete_virtual_machine(name, cloud_service_name(name, grid['name']))
32
- storage_account = client.storage_management.list_storage_accounts.find{|a| a.label == cloud_service_name(name, grid['name'])}
33
- client.storage_management.delete_storage_account(storage_account.name) if storage_account
34
- $stdout = STDOUT
35
- else
36
- abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
37
31
  end
38
- end
32
+ storage_account = client.storage_management.list_storage_accounts.find{|a| a.label == cloud_service_name(name, grid['name'])}
33
+ if storage_account
34
+ spinner "Removing Azure Storage Account #{storage_account.name.colorize(:cyan)} " do
35
+ client.storage_management.delete_storage_account(storage_account.name)
36
+ end
37
+ end
38
+ else
39
+ abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
40
+ end
39
41
 
40
42
  node = api_client.get("grids/#{grid['id']}/nodes")['nodes'].find{|n| n['name'] == name}
41
43
  if node
42
44
  spinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
43
- api_client.delete("grids/#{grid['id']}/nodes/#{name}")
45
+ api_client.delete("nodes/#{grid['id']}/#{name}")
44
46
  end
45
47
  end
46
48
  end
@@ -2,6 +2,7 @@ require 'fileutils'
2
2
  require 'erb'
3
3
  require 'open3'
4
4
  require 'base64'
5
+ require_relative 'common'
5
6
 
6
7
  module Kontena
7
8
  module Machine
@@ -9,6 +10,7 @@ module Kontena
9
10
  class NodeProvisioner
10
11
  include Kontena::Machine::RandomName
11
12
  include Kontena::Cli::ShellSpinner
13
+ include Common
12
14
 
13
15
  attr_reader :client, :api_client
14
16
 
@@ -31,15 +33,23 @@ module Kontena
31
33
  vm_name = opts[:name] || generate_name
32
34
  cloud_service_name = generate_cloud_service_name(vm_name, opts[:grid])
33
35
 
34
- spinner "Creating Azure Virtual Machine #{vm_name.colorize(:cyan)}" do
35
- if opts[:virtual_network].nil?
36
- location = opts[:location].downcase.gsub(' ', '-')
37
- default_network_name = "kontena-#{location}"
36
+ coreos_image = nil
37
+ spinner "Finding latest #{'CoreOS stable'.colorize(:cyan)} image" do
38
+ coreos_image = find_coreos_image
39
+ end
40
+ abort('Cannot find CoreOS image') if coreos_image.nil?
41
+
42
+ if opts[:virtual_network].nil?
43
+ location = opts[:location].downcase.gsub(' ', '-')
44
+ default_network_name = "kontena-#{location}"
45
+ spinner "Creating virtual network #{default_network_name}" do
38
46
  create_virtual_network(default_network_name, opts[:location]) unless virtual_network_exist?(default_network_name)
39
- opts[:virtual_network] = default_network_name
40
- opts[:subnet] = 'subnet-1'
41
47
  end
48
+ opts[:virtual_network] = default_network_name
49
+ opts[:subnet] = 'subnet-1'
50
+ end
42
51
 
52
+ spinner "Creating Azure Virtual Machine #{vm_name.colorize(:cyan)}" do
43
53
  userdata_vars = {
44
54
  version: opts[:version],
45
55
  master_uri: opts[:master_uri],
@@ -50,7 +60,7 @@ module Kontena
50
60
  vm_name: vm_name,
51
61
  vm_user: 'core',
52
62
  location: opts[:location],
53
- image: '2b171e93f07c4903bcad35bda10acf22__CoreOS-Stable-1010.5.0',
63
+ image: coreos_image,
54
64
  custom_data: Base64.encode64(user_data(userdata_vars)),
55
65
  ssh_key: File.expand_path(opts[:ssh_key])
56
66
  }
@@ -59,13 +69,13 @@ module Kontena
59
69
  deployment_name: vm_name,
60
70
  virtual_network_name: opts[:virtual_network],
61
71
  subnet_name: opts[:subnet],
62
- tcp_endpoints: '80',
72
+ tcp_endpoints: '80,443,6783',
73
+ udp_endpoints: '1194,6783,6784',
63
74
  private_key_file: opts[:ssh_key],
64
75
  ssh_port: 22,
65
76
  vm_size: opts[:size],
66
77
  }
67
78
 
68
-
69
79
  client.vm_management.create_virtual_machine(params,options)
70
80
  end
71
81
  spinner "Waiting for node #{vm_name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
@@ -110,20 +120,10 @@ module Kontena
110
120
  client.cloud_service_management.get_cloud_service(name)
111
121
  end
112
122
 
113
- def virtual_network_exist?(name)
114
- client.network_management.list_virtual_networks.find{|n| n.name == name}
115
- end
116
-
117
- def create_virtual_network(name, location)
118
- address_space = ['10.0.0.0/20']
119
- options = {subnet: [{:name => 'subnet-1', :ip_address=>'10.0.0.0', :cidr=>23}]}
120
- client.network_management.set_network_configuration(name, location, address_space, options)
121
- end
122
-
123
123
  def set_labels(node, labels)
124
124
  data = {}
125
125
  data[:labels] = labels
126
- api_client.put("nodes/#{node['id']}", data, {}, {'Kontena-Grid-Token' => node['grid']['token']})
126
+ api_client.put("nodes/#{node['grid']['id']}/#{node['id']}", data)
127
127
  end
128
128
  end
129
129
 
@@ -1,7 +1,7 @@
1
1
  module Kontena
2
2
  module Plugin
3
3
  module Azure
4
- VERSION = "0.2.5"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,53 @@
1
+
2
+ module Kontena::Plugin::Azure::Common
3
+ LOCATIONS = [
4
+ 'East US',
5
+ 'East US 2',
6
+ 'Central US',
7
+ 'North Central US',
8
+ 'South Central US',
9
+ 'West Central US',
10
+ 'West US',
11
+ 'West US 2',
12
+ 'US Gov Virginia',
13
+ 'US Gov Iowa',
14
+ 'Canada East',
15
+ 'Canada Central',
16
+ 'Brazil South',
17
+
18
+ 'North Europe',
19
+ 'West Europe',
20
+ 'Germany Central',
21
+ 'Germany Northeast',
22
+ 'UK West',
23
+ 'UK South',
24
+
25
+ 'Southeast Asia',
26
+ 'East Asia',
27
+ 'Australia East',
28
+ 'Australia Southeast',
29
+ 'Central India',
30
+ 'West India',
31
+ 'South India',
32
+ 'Japan East',
33
+ 'Japan West',
34
+ 'China East',
35
+ 'China North'
36
+ ].freeze
37
+
38
+ SIZES = [
39
+ 'ExtraSmall',
40
+ 'Small',
41
+ 'Medium',
42
+ 'Large',
43
+ 'ExtraLarge'
44
+ ]
45
+
46
+ def locations
47
+ LOCATIONS
48
+ end
49
+
50
+ def sizes
51
+ SIZES
52
+ end
53
+ end
@@ -1,24 +1,26 @@
1
1
  require 'securerandom'
2
+ require_relative '../common'
2
3
 
3
4
  module Kontena::Plugin::Azure::Master
4
5
  class CreateCommand < Kontena::Command
5
6
  include Kontena::Cli::Common
7
+ include Kontena::Plugin::Azure::Common
6
8
 
7
9
  option "--name", "[NAME]", "Set Master name"
8
10
  option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
9
11
  option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
10
- option "--size", "SIZE", "SIZE", default: 'Small'
12
+ option "--size", "SIZE", "Virtual machine size, see https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes", required: true
11
13
  option "--network", "NETWORK", "Virtual Network name"
12
14
  option "--subnet", "SUBNET", "Subnet name"
13
15
  option "--ssh-key", "SSH KEY", "SSH private key file", required: true
14
- option "--location", "LOCATION", "Location", default: 'West Europe'
16
+ option "--location", "LOCATION", "Location", required: true
15
17
  option "--ssl-cert", "SSL CERT", "SSL certificate file"
16
18
  option "--vault-secret", "VAULT_SECRET", "Secret key for Vault"
17
19
  option "--vault-iv", "VAULT_IV", "Initialization vector for Vault"
18
20
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
19
21
 
20
22
  def execute
21
- require 'kontena/machine/azure'
23
+ require_relative '../../../machine/azure'
22
24
  provisioner = provisioner(subscription_id, certificate)
23
25
  provisioner.run!(
24
26
  name: name,
@@ -41,5 +43,27 @@ module Kontena::Plugin::Azure::Master
41
43
  def provisioner(subscription_id, certificate)
42
44
  Kontena::Machine::Azure::MasterProvisioner.new subscription_id, certificate
43
45
  end
46
+
47
+ def default_location
48
+ prompt.select("Choose location: ") do |menu|
49
+ locations.each do |l|
50
+ menu.choice l
51
+ end
52
+ end
53
+ end
54
+
55
+ def default_size
56
+ size = prompt.select("Choose virtual machine size: ") do |menu|
57
+ menu.default 2
58
+ sizes.each do |s|
59
+ menu.choice s
60
+ end
61
+ menu.choice 'Other'
62
+ end
63
+ if size == 'Other'
64
+ size = prompt.ask("Virtual machine size? (see https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes#size-tables)")
65
+ end
66
+ size
67
+ end
44
68
  end
45
69
  end
@@ -1,15 +1,17 @@
1
+ require_relative '../common'
1
2
  module Kontena::Plugin::Azure::Nodes
2
3
  class CreateCommand < Kontena::Command
3
4
  include Kontena::Cli::Common
4
5
  include Kontena::Cli::GridOptions
6
+ include Kontena::Plugin::Azure::Common
5
7
 
6
- option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
7
- option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
8
- option "--size", "SIZE", "SIZE", default: 'Small'
8
+ option "--subscription-id", "ID", "Azure subscription id", required: true
9
+ option "--subscription-cert", "CERT", "Path to Azure management certificate", attribute_name: :certificate, required: true
10
+ option "--size", "SIZE", "Virtual machine size, see https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes", required: true
11
+ option "--ssh-key", "SSH KEY", "SSH private key file", required: true
12
+ option "--location", "LOCATION", "Location", required: true
9
13
  option "--network", "NETWORK", "Virtual Network name"
10
14
  option "--subnet", "SUBNET", "Subnet name"
11
- option "--ssh-key", "SSH KEY", "SSH private key file", required: true
12
- option "--location", "LOCATION", "Location", default: 'West Europe'
13
15
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
14
16
 
15
17
  parameter "[NAME]", "Node name"
@@ -18,7 +20,7 @@ module Kontena::Plugin::Azure::Nodes
18
20
  require_api_url
19
21
  require_current_grid
20
22
 
21
- require 'kontena/machine/azure'
23
+ require_relative '../../../machine/azure'
22
24
  grid = fetch_grid
23
25
  provisioner = provisioner(client(require_token), subscription_id, certificate)
24
26
  provisioner.run!(
@@ -47,5 +49,28 @@ module Kontena::Plugin::Azure::Nodes
47
49
  def fetch_grid
48
50
  client(require_token).get("grids/#{current_grid}")
49
51
  end
52
+
53
+ def default_location
54
+ prompt.select("Choose location: ") do |menu|
55
+ locations.each do |l|
56
+ menu.choice l
57
+ end
58
+ end
59
+ end
60
+
61
+ def default_size
62
+ size = prompt.select("Choose virtual machine size: ") do |menu|
63
+ menu.default 3
64
+ sizes.each do |s|
65
+ menu.choice s
66
+ end
67
+ menu.choice 'Other'
68
+ end
69
+ if size == 'Other'
70
+ size = prompt.ask("Virtual machine size? (see https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-windows-sizes#size-tables)")
71
+ end
72
+
73
+ size
74
+ end
50
75
  end
51
76
  end
@@ -12,7 +12,7 @@ module Kontena::Plugin::Azure::Nodes
12
12
  require_api_url
13
13
  require_current_grid
14
14
 
15
- require 'kontena/machine/azure'
15
+ require_relative '../../../machine/azure'
16
16
 
17
17
  client = ::Azure
18
18
  client.management_certificate = certificate
@@ -6,12 +6,15 @@ module Kontena::Plugin::Azure::Nodes
6
6
  parameter "NAME", "Node name"
7
7
  option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
8
8
  option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
9
+ option "--force", :flag, "Force remove", default: false, attribute_name: :forced
9
10
 
10
11
  def execute
11
12
  require_api_url
12
13
  require_current_grid
13
14
 
14
- require 'kontena/machine/azure'
15
+ confirm_command(name) unless forced?
16
+
17
+ require_relative '../../../machine/azure'
15
18
 
16
19
  grid = fetch_grid
17
20
  destroyer = destroyer(client(require_token), subscription_id, certificate)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-plugin-azure
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-04 00:00:00.000000000 Z
11
+ date: 2017-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kontena-cli
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.7.0
47
+ version: 0.7.7
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.7.0
54
+ version: 0.7.7
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
- description: Kontena Microsoft Azure plugin
83
+ description: Kontena Microsoft Azure (classic) plugin
84
84
  email:
85
85
  - info@kontena.io
86
86
  executables: []
@@ -98,11 +98,13 @@ files:
98
98
  - lib/kontena/machine/azure.rb
99
99
  - lib/kontena/machine/azure/cloudinit.yml
100
100
  - lib/kontena/machine/azure/cloudinit_master.yml
101
+ - lib/kontena/machine/azure/common.rb
101
102
  - lib/kontena/machine/azure/logger.rb
102
103
  - lib/kontena/machine/azure/master_provisioner.rb
103
104
  - lib/kontena/machine/azure/node_destroyer.rb
104
105
  - lib/kontena/machine/azure/node_provisioner.rb
105
106
  - lib/kontena/plugin/azure.rb
107
+ - lib/kontena/plugin/azure/common.rb
106
108
  - lib/kontena/plugin/azure/master/create_command.rb
107
109
  - lib/kontena/plugin/azure/master_command.rb
108
110
  - lib/kontena/plugin/azure/node_command.rb
@@ -134,5 +136,5 @@ rubyforge_project:
134
136
  rubygems_version: 2.4.5
135
137
  signing_key:
136
138
  specification_version: 4
137
- summary: Kontena Azure plugin
139
+ summary: Kontena Azure (classic) plugin
138
140
  test_files: []