kontena-cli 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/kontena +64 -2
  4. data/kontena-cli.gemspec +4 -2
  5. data/lib/kontena/cli/app_command.rb +20 -0
  6. data/lib/kontena/cli/apps/common.rb +53 -0
  7. data/lib/kontena/cli/{stacks/stacks.rb → apps/deploy_command.rb} +17 -31
  8. data/lib/kontena/cli/apps/init_command.rb +101 -0
  9. data/lib/kontena/cli/apps/list_command.rb +41 -0
  10. data/lib/kontena/cli/apps/logs_command.rb +58 -0
  11. data/lib/kontena/cli/apps/remove_command.rb +64 -0
  12. data/lib/kontena/cli/apps/start_command.rb +38 -0
  13. data/lib/kontena/cli/apps/stop_command.rb +38 -0
  14. data/lib/kontena/cli/container_command.rb +9 -0
  15. data/lib/kontena/cli/containers/{containers.rb → exec_command.rb} +5 -5
  16. data/lib/kontena/cli/deploy_command.rb +159 -0
  17. data/lib/kontena/cli/external_registries/add_command.rb +22 -0
  18. data/lib/kontena/cli/external_registries/delete_command.rb +13 -0
  19. data/lib/kontena/cli/external_registries/list_command.rb +16 -0
  20. data/lib/kontena/cli/external_registry_command.rb +14 -0
  21. data/lib/kontena/cli/forgot_password_command.rb +13 -0
  22. data/lib/kontena/cli/grid_command.rb +27 -0
  23. data/lib/kontena/cli/grids/add_user_command.rb +17 -0
  24. data/lib/kontena/cli/grids/{audit_log.rb → audit_log_command.rb} +7 -6
  25. data/lib/kontena/cli/grids/common.rb +24 -0
  26. data/lib/kontena/cli/grids/create_command.rb +26 -0
  27. data/lib/kontena/cli/grids/current_command.rb +18 -0
  28. data/lib/kontena/cli/grids/list_command.rb +26 -0
  29. data/lib/kontena/cli/grids/list_users_command.rb +18 -0
  30. data/lib/kontena/cli/grids/remove_command.rb +26 -0
  31. data/lib/kontena/cli/grids/remove_user_command.rb +16 -0
  32. data/lib/kontena/cli/grids/show_command.rb +19 -0
  33. data/lib/kontena/cli/grids/use_command.rb +21 -0
  34. data/lib/kontena/cli/invite_command.rb +13 -0
  35. data/lib/kontena/cli/login_command.rb +114 -0
  36. data/lib/kontena/cli/logout_command.rb +8 -0
  37. data/lib/kontena/cli/node_command.rb +21 -0
  38. data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +31 -0
  39. data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +26 -0
  40. data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +18 -0
  41. data/lib/kontena/cli/nodes/digital_ocean_command.rb +15 -0
  42. data/lib/kontena/cli/nodes/list_command.rb +28 -0
  43. data/lib/kontena/cli/nodes/remove_command.rb +15 -0
  44. data/lib/kontena/cli/nodes/show_command.rb +31 -0
  45. data/lib/kontena/cli/nodes/update_command.rb +18 -0
  46. data/lib/kontena/cli/nodes/vagrant/create_command.rb +26 -0
  47. data/lib/kontena/cli/nodes/vagrant/restart_command.rb +25 -0
  48. data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +20 -0
  49. data/lib/kontena/cli/nodes/vagrant/start_command.rb +25 -0
  50. data/lib/kontena/cli/nodes/vagrant/stop_command.rb +25 -0
  51. data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +16 -0
  52. data/lib/kontena/cli/nodes/vagrant_command.rb +21 -0
  53. data/lib/kontena/cli/register_command.rb +21 -0
  54. data/lib/kontena/cli/{grids/registry.rb → registry/create_command.rb} +32 -35
  55. data/lib/kontena/cli/registry/delete_command.rb +15 -0
  56. data/lib/kontena/cli/registry_command.rb +11 -0
  57. data/lib/kontena/cli/reset_password_command.rb +17 -0
  58. data/lib/kontena/cli/service_command.rb +33 -0
  59. data/lib/kontena/cli/services/container_command.rb +9 -0
  60. data/lib/kontena/cli/services/containers_command.rb +31 -0
  61. data/lib/kontena/cli/services/create_command.rb +62 -0
  62. data/lib/kontena/cli/services/delete_command.rb +17 -0
  63. data/lib/kontena/cli/services/deploy_command.rb +23 -0
  64. data/lib/kontena/cli/services/list_command.rb +20 -0
  65. data/lib/kontena/cli/services/logs_command.rb +51 -0
  66. data/lib/kontena/cli/services/restart_command.rb +16 -0
  67. data/lib/kontena/cli/services/scale_command.rb +20 -0
  68. data/lib/kontena/cli/services/services_helper.rb +94 -0
  69. data/lib/kontena/cli/services/show_command.rb +17 -0
  70. data/lib/kontena/cli/services/start_command.rb +16 -0
  71. data/lib/kontena/cli/services/{stats.rb → stats_command.rb} +11 -10
  72. data/lib/kontena/cli/services/stop_command.rb +16 -0
  73. data/lib/kontena/cli/services/update_command.rb +51 -0
  74. data/lib/kontena/cli/verify_account_command.rb +13 -0
  75. data/lib/kontena/cli/version_command.rb +8 -0
  76. data/lib/kontena/cli/vpn/config_command.rb +12 -0
  77. data/lib/kontena/cli/{grids/vpn.rb → vpn/create_command.rb} +12 -29
  78. data/lib/kontena/cli/vpn/delete_command.rb +15 -0
  79. data/lib/kontena/cli/vpn_command.rb +13 -0
  80. data/lib/kontena/cli/whoami_command.rb +19 -0
  81. data/lib/kontena/client.rb +14 -11
  82. data/lib/kontena/machine/common.rb +17 -0
  83. data/lib/kontena/machine/digital_ocean.rb +11 -0
  84. data/lib/kontena/machine/digital_ocean/cloudinit.yml +66 -0
  85. data/lib/kontena/machine/digital_ocean/node_destroyer.rb +38 -0
  86. data/lib/kontena/machine/digital_ocean/node_provisioner.rb +74 -0
  87. data/lib/kontena/machine/random_name.rb +42 -0
  88. data/lib/kontena/machine/vagrant.rb +10 -0
  89. data/lib/kontena/machine/vagrant/Vagrantfile.coreos.rb.erb +32 -0
  90. data/lib/kontena/machine/vagrant/cloudinit.yml +65 -0
  91. data/lib/kontena/machine/vagrant/node_destroyer.rb +36 -0
  92. data/lib/kontena/machine/vagrant/node_provisioner.rb +68 -0
  93. data/lib/kontena/scripts/completer +5 -5
  94. data/spec/kontena/cli/app/deploy_command_spec.rb +227 -0
  95. data/spec/kontena/cli/deploy_command_spec.rb +213 -0
  96. data/spec/kontena/cli/login_command_spec.rb +22 -0
  97. data/spec/kontena/cli/register_command_spec.rb +57 -0
  98. data/spec/spec_helper.rb +5 -1
  99. metadata +132 -36
  100. data/lib/kontena/cli/commands.rb +0 -20
  101. data/lib/kontena/cli/containers/commands.rb +0 -12
  102. data/lib/kontena/cli/grids/commands.rb +0 -169
  103. data/lib/kontena/cli/grids/external_registries.rb +0 -40
  104. data/lib/kontena/cli/grids/grids.rb +0 -108
  105. data/lib/kontena/cli/grids/users.rb +0 -32
  106. data/lib/kontena/cli/nodes/commands.rb +0 -27
  107. data/lib/kontena/cli/nodes/nodes.rb +0 -64
  108. data/lib/kontena/cli/server/commands.rb +0 -69
  109. data/lib/kontena/cli/server/server.rb +0 -45
  110. data/lib/kontena/cli/server/user.rb +0 -174
  111. data/lib/kontena/cli/services/commands.rb +0 -138
  112. data/lib/kontena/cli/services/containers.rb +0 -24
  113. data/lib/kontena/cli/services/logs.rb +0 -44
  114. data/lib/kontena/cli/services/services.rb +0 -175
  115. data/lib/kontena/cli/stacks/commands.rb +0 -13
  116. data/spec/kontena/cli/server/user_spec.rb +0 -59
  117. data/spec/kontena/cli/stacks/stacks_spec.rb +0 -212
@@ -0,0 +1,17 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class ShowCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+
10
+ def execute
11
+ require_api_url
12
+ token = require_token
13
+
14
+ show_service(token, name)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class StartCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+
10
+ def execute
11
+ require_api_url
12
+ token = require_token
13
+ result = client(token).post("services/#{parse_service_id(name)}/start", {})
14
+ end
15
+ end
16
+ end
@@ -1,24 +1,25 @@
1
- require 'kontena/client'
2
- require_relative '../common'
3
- require 'pp'
1
+ require_relative 'services_helper'
4
2
 
5
3
  module Kontena::Cli::Services
6
- class Stats
4
+ class StatsCommand < Clamp::Command
7
5
  include Kontena::Cli::Common
6
+ include ServicesHelper
8
7
 
9
- def show(service_id, options)
8
+ parameter "NAME", "Service name"
9
+ option ["-f", "--follow"], :flag, "Follow stats in real time", default: false
10
+
11
+ def execute
10
12
  require_api_url
11
13
  token = require_token
12
- if options.follow
14
+ if follow?
13
15
  system('clear')
14
16
  render_header
15
17
  end
16
18
  loop do
17
- fetch_stats(token, service_id, options.follow)
18
- break unless options.follow
19
+ fetch_stats(token, name, follow?)
20
+ break unless follow?
19
21
  sleep(2)
20
22
  end
21
-
22
23
  end
23
24
 
24
25
  private
@@ -40,7 +41,7 @@ module Kontena::Cli::Services
40
41
  memory = stat['memory'].nil? ? 'N/A' : filesize_to_human(stat['memory']['usage'])
41
42
  if !stat['memory'].nil? && stat['memory']['limit'] != 1.8446744073709552e+19
42
43
  memory_limit = filesize_to_human(stat['memory']['limit'])
43
- memory_pct = "#{(memory.to_f / memory_limit.to_f * 100).round(2)}%"
44
+ memory_pct = "#{(stat['memory']['usage'].to_f / stat['memory']['limit'].to_f * 100).round(2)}%"
44
45
  else
45
46
  memory_limit = 'N/A'
46
47
  memory_pct = 'N/A'
@@ -0,0 +1,16 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class StopCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+
10
+ def execute
11
+ require_api_url
12
+ token = require_token
13
+ result = client(token).post("services/#{parse_service_id(name)}/stop", {})
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,51 @@
1
+ require_relative 'services_helper'
2
+
3
+ module Kontena::Cli::Services
4
+ class UpdateCommand < Clamp::Command
5
+ include Kontena::Cli::Common
6
+ include ServicesHelper
7
+
8
+ parameter "NAME", "Service name"
9
+
10
+ option "--image", "IMAGE", "Docker image to use"
11
+ option ["-p", "--ports"], "PORTS", "Publish a service's port to the host", multivalued: true
12
+ option ["-e", "--env"], "ENV", "Set environment variables", multivalued: true
13
+ option ["-a", "--affinity"], "AFFINITY", "Set service affinity", multivalued: true
14
+ option ["-c", "--cpu-shares"], "CPU_SHARES", "CPU shares (relative weight)"
15
+ option ["-m", "--memory"], "MEMORY", "Memory limit (format: <number><optional unit>, where unit = b, k, m or g)"
16
+ option ["--memory-swap"], "MEMORY_SWAP", "Total memory usage (memory + swap), set \'-1\' to disable swap (format: <number><optional unit>, where unit = b, k, m or g)"
17
+ option "--cmd", "CMD", "Command to execute"
18
+ option "--instances", "INSTANCES", "How many instances should be deployed"
19
+ option ["-u", "--user"], "USER", "Username who executes first process inside container"
20
+ option "--cap-add", "CAP_ADD", "Add capabitilies", multivalued: true
21
+ option "--cap-drop", "CAP_DROP", "Drop capabitilies", multivalued: true
22
+
23
+ def execute
24
+ require_api_url
25
+ token = require_token
26
+
27
+ data = parse_service_data_from_options
28
+ update_service(token, name, data)
29
+ end
30
+
31
+ ##
32
+ # parse given options to hash
33
+ # @return [Hash]
34
+ def parse_service_data_from_options
35
+ data = {}
36
+ data[:ports] = parse_ports(ports_list) if ports_list
37
+ data[:memory] = parse_memory(memory) if memory
38
+ data[:memory_swap] = parse_memory(memory_swap) if memory_swap
39
+ data[:cpu_shares] = cpu_shares if cpu_shares
40
+ data[:affinity] = affinity_list if affinity_list
41
+ data[:env] = env_list if env_list
42
+ data[:container_count] = instances if instances
43
+ data[:cmd] = cmd.split(" ") if cmd
44
+ data[:user] = user if user
45
+ data[:image] = image if image
46
+ data[:cap_add] = cap_add_list if cap_add_list
47
+ data[:cap_drop] = cap_drop_list if cap_drop_list
48
+ data
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,13 @@
1
+ class Kontena::Cli::VerifyAccountCommand < Clamp::Command
2
+ include Kontena::Cli::Common
3
+
4
+ parameter "TOKEN", "Kontena verify token"
5
+
6
+ def execute
7
+ require_api_url
8
+
9
+ params = {token: token}
10
+ client.post('user/email_confirm', params)
11
+ puts 'Account verified'.colorize(:green)
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ require_relative 'version'
2
+
3
+ class Kontena::Cli::VersionCommand < Clamp::Command
4
+
5
+ def execute
6
+ puts Kontena::Cli::VERSION
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ module Kontena::Cli::Vpn
2
+ class ConfigCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_api_url
7
+ payload = {cmd: ['/usr/local/bin/ovpn_getclient', 'KONTENA_VPN_CLIENT']}
8
+ stdout, stderr = client(require_token).post("containers/#{current_grid}/vpn/vpn-1/exec", payload)
9
+ puts stdout
10
+ end
11
+ end
12
+ end
@@ -1,33 +1,33 @@
1
- require 'kontena/client'
2
- require_relative '../common'
3
-
4
- module Kontena::Cli::Grids
5
- class Vpn
1
+ module Kontena::Cli::Vpn
2
+ class CreateCommand < Clamp::Command
6
3
  include Kontena::Cli::Common
7
4
 
8
- def create(opts)
5
+ option '--node', 'NODE', 'Node name where VPN is deployed'
6
+ option '--ip', 'IP', 'Node ip-address'
7
+
8
+ def execute
9
9
  require_api_url
10
10
  token = require_token
11
- preferred_node = opts.node
11
+ preferred_node = node
12
12
 
13
13
  vpn = client(token).get("services/#{current_grid}/vpn") rescue nil
14
- raise ArgumentError.new('Vpn already exists') if vpn
14
+ abort('Vpn already exists') if vpn
15
15
 
16
16
  nodes = client(token).get("grids/#{current_grid}/nodes")
17
17
  if preferred_node.nil?
18
18
  node = nodes['nodes'].find{|n| n['connected']}
19
- raise ArgumentError.new('Cannot find any online nodes') if node.nil?
19
+ abort('Cannot find any online nodes') if node.nil?
20
20
  else
21
21
  node = nodes['nodes'].find{|n| n['connected'] && n['name'] == preferred_node }
22
- raise ArgumentError.new('Node not found') if node.nil?
22
+ abort('Node not found') if node.nil?
23
23
  end
24
24
 
25
- public_ip = opts.ip || node['public_ip']
25
+ public_ip = ip || node['public_ip']
26
26
 
27
27
  data = {
28
28
  name: 'vpn',
29
29
  stateful: true,
30
- image: 'kontena/openvpn:latest',
30
+ image: 'kontena/openvpn:ethwe',
31
31
  ports: [
32
32
  {
33
33
  container_port: '1194',
@@ -50,22 +50,5 @@ module Kontena::Cli::Grids
50
50
  puts "OpenVPN service is now started (udp://#{public_ip}:1194)."
51
51
  puts "Use 'kontena vpn config' to fetch OpenVPN client config to your machine (it takes a while until config is ready)."
52
52
  end
53
-
54
- def delete
55
- require_api_url
56
- token = require_token
57
-
58
- vpn = client(token).get("services/#{current_grid}/vpn") rescue nil
59
- raise ArgumentError.new("VPN service does not exist") if vpn.nil?
60
-
61
- client(token).delete("services/#{current_grid}/vpn")
62
- end
63
-
64
- def config
65
- require_api_url
66
- payload = {cmd: ['/usr/local/bin/ovpn_getclient', 'KONTENA_VPN_CLIENT']}
67
- stdout, stderr = client(require_token).post("containers/#{current_grid}/vpn/vpn-1/exec", payload)
68
- puts stdout
69
- end
70
53
  end
71
54
  end
@@ -0,0 +1,15 @@
1
+ module Kontena::Cli::Vpn
2
+ class DeleteCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_api_url
7
+ token = require_token
8
+
9
+ vpn = client(token).get("services/#{current_grid}/vpn") rescue nil
10
+ abort("VPN service does not exist") if vpn.nil?
11
+
12
+ client(token).delete("services/#{current_grid}/vpn")
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'vpn/create_command'
2
+ require_relative 'vpn/config_command'
3
+ require_relative 'vpn/delete_command'
4
+
5
+ class Kontena::Cli::VpnCommand < Clamp::Command
6
+
7
+ subcommand "create", "Create VPN service", Kontena::Cli::Vpn::CreateCommand
8
+ subcommand "config", "Show/Export VPN config", Kontena::Cli::Vpn::ConfigCommand
9
+ subcommand "delete", "Delete VPN service", Kontena::Cli::Vpn::DeleteCommand
10
+
11
+ def execute
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ class Kontena::Cli::WhoamiCommand < Clamp::Command
2
+ include Kontena::Cli::Common
3
+
4
+ option '--bash-completion-path', :flag, 'Show bash completion path', hidden: true
5
+
6
+ def execute
7
+ if bash_completion_path?
8
+ puts File.realpath(File.join(__dir__, '../scripts/init'))
9
+ exit 0
10
+ end
11
+
12
+ require_api_url
13
+ puts "Master: #{settings['server']['url']}"
14
+ token = require_token
15
+ response = client(token).get('user')
16
+ puts "User: #{response['email']}"
17
+ end
18
+
19
+ end
@@ -1,5 +1,5 @@
1
1
  require 'json'
2
- require 'httpclient'
2
+ require 'excon'
3
3
  require_relative 'errors'
4
4
  require 'kontena/cli/version'
5
5
 
@@ -14,8 +14,8 @@ module Kontena
14
14
  # @param [String] api_url
15
15
  # @param [Hash] default_headers
16
16
  def initialize(api_url, default_headers = {})
17
- @http_client = HTTPClient.new
18
- @http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE if ignore_ssl_errors?
17
+ Excon.defaults[:ssl_verify_peer] = false if ignore_ssl_errors?
18
+ @http_client = Excon.new(api_url)
19
19
  @default_headers = {'Accept' => 'application/json', 'Content-Type' => 'application/json', 'User-Agent' => "kontena-cli/#{Kontena::Cli::VERSION}"}.merge(default_headers)
20
20
  @api_url = api_url
21
21
  end
@@ -26,7 +26,7 @@ module Kontena
26
26
  # @param [Hash,NilClass] params
27
27
  # @return [Hash]
28
28
  def get(path, params = nil, headers = {})
29
- response = http_client.get(request_uri(path), params, request_headers(headers))
29
+ response = http_client.get(path: request_uri(path), query: params, headers: request_headers(headers))
30
30
  if response.status == 200
31
31
  parse_response(response)
32
32
  else
@@ -44,12 +44,13 @@ module Kontena
44
44
  def post(path, obj, params = {}, headers = {})
45
45
  request_headers = request_headers(headers)
46
46
  request_options = {
47
- header: request_headers,
47
+ path: request_uri(path),
48
+ headers: request_headers,
48
49
  body: encode_body(obj, request_headers['Content-Type']),
49
50
  query: params
50
51
  }
51
52
 
52
- response = http_client.post(request_uri(path), request_options)
53
+ response = http_client.post(request_options)
53
54
  if [200, 201].include?(response.status)
54
55
  parse_response(response)
55
56
  else
@@ -67,12 +68,13 @@ module Kontena
67
68
  def put(path, obj, params = {}, headers = {})
68
69
  request_headers = request_headers(headers)
69
70
  request_options = {
70
- header: request_headers,
71
+ path: request_uri(path),
72
+ headers: request_headers,
71
73
  body: encode_body(obj, request_headers['Content-Type']),
72
74
  query: params
73
75
  }
74
76
 
75
- response = http_client.put(request_uri(path), request_options)
77
+ response = http_client.put(request_options)
76
78
  if [200, 201].include?(response.status)
77
79
  parse_response(response)
78
80
  else
@@ -90,11 +92,12 @@ module Kontena
90
92
  def delete(path, body = nil, params = {}, headers = {})
91
93
  request_headers = request_headers(headers)
92
94
  request_options = {
93
- header: request_headers,
95
+ path: request_uri(path),
96
+ headers: request_headers,
94
97
  body: encode_body(body, request_headers['Content-Type']),
95
98
  query: params
96
99
  }
97
- response = http_client.delete(request_uri(path), request_options)
100
+ response = http_client.delete(request_options)
98
101
  if response.status == 200
99
102
  parse_response(response)
100
103
  else
@@ -110,7 +113,7 @@ module Kontena
110
113
  # @param [String] path
111
114
  # @return [String]
112
115
  def request_uri(path)
113
- "#{@api_url}/v1/#{path}"
116
+ "/v1/#{path}"
114
117
  end
115
118
 
116
119
  ##
@@ -0,0 +1,17 @@
1
+ module Kontena
2
+ module Machine
3
+ module Common
4
+
5
+ def which(cmd)
6
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
7
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
8
+ exts.each { |ext|
9
+ exe = File.join(path, "#{cmd}#{ext}")
10
+ return exe if File.executable?(exe) && !File.directory?(exe)
11
+ }
12
+ end
13
+ return nil
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
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 'digital_ocean/node_provisioner'
11
+ require_relative 'digital_ocean/node_destroyer'
@@ -0,0 +1,66 @@
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-insecure-registry.conf
12
+ content: |
13
+ [Service]
14
+ Environment='DOCKER_OPTS=--insecure-registry="10.81.0.0/19" --bip="172.17.42.1/16"'
15
+ coreos:
16
+ units:
17
+ - name: 00-eth.network
18
+ runtime: true
19
+ content: |
20
+ [Match]
21
+ Name=eth*
22
+ [Network]
23
+ DHCP=yes
24
+ DNS=172.17.42.1
25
+ DNS=173.245.58.51
26
+ DNS=173.245.59.41
27
+ DNS=8.8.8.8
28
+ DOMAINS=kontena.local
29
+ [DHCP]
30
+ UseDNS=false
31
+
32
+ - name: 10-weave.network
33
+ runtime: false
34
+ content: |
35
+ [Match]
36
+ Type=bridge
37
+ Name=weave*
38
+
39
+ [Network]
40
+ - name: kontena-agent.service
41
+ command: start
42
+ enable: true
43
+ content: |
44
+ [Unit]
45
+ Description=kontena-agent
46
+ After=network-online.target
47
+ After=docker.service
48
+ Description=Kontena Agent
49
+ Documentation=http://www.kontena.io/
50
+ Requires=network-online.target
51
+ Requires=docker.service
52
+
53
+ [Service]
54
+ Restart=always
55
+ RestartSec=5
56
+ EnvironmentFile=/etc/kontena-agent.env
57
+ ExecStartPre=-/usr/bin/docker stop kontena-agent
58
+ ExecStartPre=-/usr/bin/docker rm kontena-agent
59
+ ExecStartPre=/usr/bin/docker pull kontena/agent:${KONTENA_VERSION}
60
+ ExecStart=/usr/bin/docker run --name kontena-agent \
61
+ -e KONTENA_URI=${KONTENA_URI} \
62
+ -e KONTENA_TOKEN=${KONTENA_TOKEN} \
63
+ -e KONTENA_PEER_INTERFACE=${KONTENA_PEER_INTERFACE} \
64
+ -v=/var/run/docker.sock:/var/run/docker.sock \
65
+ --net=host \
66
+ kontena/agent:${KONTENA_VERSION}