kontena-cli 0.14.7 → 0.15.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/VERSION +1 -1
- data/bin/kontena +3 -50
- data/examples/kontena-plugin-hello/.gitignore +9 -0
- data/examples/kontena-plugin-hello/Gemfile +4 -0
- data/examples/kontena-plugin-hello/README.md +3 -0
- data/examples/kontena-plugin-hello/bin/console +14 -0
- data/examples/kontena-plugin-hello/bin/setup +8 -0
- data/examples/kontena-plugin-hello/kontena-plugin-hello.gemspec +22 -0
- data/examples/kontena-plugin-hello/lib/kontena/plugin/hello.rb +7 -0
- data/examples/kontena-plugin-hello/lib/kontena/plugin/hello/world_command.rb +6 -0
- data/examples/kontena-plugin-hello/lib/kontena/plugin/hello_command.rb +9 -0
- data/examples/kontena-plugin-hello/lib/kontena_cli_plugin.rb +5 -0
- data/kontena-cli.gemspec +1 -3
- data/lib/kontena/cli/apps/build_command.rb +3 -0
- data/lib/kontena/cli/apps/common.rb +6 -1
- data/lib/kontena/cli/apps/deploy_command.rb +1 -1
- data/lib/kontena/cli/apps/docker_helper.rb +13 -14
- data/lib/kontena/cli/apps/service_generator.rb +19 -11
- data/lib/kontena/cli/apps/service_generator_v2.rb +1 -0
- data/lib/kontena/cli/apps/yaml/reader.rb +15 -0
- data/lib/kontena/cli/apps/yaml/service_extender.rb +28 -0
- data/lib/kontena/cli/apps/yaml/validations.rb +38 -24
- data/lib/kontena/cli/apps/yaml/validator.rb +7 -7
- data/lib/kontena/cli/apps/yaml/validator_v2.rb +7 -6
- data/lib/kontena/cli/certificate/authorize_command.rb +23 -0
- data/lib/kontena/cli/certificate/get_command.rb +25 -0
- data/lib/kontena/cli/certificate/register_command.rb +19 -0
- data/lib/kontena/cli/certificate_command.rb +14 -0
- data/lib/kontena/cli/containers/containers_helper.rb +22 -0
- data/lib/kontena/cli/containers/exec_command.rb +9 -2
- data/lib/kontena/cli/grids/logs_command.rb +14 -3
- data/lib/kontena/cli/master_command.rb +1 -12
- data/lib/kontena/cli/node_command.rb +0 -16
- data/lib/kontena/cli/plugin_command.rb +15 -0
- data/lib/kontena/cli/plugins/install_command.rb +28 -0
- data/lib/kontena/cli/plugins/list_command.rb +13 -0
- data/lib/kontena/cli/plugins/search_command.rb +29 -0
- data/lib/kontena/cli/plugins/uninstall_command.rb +30 -0
- data/lib/kontena/cli/registry/create_command.rb +1 -1
- data/lib/kontena/cli/services/create_command.rb +16 -0
- data/lib/kontena/cli/services/list_command.rb +17 -3
- data/lib/kontena/cli/services/logs_command.rb +63 -18
- data/lib/kontena/cli/services/services_helper.rb +47 -4
- data/lib/kontena/cli/services/update_command.rb +16 -0
- data/lib/kontena/cli/stack_command.rb +20 -0
- data/lib/kontena/cli/stacks/common.rb +39 -0
- data/lib/kontena/cli/stacks/create_command.rb +27 -0
- data/lib/kontena/cli/stacks/deploy_command.rb +26 -0
- data/lib/kontena/cli/stacks/list_command.rb +38 -0
- data/lib/kontena/cli/stacks/remove_command.rb +26 -0
- data/lib/kontena/cli/stacks/show_command.rb +38 -0
- data/lib/kontena/cli/stacks/update_command.rb +27 -0
- data/lib/kontena/client.rb +11 -4
- data/lib/kontena/command.rb +4 -0
- data/lib/kontena/main_command.rb +61 -0
- data/lib/kontena/plugin_manager.rb +38 -0
- data/lib/kontena/util.rb +17 -0
- data/lib/kontena_cli.rb +6 -0
- data/spec/fixtures/health.yml +26 -0
- data/spec/fixtures/kontena-build.yml +16 -0
- data/spec/fixtures/kontena_build_v2.yaml +26 -0
- data/spec/kontena/cli/app/build_command_spec.rb +13 -1
- data/spec/kontena/cli/app/common_spec.rb +11 -0
- data/spec/kontena/cli/app/deploy_command_spec.rb +1 -1
- data/spec/kontena/cli/app/docker_helper_spec.rb +45 -0
- data/spec/kontena/cli/app/service_generator_spec.rb +52 -1
- data/spec/kontena/cli/app/yaml/service_extender_spec.rb +24 -0
- data/spec/kontena/cli/app/yaml/validator_spec.rb +97 -14
- data/spec/kontena/cli/common_spec.rb +0 -5
- data/spec/kontena/cli/containers/containers_helper_spec.rb +16 -0
- data/spec/kontena/cli/services/services_helper_spec.rb +50 -1
- data/spec/kontena/cli/version_command_spec.rb +1 -1
- data/spec/kontena/client_spec.rb +156 -0
- data/spec/kontena/plugin_manager_spec.rb +22 -0
- data/spec/spec_helper.rb +1 -0
- metadata +54 -125
- data/lib/kontena/cli/master/aws/create_command.rb +0 -48
- data/lib/kontena/cli/master/aws_command.rb +0 -8
- data/lib/kontena/cli/master/azure/create_command.rb +0 -37
- data/lib/kontena/cli/master/azure_command.rb +0 -13
- data/lib/kontena/cli/master/digital_ocean/create_command.rb +0 -38
- data/lib/kontena/cli/master/digital_ocean_command.rb +0 -13
- data/lib/kontena/cli/master/packet/create_command.rb +0 -42
- data/lib/kontena/cli/master/packet_command.rb +0 -14
- data/lib/kontena/cli/master/upcloud/create_command.rb +0 -39
- data/lib/kontena/cli/master/upcloud_command.rb +0 -13
- data/lib/kontena/cli/master/vagrant/create_command.rb +0 -25
- data/lib/kontena/cli/master/vagrant/restart_command.rb +0 -20
- data/lib/kontena/cli/master/vagrant/ssh_command.rb +0 -15
- data/lib/kontena/cli/master/vagrant/start_command.rb +0 -20
- data/lib/kontena/cli/master/vagrant/stop_command.rb +0 -20
- data/lib/kontena/cli/master/vagrant/terminate_command.rb +0 -13
- data/lib/kontena/cli/master/vagrant_command.rb +0 -23
- data/lib/kontena/cli/nodes/aws/create_command.rb +0 -44
- data/lib/kontena/cli/nodes/aws/restart_command.rb +0 -29
- data/lib/kontena/cli/nodes/aws/terminate_command.rb +0 -21
- data/lib/kontena/cli/nodes/aws_command.rb +0 -15
- data/lib/kontena/cli/nodes/azure/create_command.rb +0 -38
- data/lib/kontena/cli/nodes/azure/restart_command.rb +0 -32
- data/lib/kontena/cli/nodes/azure/terminate_command.rb +0 -21
- data/lib/kontena/cli/nodes/azure_command.rb +0 -15
- data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +0 -32
- data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +0 -27
- data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +0 -19
- data/lib/kontena/cli/nodes/digital_ocean_command.rb +0 -15
- data/lib/kontena/cli/nodes/packet/create_command.rb +0 -35
- data/lib/kontena/cli/nodes/packet/restart_command.rb +0 -17
- data/lib/kontena/cli/nodes/packet/terminate_command.rb +0 -20
- data/lib/kontena/cli/nodes/packet_command.rb +0 -15
- data/lib/kontena/cli/nodes/upcloud/create_command.rb +0 -33
- data/lib/kontena/cli/nodes/upcloud/restart_command.rb +0 -20
- data/lib/kontena/cli/nodes/upcloud/terminate_command.rb +0 -20
- data/lib/kontena/cli/nodes/upcloud_command.rb +0 -15
- data/lib/kontena/cli/nodes/vagrant/create_command.rb +0 -27
- data/lib/kontena/cli/nodes/vagrant/restart_command.rb +0 -26
- data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +0 -21
- data/lib/kontena/cli/nodes/vagrant/start_command.rb +0 -26
- data/lib/kontena/cli/nodes/vagrant/stop_command.rb +0 -26
- data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +0 -17
- data/lib/kontena/cli/nodes/vagrant_command.rb +0 -21
- data/lib/kontena/machine/aws.rb +0 -13
- data/lib/kontena/machine/aws/cloudinit.yml +0 -71
- data/lib/kontena/machine/aws/cloudinit_master.yml +0 -118
- data/lib/kontena/machine/aws/common.rb +0 -58
- data/lib/kontena/machine/aws/master_provisioner.rb +0 -187
- data/lib/kontena/machine/aws/node_destroyer.rb +0 -51
- data/lib/kontena/machine/aws/node_provisioner.rb +0 -204
- data/lib/kontena/machine/azure.rb +0 -13
- data/lib/kontena/machine/azure/cloudinit.yml +0 -64
- data/lib/kontena/machine/azure/cloudinit_master.yml +0 -106
- data/lib/kontena/machine/azure/logger.rb +0 -27
- data/lib/kontena/machine/azure/master_provisioner.rb +0 -128
- data/lib/kontena/machine/azure/node_destroyer.rb +0 -53
- data/lib/kontena/machine/azure/node_provisioner.rb +0 -132
- data/lib/kontena/machine/digital_ocean.rb +0 -13
- data/lib/kontena/machine/digital_ocean/cloudinit.yml +0 -64
- data/lib/kontena/machine/digital_ocean/cloudinit_master.yml +0 -118
- data/lib/kontena/machine/digital_ocean/master_provisioner.rb +0 -99
- data/lib/kontena/machine/digital_ocean/node_destroyer.rb +0 -40
- data/lib/kontena/machine/digital_ocean/node_provisioner.rb +0 -88
- data/lib/kontena/machine/packet.rb +0 -17
- data/lib/kontena/machine/packet/cloudinit.yml +0 -66
- data/lib/kontena/machine/packet/cloudinit_master.yml +0 -118
- data/lib/kontena/machine/packet/master_provisioner.rb +0 -93
- data/lib/kontena/machine/packet/node_destroyer.rb +0 -42
- data/lib/kontena/machine/packet/node_provisioner.rb +0 -77
- data/lib/kontena/machine/packet/node_restarter.rb +0 -41
- data/lib/kontena/machine/packet/packet_common.rb +0 -89
- data/lib/kontena/machine/upcloud.rb +0 -9
- data/lib/kontena/machine/upcloud/cloudinit.yml +0 -64
- data/lib/kontena/machine/upcloud/cloudinit_master.yml +0 -118
- data/lib/kontena/machine/upcloud/master_provisioner.rb +0 -138
- data/lib/kontena/machine/upcloud/node_destroyer.rb +0 -85
- data/lib/kontena/machine/upcloud/node_provisioner.rb +0 -121
- data/lib/kontena/machine/upcloud/node_restarter.rb +0 -49
- data/lib/kontena/machine/upcloud/upcloud_common.rb +0 -74
- data/lib/kontena/machine/vagrant.rb +0 -12
- data/lib/kontena/machine/vagrant/Vagrantfile.master.rb.erb +0 -104
- data/lib/kontena/machine/vagrant/Vagrantfile.node.rb.erb +0 -32
- data/lib/kontena/machine/vagrant/cloudinit.yml +0 -73
- data/lib/kontena/machine/vagrant/master_destroyer.rb +0 -37
- data/lib/kontena/machine/vagrant/master_provisioner.rb +0 -79
- data/lib/kontena/machine/vagrant/node_destroyer.rb +0 -40
- data/lib/kontena/machine/vagrant/node_provisioner.rb +0 -68
@@ -1,128 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'erb'
|
3
|
-
require 'open3'
|
4
|
-
require 'shell-spinner'
|
5
|
-
|
6
|
-
module Kontena
|
7
|
-
module Machine
|
8
|
-
module Azure
|
9
|
-
class MasterProvisioner
|
10
|
-
include RandomName
|
11
|
-
|
12
|
-
attr_reader :client, :http_client
|
13
|
-
|
14
|
-
# @param [String] subscription_id Azure subscription id
|
15
|
-
# @param [String] certificate Path to Azure management certificate
|
16
|
-
def initialize(subscription_id, certificate)
|
17
|
-
|
18
|
-
abort('Invalid management certificate') unless File.exists?(File.expand_path(certificate))
|
19
|
-
|
20
|
-
@client = ::Azure
|
21
|
-
client.management_certificate = certificate
|
22
|
-
client.subscription_id = subscription_id
|
23
|
-
client.vm_management.initialize_external_logger(Logger.new) # We don't want all the output
|
24
|
-
end
|
25
|
-
|
26
|
-
def run!(opts)
|
27
|
-
abort('Invalid ssh key') unless File.exists?(File.expand_path(opts[:ssh_key]))
|
28
|
-
if opts[:ssl_cert]
|
29
|
-
abort('Invalid ssl cert') unless File.exists?(File.expand_path(opts[:ssl_cert]))
|
30
|
-
ssl_cert = File.read(File.expand_path(opts[:ssl_cert]))
|
31
|
-
end
|
32
|
-
cloud_service_name = generate_cloud_service_name
|
33
|
-
vm_name = cloud_service_name
|
34
|
-
master_url = ''
|
35
|
-
ShellSpinner "Creating Azure Virtual Machine #{vm_name.colorize(:cyan)}" do
|
36
|
-
if opts[:virtual_network].nil?
|
37
|
-
location = opts[:location].downcase.gsub(' ', '-')
|
38
|
-
default_network_name = "kontena-#{location}"
|
39
|
-
create_virtual_network(default_network_name, opts[:location]) unless virtual_network_exist?(default_network_name)
|
40
|
-
opts[:virtual_network] = default_network_name
|
41
|
-
opts[:subnet] = 'subnet-1'
|
42
|
-
end
|
43
|
-
|
44
|
-
userdata_vars = {
|
45
|
-
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
|
-
}
|
51
|
-
|
52
|
-
params = {
|
53
|
-
vm_name: vm_name,
|
54
|
-
vm_user: 'core',
|
55
|
-
location: opts[:location],
|
56
|
-
image: '2b171e93f07c4903bcad35bda10acf22__CoreOS-Stable-1010.5.0',
|
57
|
-
custom_data: Base64.encode64(user_data(userdata_vars)),
|
58
|
-
ssh_key: opts[:ssh_key]
|
59
|
-
}
|
60
|
-
|
61
|
-
options = {
|
62
|
-
cloud_service_name: cloud_service_name,
|
63
|
-
deployment_name: vm_name,
|
64
|
-
virtual_network_name: opts[:virtual_network],
|
65
|
-
subnet_name: opts[:subnet],
|
66
|
-
tcp_endpoints: '80,443',
|
67
|
-
private_key_file: File.expand_path(opts[:ssh_key]),
|
68
|
-
ssh_port: 22,
|
69
|
-
vm_size: opts[:size],
|
70
|
-
}
|
71
|
-
|
72
|
-
|
73
|
-
virtual_machine = client.vm_management.create_virtual_machine(params,options)
|
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
|
-
|
81
|
-
end
|
82
|
-
Excon.defaults[:ssl_verify_peer] = false
|
83
|
-
@http_client = Excon.new("#{master_url}", :connect_timeout => 10)
|
84
|
-
|
85
|
-
ShellSpinner "Waiting for #{vm_name.colorize(:cyan)} to start" do
|
86
|
-
sleep 5 until master_running?
|
87
|
-
end
|
88
|
-
|
89
|
-
puts "Kontena Master is now running at #{master_url}"
|
90
|
-
puts "Use #{"kontena login #{master_url}".colorize(:light_black)} to complete Kontena Master setup"
|
91
|
-
end
|
92
|
-
|
93
|
-
def erb(template, vars)
|
94
|
-
ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
|
95
|
-
end
|
96
|
-
|
97
|
-
def user_data(vars)
|
98
|
-
cloudinit_template = File.join(__dir__ , '/cloudinit_master.yml')
|
99
|
-
erb(File.read(cloudinit_template), vars)
|
100
|
-
end
|
101
|
-
|
102
|
-
def master_running?
|
103
|
-
http_client.get(path: '/').status == 200
|
104
|
-
rescue
|
105
|
-
false
|
106
|
-
end
|
107
|
-
|
108
|
-
def generate_cloud_service_name
|
109
|
-
"kontena-master-#{generate_name}-#{rand(1..99)}"
|
110
|
-
end
|
111
|
-
|
112
|
-
def cloud_service(name)
|
113
|
-
client.cloud_service_management.get_cloud_service(name)
|
114
|
-
end
|
115
|
-
|
116
|
-
def virtual_network_exist?(name)
|
117
|
-
client.network_management.list_virtual_networks.find{|n| n.name == name}
|
118
|
-
end
|
119
|
-
|
120
|
-
def create_virtual_network(name, location)
|
121
|
-
address_space = ['10.0.0.0/20']
|
122
|
-
options = {subnet: [{:name => 'subnet-1', :ip_address=>'10.0.0.0', :cidr=>23}]}
|
123
|
-
client.network_management.set_network_configuration(name, location, address_space, options)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
require 'azure/virtual_machine_image_management/virtual_machine_image_management_service'
|
3
|
-
|
4
|
-
module Kontena
|
5
|
-
module Machine
|
6
|
-
module Azure
|
7
|
-
class NodeDestroyer
|
8
|
-
|
9
|
-
attr_reader :client, :api_client
|
10
|
-
|
11
|
-
# @param [Kontena::Client] api_client Kontena api client
|
12
|
-
# @param [String] subscription_id Azure subscription id
|
13
|
-
# @param [String] certificate Path to Azure management certificate
|
14
|
-
def initialize(api_client, subscription_id, certificate)
|
15
|
-
@api_client = api_client
|
16
|
-
abort('Invalid management certificate') unless File.exists?(File.expand_path(certificate))
|
17
|
-
|
18
|
-
@client = ::Azure
|
19
|
-
client.management_certificate = certificate
|
20
|
-
client.subscription_id = subscription_id
|
21
|
-
client.vm_management.initialize_external_logger(Logger.new) # We don't want all the output
|
22
|
-
end
|
23
|
-
|
24
|
-
def run!(grid, name)
|
25
|
-
ShellSpinner "Terminating Azure Virtual Machine #{name.colorize(:cyan)} " do
|
26
|
-
vm = client.vm_management.get_virtual_machine(name, cloud_service_name(name, grid['name']))
|
27
|
-
if vm
|
28
|
-
out = StringIO.new
|
29
|
-
$stdout = out # to avoid debug data (https://github.com/Azure/azure-sdk-for-ruby/issues/200)
|
30
|
-
client.vm_management.delete_virtual_machine(name, cloud_service_name(name, grid['name']))
|
31
|
-
storage_account = client.storage_management.list_storage_accounts.find{|a| a.label == cloud_service_name(name, grid['name'])}
|
32
|
-
client.storage_management.delete_storage_account(storage_account.name) if storage_account
|
33
|
-
$stdout = STDOUT
|
34
|
-
else
|
35
|
-
abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
node = api_client.get("grids/#{grid['id']}/nodes")['nodes'].find{|n| n['name'] == name}
|
40
|
-
if node
|
41
|
-
ShellSpinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
|
42
|
-
api_client.delete("grids/#{grid['id']}/nodes/#{name}")
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def cloud_service_name(vm_name, grid)
|
48
|
-
"kontena-#{grid}-#{vm_name}"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,132 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
require 'erb'
|
3
|
-
require 'open3'
|
4
|
-
require 'base64'
|
5
|
-
require 'shell-spinner'
|
6
|
-
|
7
|
-
module Kontena
|
8
|
-
module Machine
|
9
|
-
module Azure
|
10
|
-
class NodeProvisioner
|
11
|
-
include RandomName
|
12
|
-
|
13
|
-
attr_reader :client, :api_client
|
14
|
-
|
15
|
-
# @param [Kontena::Client] api_client Kontena api client
|
16
|
-
# @param [String] subscription_id Azure subscription id
|
17
|
-
# @param [String] certificate Path to Azure management certificate
|
18
|
-
def initialize(api_client, subscription_id, certificate)
|
19
|
-
@api_client = api_client
|
20
|
-
abort('Invalid management certificate') unless File.exists?(File.expand_path(certificate))
|
21
|
-
|
22
|
-
@client = ::Azure
|
23
|
-
client.management_certificate = File.expand_path(certificate)
|
24
|
-
client.subscription_id = subscription_id
|
25
|
-
client.vm_management.initialize_external_logger(Logger.new) # We don't want all the output
|
26
|
-
end
|
27
|
-
|
28
|
-
def run!(opts)
|
29
|
-
abort('Invalid ssh key') unless File.exists?(File.expand_path(opts[:ssh_key]))
|
30
|
-
node = nil
|
31
|
-
vm_name = opts[:name] || generate_name
|
32
|
-
cloud_service_name = generate_cloud_service_name(vm_name, opts[:grid])
|
33
|
-
|
34
|
-
ShellSpinner "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}"
|
38
|
-
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
|
-
end
|
42
|
-
|
43
|
-
userdata_vars = {
|
44
|
-
version: opts[:version],
|
45
|
-
master_uri: opts[:master_uri],
|
46
|
-
grid_token: opts[:grid_token],
|
47
|
-
}
|
48
|
-
|
49
|
-
params = {
|
50
|
-
vm_name: vm_name,
|
51
|
-
vm_user: 'core',
|
52
|
-
location: opts[:location],
|
53
|
-
image: '2b171e93f07c4903bcad35bda10acf22__CoreOS-Stable-1010.5.0',
|
54
|
-
custom_data: Base64.encode64(user_data(userdata_vars)),
|
55
|
-
ssh_key: File.expand_path(opts[:ssh_key])
|
56
|
-
}
|
57
|
-
options = {
|
58
|
-
cloud_service_name: cloud_service_name,
|
59
|
-
deployment_name: vm_name,
|
60
|
-
virtual_network_name: opts[:virtual_network],
|
61
|
-
subnet_name: opts[:subnet],
|
62
|
-
tcp_endpoints: '80',
|
63
|
-
private_key_file: opts[:ssh_key],
|
64
|
-
ssh_port: 22,
|
65
|
-
vm_size: opts[:size],
|
66
|
-
}
|
67
|
-
|
68
|
-
|
69
|
-
client.vm_management.create_virtual_machine(params,options)
|
70
|
-
end
|
71
|
-
ShellSpinner "Waiting for node #{vm_name.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} " do
|
72
|
-
sleep 2 until node = vm_exists_in_grid?(opts[:grid], vm_name)
|
73
|
-
end
|
74
|
-
if node
|
75
|
-
labels = [
|
76
|
-
"region=#{cloud_service(cloud_service_name).location}",
|
77
|
-
"az=#{cloud_service(cloud_service_name).location}",
|
78
|
-
"provider=azure"
|
79
|
-
]
|
80
|
-
set_labels(node, labels)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def user_data(vars)
|
85
|
-
cloudinit_template = File.join(__dir__ , '/cloudinit.yml')
|
86
|
-
erb(File.read(cloudinit_template), vars)
|
87
|
-
end
|
88
|
-
|
89
|
-
def generate_name
|
90
|
-
"#{super}-#{rand(1..99)}"
|
91
|
-
end
|
92
|
-
|
93
|
-
def generate_cloud_service_name(name, grid)
|
94
|
-
"kontena-#{grid}-#{name}"
|
95
|
-
end
|
96
|
-
|
97
|
-
def vm_exists_in_grid?(grid, name)
|
98
|
-
api_client.get("grids/#{grid}/nodes")['nodes'].find{|n| n['name'] == name}
|
99
|
-
end
|
100
|
-
|
101
|
-
def erb(template, vars)
|
102
|
-
ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
|
103
|
-
end
|
104
|
-
|
105
|
-
def cloud_service_exist?(name)
|
106
|
-
cloud_service(name)
|
107
|
-
end
|
108
|
-
|
109
|
-
def cloud_service(name)
|
110
|
-
client.cloud_service_management.get_cloud_service(name)
|
111
|
-
end
|
112
|
-
|
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
|
-
def set_labels(node, labels)
|
124
|
-
data = {}
|
125
|
-
data[:labels] = labels
|
126
|
-
api_client.put("nodes/#{node['id']}", data, {}, {'Kontena-Grid-Token' => node['grid']['token']})
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require "droplet_kit"
|
3
|
-
rescue LoadError
|
4
|
-
puts "It seems that you don't have Digital Ocean API installed."
|
5
|
-
puts "Install it using: gem install droplet_kit"
|
6
|
-
exit 1
|
7
|
-
end
|
8
|
-
|
9
|
-
require_relative 'random_name'
|
10
|
-
require_relative 'cert_helper'
|
11
|
-
require_relative 'digital_ocean/node_provisioner'
|
12
|
-
require_relative 'digital_ocean/node_destroyer'
|
13
|
-
require_relative 'digital_ocean/master_provisioner'
|
@@ -1,64 +0,0 @@
|
|
1
|
-
#cloud-config
|
2
|
-
write_files:
|
3
|
-
- path: /etc/kontena-agent.env
|
4
|
-
permissions: 0600
|
5
|
-
owner: root
|
6
|
-
content: |
|
7
|
-
KONTENA_URI="<%= master_uri %>"
|
8
|
-
KONTENA_TOKEN="<%= grid_token %>"
|
9
|
-
KONTENA_PEER_INTERFACE=eth1
|
10
|
-
KONTENA_VERSION=<%= version %>
|
11
|
-
- path: /etc/systemd/system/docker.service.d/50-kontena.conf
|
12
|
-
content: |
|
13
|
-
[Service]
|
14
|
-
Environment='DOCKER_OPTS=--insecure-registry="10.81.0.0/19" --bip="172.17.43.1/16"'
|
15
|
-
- path: /etc/sysctl.d/99-inotify.conf
|
16
|
-
owner: root
|
17
|
-
permissions: 0644
|
18
|
-
content: |
|
19
|
-
fs.inotify.max_user_instances = 8192
|
20
|
-
- path: /etc/resolv.conf
|
21
|
-
permissions: 0644
|
22
|
-
owner: root
|
23
|
-
content: |
|
24
|
-
nameserver 172.17.43.1
|
25
|
-
nameserver 8.8.8.8
|
26
|
-
nameserver 8.8.4.4
|
27
|
-
coreos:
|
28
|
-
units:
|
29
|
-
- name: 10-weave.network
|
30
|
-
runtime: false
|
31
|
-
content: |
|
32
|
-
[Match]
|
33
|
-
Type=bridge
|
34
|
-
Name=weave*
|
35
|
-
|
36
|
-
[Network]
|
37
|
-
- name: kontena-agent.service
|
38
|
-
command: start
|
39
|
-
enable: true
|
40
|
-
content: |
|
41
|
-
[Unit]
|
42
|
-
Description=kontena-agent
|
43
|
-
After=network-online.target
|
44
|
-
After=docker.service
|
45
|
-
Description=Kontena Agent
|
46
|
-
Documentation=http://www.kontena.io/
|
47
|
-
Requires=network-online.target
|
48
|
-
Requires=docker.service
|
49
|
-
|
50
|
-
[Service]
|
51
|
-
Restart=always
|
52
|
-
RestartSec=5
|
53
|
-
EnvironmentFile=/etc/kontena-agent.env
|
54
|
-
ExecStartPre=-/usr/bin/docker stop kontena-agent
|
55
|
-
ExecStartPre=-/usr/bin/docker rm kontena-agent
|
56
|
-
ExecStartPre=/usr/bin/docker pull kontena/agent:${KONTENA_VERSION}
|
57
|
-
ExecStart=/usr/bin/docker run --name kontena-agent \
|
58
|
-
-e KONTENA_URI=${KONTENA_URI} \
|
59
|
-
-e KONTENA_TOKEN=${KONTENA_TOKEN} \
|
60
|
-
-e KONTENA_PEER_INTERFACE=${KONTENA_PEER_INTERFACE} \
|
61
|
-
-v=/var/run/docker.sock:/var/run/docker.sock \
|
62
|
-
-v=/etc/kontena-agent.env:/etc/kontena.env \
|
63
|
-
--net=host \
|
64
|
-
kontena/agent:${KONTENA_VERSION}
|
@@ -1,118 +0,0 @@
|
|
1
|
-
#cloud-config
|
2
|
-
write_files:
|
3
|
-
- path: /etc/kontena-server.env
|
4
|
-
permissions: 0600
|
5
|
-
owner: root
|
6
|
-
content: |
|
7
|
-
KONTENA_VERSION=<%= version %>
|
8
|
-
KONTENA_VAULT_KEY=<%= vault_secret %>
|
9
|
-
KONTENA_VAULT_IV=<%= vault_iv %>
|
10
|
-
<% if ssl_cert %>SSL_CERT="/etc/kontena-server.pem"
|
11
|
-
|
12
|
-
- path: /etc/kontena-server.pem
|
13
|
-
permissions: 0600
|
14
|
-
owner: root
|
15
|
-
content: | <% ssl_cert.split(/\n/).each do |row| %>
|
16
|
-
<%= row %><% end %><% end %>
|
17
|
-
- path: /opt/bin/kontena-haproxy.sh
|
18
|
-
permissions: 0755
|
19
|
-
owner: root
|
20
|
-
content: |
|
21
|
-
#!/bin/sh
|
22
|
-
if [ -n "$SSL_CERT" ]; then
|
23
|
-
SSL_CERT=$(awk 1 ORS='\\n' $SSL_CERT)
|
24
|
-
else
|
25
|
-
SSL_CERT="**None**"
|
26
|
-
fi
|
27
|
-
/usr/bin/docker run --name=kontena-server-haproxy \
|
28
|
-
--link kontena-server-api:kontena-server-api \
|
29
|
-
-e SSL_CERT="$SSL_CERT" \
|
30
|
-
-p 80:80 -p 443:443 kontena/haproxy:latest
|
31
|
-
coreos:
|
32
|
-
units:
|
33
|
-
<% unless mongodb_uri -%>
|
34
|
-
- name: kontena-server-mongo.service
|
35
|
-
command: start
|
36
|
-
enable: true
|
37
|
-
content: |
|
38
|
-
[Unit]
|
39
|
-
Description=kontena-server-mongo
|
40
|
-
After=network-online.target
|
41
|
-
After=docker.service
|
42
|
-
Description=Kontena Server MongoDB
|
43
|
-
Documentation=http://www.mongodb.org/
|
44
|
-
Requires=network-online.target
|
45
|
-
Requires=docker.service
|
46
|
-
|
47
|
-
[Service]
|
48
|
-
Restart=always
|
49
|
-
RestartSec=5
|
50
|
-
ExecStartPre=/usr/bin/docker pull mongo:3.0
|
51
|
-
ExecStartPre=-/usr/bin/docker create --name=kontena-server-mongo-data mongo:3.0
|
52
|
-
ExecStartPre=-/usr/bin/docker stop kontena-server-mongo
|
53
|
-
ExecStartPre=-/usr/bin/docker rm kontena-server-mongo
|
54
|
-
ExecStart=/usr/bin/docker run --name=kontena-server-mongo \
|
55
|
-
--volumes-from=kontena-server-mongo-data \
|
56
|
-
mongo:3.0 mongod --smallfiles
|
57
|
-
<% end -%>
|
58
|
-
- name: kontena-server-api.service
|
59
|
-
command: start
|
60
|
-
enable: true
|
61
|
-
content: |
|
62
|
-
[Unit]
|
63
|
-
Description=kontena-server-api
|
64
|
-
After=network-online.target
|
65
|
-
After=docker.service
|
66
|
-
After=kontena-server-mongo.service
|
67
|
-
Description=Kontena Master
|
68
|
-
Documentation=http://www.kontena.io/
|
69
|
-
Before=kontena-server-haproxy.service
|
70
|
-
Wants=kontena-server-haproxy.service
|
71
|
-
Requires=network-online.target
|
72
|
-
Requires=docker.service
|
73
|
-
<% unless mongodb_uri -%>
|
74
|
-
Requires=kontena-server-mongo.service
|
75
|
-
<% end %>
|
76
|
-
|
77
|
-
[Service]
|
78
|
-
Restart=always
|
79
|
-
RestartSec=5
|
80
|
-
EnvironmentFile=/etc/kontena-server.env
|
81
|
-
ExecStartPre=-/usr/bin/docker stop kontena-server-api
|
82
|
-
ExecStartPre=-/usr/bin/docker rm kontena-server-api
|
83
|
-
ExecStartPre=/usr/bin/docker pull kontena/server:${KONTENA_VERSION}
|
84
|
-
ExecStart=/usr/bin/docker run --name kontena-server-api \
|
85
|
-
<% if mongodb_uri -%>
|
86
|
-
-e MONGODB_URI=<%= mongodb_uri %> \
|
87
|
-
<% else -%>
|
88
|
-
--link kontena-server-mongo:mongodb \
|
89
|
-
-e MONGODB_URI=mongodb://mongodb:27017/kontena_server \
|
90
|
-
<% end -%>
|
91
|
-
<% if auth_server %>
|
92
|
-
-e AUTH_API_URL=<%= auth_server %> \
|
93
|
-
<% end -%>
|
94
|
-
-e VAULT_KEY=${KONTENA_VAULT_KEY} -e VAULT_IV=${KONTENA_VAULT_IV} \
|
95
|
-
kontena/server:${KONTENA_VERSION}
|
96
|
-
|
97
|
-
- name: kontena-server-haproxy.service
|
98
|
-
command: start
|
99
|
-
enable: true
|
100
|
-
content: |
|
101
|
-
[Unit]
|
102
|
-
Description=kontena-server-haproxy
|
103
|
-
After=network-online.target
|
104
|
-
After=docker.service
|
105
|
-
Description=Kontena Server HAProxy
|
106
|
-
Documentation=http://www.kontena.io/
|
107
|
-
Requires=network-online.target
|
108
|
-
Requires=docker.service
|
109
|
-
Requires=kontena-server-api.service
|
110
|
-
|
111
|
-
[Service]
|
112
|
-
Restart=always
|
113
|
-
RestartSec=5
|
114
|
-
EnvironmentFile=/etc/kontena-server.env
|
115
|
-
ExecStartPre=-/usr/bin/docker stop kontena-server-haproxy
|
116
|
-
ExecStartPre=-/usr/bin/docker rm kontena-server-haproxy
|
117
|
-
ExecStartPre=/usr/bin/docker pull kontena/haproxy:latest
|
118
|
-
ExecStart=/opt/bin/kontena-haproxy.sh
|