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,42 +0,0 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
|
-
module Kontena
|
4
|
-
module Machine
|
5
|
-
module Packet
|
6
|
-
class NodeDestroyer
|
7
|
-
include RandomName
|
8
|
-
include PacketCommon
|
9
|
-
|
10
|
-
attr_reader :client, :api_client
|
11
|
-
|
12
|
-
# @param [Kontena::Client] api_client Kontena api client
|
13
|
-
# @param [String] token Packet api token
|
14
|
-
def initialize(api_client, token)
|
15
|
-
@api_client = api_client
|
16
|
-
@client = login(token)
|
17
|
-
end
|
18
|
-
|
19
|
-
def run!(grid, project_id, name)
|
20
|
-
device = client.list_devices(project_id).find{|d| d.hostname == name}
|
21
|
-
abort("Device #{name.colorize(:cyan)} not found in Packet") unless device
|
22
|
-
|
23
|
-
ShellSpinner "Terminating Packet device #{name.colorize(:cyan)} " do
|
24
|
-
begin
|
25
|
-
response = client.delete_device(device.id)
|
26
|
-
raise unless response.success?
|
27
|
-
rescue
|
28
|
-
abort "Cannot delete device #{name.colorize(:cyan)} in Packet"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
node = api_client.get("grids/#{grid['id']}/nodes")['nodes'].find{|n| n['name'] == name}
|
33
|
-
if node
|
34
|
-
ShellSpinner "Removing node #{name.colorize(:cyan)} from grid #{grid['name'].colorize(:cyan)} " do
|
35
|
-
api_client.delete("grids/#{grid['id']}/nodes/#{name}")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
|
-
module Kontena
|
4
|
-
module Machine
|
5
|
-
module Packet
|
6
|
-
class NodeProvisioner
|
7
|
-
include RandomName
|
8
|
-
include PacketCommon
|
9
|
-
|
10
|
-
attr_reader :client, :api_client
|
11
|
-
|
12
|
-
# @param [Kontena::Client] api_client Kontena api client
|
13
|
-
# @param [String] token Digital Ocean token
|
14
|
-
def initialize(api_client, token)
|
15
|
-
@api_client = api_client
|
16
|
-
@client = login(token)
|
17
|
-
end
|
18
|
-
|
19
|
-
def run!(opts)
|
20
|
-
abort('Project does not exist in Packet') unless project = find_project(opts[:project])
|
21
|
-
abort('Facility does not exist in Packet') unless facility = find_facility(opts[:facility])
|
22
|
-
abort('Operating system coreos_stable does not exist in Packet') unless os = find_os('coreos_stable')
|
23
|
-
abort('Device type does not exist in Packet') unless plan = find_plan(opts[:plan])
|
24
|
-
|
25
|
-
check_or_create_ssh_key(opts[:ssh_key]) if opts[:ssh_key]
|
26
|
-
|
27
|
-
userdata_vars = {
|
28
|
-
version: opts[:version],
|
29
|
-
master_uri: opts[:master_uri],
|
30
|
-
grid_token: opts[:grid_token],
|
31
|
-
}
|
32
|
-
|
33
|
-
device = project.new_device(
|
34
|
-
hostname: generate_name,
|
35
|
-
facility: facility.to_hash,
|
36
|
-
operating_system: os.to_hash,
|
37
|
-
plan: plan.to_hash,
|
38
|
-
billing_cycle: opts[:billing],
|
39
|
-
locked: false,
|
40
|
-
userdata: user_data(userdata_vars, 'cloudinit.yml')
|
41
|
-
)
|
42
|
-
|
43
|
-
ShellSpinner "Creating Packet device #{device.hostname.colorize(:cyan)} " do
|
44
|
-
api_retry "Packet API reported an error, please try again" do
|
45
|
-
response = client.create_device(device)
|
46
|
-
raise response.body unless response.success?
|
47
|
-
end
|
48
|
-
|
49
|
-
until device && [:active, :provisioning, :powering_on].include?(device.state)
|
50
|
-
device = find_device(project.id, device.hostname) rescue nil
|
51
|
-
sleep 5
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
node = nil
|
56
|
-
ShellSpinner "Waiting for node #{device.hostname.colorize(:cyan)} join to grid #{opts[:grid].colorize(:cyan)} (estimate 4 minutes) " do
|
57
|
-
sleep 2 until node = device_exists_in_grid?(opts[:grid], device)
|
58
|
-
end
|
59
|
-
set_labels(node, ["region=#{opts[:facility]}", "provider=packet"])
|
60
|
-
end
|
61
|
-
|
62
|
-
def generate_name
|
63
|
-
"#{super}-#{rand(1..99)}"
|
64
|
-
end
|
65
|
-
|
66
|
-
def device_exists_in_grid?(grid, device)
|
67
|
-
api_client.get("grids/#{grid}/nodes")['nodes'].find{|n| n['name'] == device.hostname}
|
68
|
-
end
|
69
|
-
|
70
|
-
def set_labels(node, labels)
|
71
|
-
data = {labels: labels}
|
72
|
-
api_client.put("nodes/#{node['id']}", data, {}, {'Kontena-Grid-Token' => node['grid']['token']})
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'shell-spinner'
|
2
|
-
|
3
|
-
module Kontena
|
4
|
-
module Machine
|
5
|
-
module Packet
|
6
|
-
class NodeRestarter
|
7
|
-
include RandomName
|
8
|
-
include PacketCommon
|
9
|
-
|
10
|
-
attr_reader :client
|
11
|
-
|
12
|
-
# @param [String] token Packet api token
|
13
|
-
def initialize(token)
|
14
|
-
@client = login(token)
|
15
|
-
end
|
16
|
-
|
17
|
-
# @param [String] project_id Packet project id
|
18
|
-
# @param [String] token Node hostname
|
19
|
-
def run!(project_id, name)
|
20
|
-
device = client.list_devices(project_id).find{|d| d.hostname == name}
|
21
|
-
abort("Device #{name.colorize(:cyan)} not found in Packet") unless device
|
22
|
-
abort("Your version of 'packethost' gem does not support rebooting servers") unless client.respond_to?(:reboot_device)
|
23
|
-
|
24
|
-
ShellSpinner "Restarting Packet device #{device.hostname.colorize(:cyan)} " do
|
25
|
-
begin
|
26
|
-
response = client.reboot_device(device)
|
27
|
-
raise unless response.success?
|
28
|
-
rescue
|
29
|
-
abort "Cannot delete device #{name.colorize(:cyan)} in Packet"
|
30
|
-
end
|
31
|
-
sleep 5
|
32
|
-
until device && device.state == :active
|
33
|
-
device = find_device(project.id, device.hostname) rescue nil
|
34
|
-
sleep 5
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
|
3
|
-
module Kontena
|
4
|
-
module Machine
|
5
|
-
module Packet
|
6
|
-
module PacketCommon
|
7
|
-
# @param [String] token Packet token
|
8
|
-
def login(token)
|
9
|
-
::Packet::Client.new(token)
|
10
|
-
end
|
11
|
-
|
12
|
-
def create_ssh_key(ssh_key)
|
13
|
-
client.create_ssh_key(ssh_key_label(ssh_key))
|
14
|
-
end
|
15
|
-
|
16
|
-
def ssh_key_exist?(ssh_key)
|
17
|
-
client.list_ssh_keys.any?{|key| key.key == ssh_key}
|
18
|
-
end
|
19
|
-
|
20
|
-
def ssh_key_label(ssh_key)
|
21
|
-
label = ssh_key[/^ssh.+?\s+\S+\s+(.*)$/, 1].to_s.strip
|
22
|
-
label.empty? ? "kontena-ssh-key-#{rand(1..9)}" : label
|
23
|
-
end
|
24
|
-
|
25
|
-
# @param [String] keyfile_path Path to ssh keyfile
|
26
|
-
def check_or_create_ssh_key(keyfile_path)
|
27
|
-
abort('Ssh key file not found') unless File.exist?(keyfile_path)
|
28
|
-
abort('Ssh key file not readable') unless File.readable?(keyfile_path)
|
29
|
-
ssh_key = File.read(keyfile_path).strip
|
30
|
-
create_ssh_key(ssh_key) unless ssh_key_exist?(ssh_key)
|
31
|
-
end
|
32
|
-
|
33
|
-
def find_project(project_id)
|
34
|
-
client.list_projects.find{|project| project.id == project_id}
|
35
|
-
end
|
36
|
-
|
37
|
-
def find_device(project_id, device_hostname)
|
38
|
-
client.list_devices(project_id).find{|device| device.hostname == device_hostname}
|
39
|
-
end
|
40
|
-
|
41
|
-
def find_facility(facility_code)
|
42
|
-
client.list_facilities.find{|f| f.code == facility_code}
|
43
|
-
end
|
44
|
-
|
45
|
-
def find_os(os_code)
|
46
|
-
client.list_operating_systems.find{|os| os.slug == os_code}
|
47
|
-
end
|
48
|
-
|
49
|
-
def find_plan(plan_code)
|
50
|
-
client.list_plans.find{|plan| plan.slug == plan_code}
|
51
|
-
end
|
52
|
-
|
53
|
-
def device_public_ip(device)
|
54
|
-
api_retry "Packet API did not find a public ip address for the device" do
|
55
|
-
device.ip_addresses.find{|ip| ip['public'] && ip['address_family'] == 4}
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# Retry API requests to recover from random tls errors
|
60
|
-
# @param [String] message Message to output when giving up
|
61
|
-
# @param [Fixnum] times Default: 5
|
62
|
-
def api_retry(message, times=5, &block)
|
63
|
-
attempt = 1
|
64
|
-
begin
|
65
|
-
yield
|
66
|
-
rescue => error
|
67
|
-
ENV['DEBUG'] && puts("Packet API error: #{error}: #{error.message} - attempt #{attempt}")
|
68
|
-
attempt += 1
|
69
|
-
if attempt < times
|
70
|
-
sleep 5 and retry
|
71
|
-
else
|
72
|
-
abort(message)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def user_data(vars, template_filename)
|
78
|
-
cloudinit_template = File.join(__dir__ , template_filename)
|
79
|
-
erb(File.read(cloudinit_template), vars)
|
80
|
-
end
|
81
|
-
|
82
|
-
def erb(template, vars)
|
83
|
-
ERB.new(template, nil, '%<>-').result(OpenStruct.new(vars).instance_eval { binding })
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'excon'
|
2
|
-
|
3
|
-
require_relative 'random_name'
|
4
|
-
require_relative 'cert_helper'
|
5
|
-
require_relative 'upcloud/upcloud_common'
|
6
|
-
require_relative 'upcloud/node_provisioner'
|
7
|
-
require_relative 'upcloud/node_destroyer'
|
8
|
-
require_relative 'upcloud/node_restarter'
|
9
|
-
require_relative 'upcloud/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
|