kontena-cli 0.7.3 → 0.8.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.
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,26 @@
1
+ module Kontena::Cli::Nodes::DigitalOcean
2
+ class RestartCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NAME", "Node name"
6
+ option "--token", "TOKEN", "DigitalOcean API token", required: true
7
+
8
+ def execute
9
+ require_api_url
10
+ require_current_grid
11
+
12
+ require 'kontena/machine/digital_ocean'
13
+
14
+ client = DropletKit::Client.new(access_token: token)
15
+ droplet = client.droplets.all.find{|d| d.name == name}
16
+ if droplet
17
+ ShellSpinner "Restarting DigitalOcean droplet #{name.colorize(:cyan)} " do
18
+ client.droplet_actions.reboot(droplet_id: droplet.id)
19
+ sleep 5 until client.droplets.find(id: droplet.id).status == 'active'
20
+ end
21
+ else
22
+ abort "Cannot find droplet #{name.colorize(:cyan)} in DigitalOcean"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+ module Kontena::Cli::Nodes::DigitalOcean
2
+ class TerminateCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NAME", "Node name"
6
+ option "--token", "TOKEN", "DigitalOcean API token", required: true
7
+
8
+ def execute
9
+ require_api_url
10
+ require_current_grid
11
+
12
+ require 'kontena/machine/digital_ocean'
13
+ grid = client(require_token).get("grids/#{current_grid}")
14
+ destroyer = Kontena::Machine::DigitalOcean::NodeDestroyer.new(client(require_token), token)
15
+ destroyer.run!(grid, name)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'digital_ocean/create_command'
2
+ require_relative 'digital_ocean/restart_command'
3
+ require_relative 'digital_ocean/terminate_command'
4
+
5
+ module Kontena::Cli::Nodes
6
+ class DigitalOceanCommand < Clamp::Command
7
+
8
+ subcommand "create", "Create a new DigitalOcean node", DigitalOcean::CreateCommand
9
+ subcommand "restart", "Restart DigitalOcean node", DigitalOcean::RestartCommand
10
+ subcommand "terminate", "Terminate DigitalOcean node", DigitalOcean::TerminateCommand
11
+
12
+ def execute
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ module Kontena::Cli::Nodes
2
+ class ListCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ def execute
6
+ require_api_url
7
+ require_current_grid
8
+ token = require_token
9
+
10
+ grids = client(token).get("grids/#{current_grid}/nodes")
11
+ puts "%-30s %-40s %-15s %-30s %-10s" % ['Name', 'OS', 'Driver', 'Labels', 'Status']
12
+ grids['nodes'].each do |node|
13
+ if node['connected']
14
+ status = 'online'
15
+ else
16
+ status = 'offline'
17
+ end
18
+ puts "%-30.30s %-40.40s %-15s %-30.30s %-10s" % [
19
+ node['name'],
20
+ "#{node['os']} (#{node['kernel_version']})",
21
+ node['driver'],
22
+ (node['labels'] || ['-']).join(","),
23
+ status
24
+ ]
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ module Kontena::Cli::Nodes
2
+ class RemoveCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NODE_ID", "Node id"
6
+
7
+ def execute
8
+ require_api_url
9
+ require_current_grid
10
+ token = require_token
11
+
12
+ client(token).delete("grids/#{current_grid}/nodes/#{node_id}")
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ module Kontena::Cli::Nodes
2
+ class ShowCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NODE_ID", "Node id"
6
+
7
+ def execute
8
+ require_api_url
9
+ require_current_grid
10
+ token = require_token
11
+
12
+ node = client(token).get("grids/#{current_grid}/nodes/#{node_id}")
13
+ puts "#{node['name']}:"
14
+ puts " id: #{node['id']}"
15
+ puts " connected: #{node['connected'] ? 'yes': 'no'}"
16
+ puts " last connect: #{node['updated_at']}"
17
+ puts " public ip: #{node['public_ip']}"
18
+ puts " private ip: #{node['private_ip']}"
19
+ puts " overlay network: 10.81.#{node['node_number']}.0/24"
20
+ puts " os: #{node['os']}"
21
+ puts " driver: #{node['driver']}"
22
+ puts " kernel: #{node['kernel_version']}"
23
+ puts " cpus: #{node['cpus']}"
24
+ puts " memory: #{node['mem_total'] / 1024 / 1024}M"
25
+ puts " labels:"
26
+ if node['labels']
27
+ node['labels'].each{|l| puts " - #{l}"}
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,18 @@
1
+ module Kontena::Cli::Nodes
2
+ class UpdateCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NODE_ID", "Node id"
6
+ option ["-l", "--label"], "LABEL", "Node label", multivalued: true
7
+
8
+ def execute
9
+ require_api_url
10
+ require_current_grid
11
+ token = require_token
12
+
13
+ data = {}
14
+ data[:labels] = label_list if label_list
15
+ client(token).put("grids/#{current_grid}/nodes/#{node_id}", data)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ module Kontena::Cli::Nodes::Vagrant
2
+ class CreateCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ option "--name", "NAME", "Node name"
6
+ option "--memory", "MEMORY", "How much memory node has", default: '1024'
7
+ option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
8
+
9
+ def execute
10
+ require_api_url
11
+ require_current_grid
12
+
13
+ require 'kontena/machine/vagrant'
14
+ grid = client(require_token).get("grids/#{current_grid}")
15
+ provisioner = Kontena::Machine::Vagrant::NodeProvisioner.new(client(require_token))
16
+ provisioner.run!(
17
+ master_uri: api_url,
18
+ grid_token: grid['token'],
19
+ grid: current_grid,
20
+ name: name,
21
+ memory: memory,
22
+ version: version
23
+ )
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
1
+ module Kontena::Cli::Nodes::Vagrant
2
+ class RestartCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NAME", "Node name"
6
+
7
+ def execute
8
+ require_api_url
9
+ require_current_grid
10
+
11
+ require 'kontena/machine/vagrant'
12
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
13
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
14
+ Dir.chdir(vagrant_path) do
15
+ ShellSpinner "Restarting Vagrant machine #{name.colorize(:cyan)} " do
16
+ Open3.popen2('vagrant reload') do |stdin, output, wait|
17
+ while o = output.gets
18
+ print o if ENV['DEBUG']
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module Kontena::Cli::Nodes::Vagrant
2
+ class SshCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NAME", "Node name"
6
+
7
+ def execute
8
+ require_api_url
9
+ require_current_grid
10
+
11
+ require 'kontena/machine/vagrant'
12
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
13
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
14
+
15
+ Dir.chdir(vagrant_path) do
16
+ system('vagrant ssh')
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,25 @@
1
+ module Kontena::Cli::Nodes::Vagrant
2
+ class StartCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NAME", "Node name"
6
+
7
+ def execute
8
+ require_api_url
9
+ require_current_grid
10
+
11
+ require 'kontena/machine/vagrant'
12
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
13
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
14
+ Dir.chdir(vagrant_path) do
15
+ ShellSpinner "Starting Vagrant machine #{name.colorize(:cyan)} " do
16
+ Open3.popen2('vagrant up') do |stdin, output, wait|
17
+ while o = output.gets
18
+ print o if ENV['DEBUG']
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ module Kontena::Cli::Nodes::Vagrant
2
+ class StopCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NAME", "Node name"
6
+
7
+ def execute
8
+ require_api_url
9
+ require_current_grid
10
+
11
+ require 'kontena/machine/vagrant'
12
+ vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
13
+ abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
14
+ Dir.chdir(vagrant_path) do
15
+ ShellSpinner "Stopping Vagrant machine #{name.colorize(:cyan)} " do
16
+ Open3.popen2('vagrant halt') do |stdin, output, wait|
17
+ while o = output.gets
18
+ print o if ENV['DEBUG']
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ module Kontena::Cli::Nodes::Vagrant
2
+ class TerminateCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ parameter "NAME", "Node name"
6
+
7
+ def execute
8
+ require_api_url
9
+ require_current_grid
10
+
11
+ require 'kontena/machine/vagrant'
12
+ destroyer = Kontena::Machine::Vagrant::NodeDestroyer.new(client(require_token))
13
+ destroyer.run!(current_grid, name)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'vagrant/create_command'
2
+ require_relative 'vagrant/start_command'
3
+ require_relative 'vagrant/stop_command'
4
+ require_relative 'vagrant/restart_command'
5
+ require_relative 'vagrant/terminate_command'
6
+ require_relative 'vagrant/ssh_command'
7
+
8
+ module Kontena::Cli::Nodes
9
+ class VagrantCommand < Clamp::Command
10
+
11
+ subcommand "create", "Create a new Vagrant node", Vagrant::CreateCommand
12
+ subcommand "ssh", "SSH into Vagrant node", Vagrant::SshCommand
13
+ subcommand "start", "Start Vagrant node", Vagrant::StartCommand
14
+ subcommand "stop", "Stop Vagrant node", Vagrant::StopCommand
15
+ subcommand "restart", "Restart Vagrant node", Vagrant::RestartCommand
16
+ subcommand "terminate", "Terminate Vagrant node", Vagrant::TerminateCommand
17
+
18
+ def execute
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ class Kontena::Cli::RegisterCommand < Clamp::Command
2
+ include Kontena::Cli::Common
3
+
4
+ option "--auth-provider-url", "AUTH_PROVIDER_URL", "Auth provider URL"
5
+
6
+ def execute
7
+ auth_api_url = auth_provider_url || 'https://auth.kontena.io'
8
+ if !auth_api_url.start_with?('http://') && !auth_api_url.start_with?('https://')
9
+ auth_api_url = "https://#{auth_api_url}"
10
+ end
11
+ email = ask("Email: ")
12
+ password = password("Password: ")
13
+ password2 = password("Password again: ")
14
+ if password != password2
15
+ abort("Passwords don't match".colorize(:red))
16
+ end
17
+ params = {email: email, password: password}
18
+ auth_client = Kontena::Client.new(auth_api_url)
19
+ auth_client.post('users', params)
20
+ end
21
+ end
@@ -1,34 +1,40 @@
1
- require 'kontena/client'
2
- require_relative '../common'
3
-
4
- module Kontena::Cli::Grids
5
- class Registry
1
+ module Kontena::Cli::Registry
2
+ class CreateCommand < Clamp::Command
6
3
  include Kontena::Cli::Common
7
4
 
8
- def create(opts)
5
+ option '--node', 'NODE', 'Node name'
6
+ option '--auth-password', 'AUTH_PASSWORD', 'Password protect registry'
7
+ option '--s3-access-key', 'S3_ACCESS_KEY', 'S3 access key'
8
+ option '--s3-secret-key', 'S3_SECRET_KEY', 'S3 secret key'
9
+ option '--s3-bucket', 'S3_BUCKET', 'S3 bucket'
10
+ option '--s3-region', 'S3_REGION', 'S3 region', default: 'eu-west-1'
11
+ option '--s3-encrypt', :flag, 'Encrypt S3 objects', default: false
12
+ option '--s3-secure', :flag, 'Use secure connection in S3', default: true
13
+ option '--azure-account-name', 'AZURE_ACCOUNT_NAME', 'Azure account name'
14
+ option '--azure-account-key', 'AZURE_ACCOUNT_KEY', 'Azure account key'
15
+ option '--azure-container-name', 'AZURE_CONTAINER_NAME', 'Azure container name'
16
+
17
+ def execute
9
18
  require_api_url
10
19
  token = require_token
11
- preferred_node = opts.node
20
+ preferred_node = node
12
21
 
13
22
  registry = client(token).get("services/#{current_grid}/registry") rescue nil
14
- raise ArgumentError.new('Registry already exists') if registry
23
+ abort('Registry already exists') if registry
15
24
 
16
25
  nodes = client(token).get("grids/#{current_grid}/nodes")
17
26
  if preferred_node.nil?
18
27
  node = nodes['nodes'].find{|n| n['connected']}
19
- raise ArgumentError.new('Cannot find any online nodes') if node.nil?
28
+ abort('Cannot find any online nodes') if node.nil?
20
29
  else
21
30
  node = nodes['nodes'].find{|n| n['connected'] && n['name'] == preferred_node }
22
- raise ArgumentError.new('Node not found') if node.nil?
31
+ abort('Node not found') if node.nil?
23
32
  end
24
33
 
25
- if opts.s3_access_key || opts.s3_secret_key
26
- raise ArgumentError.new('--s3-access-key is missing') if opts.s3_access_key.nil?
27
- raise ArgumentError.new('--s3-secret-key is missing') if opts.s3_secret_key.nil?
28
- raise ArgumentError.new('--s3-bucket is missing') if opts.s3_bucket.nil?
29
- s3_region = opts.s3_region || 'eu-west-1'
30
- s3_encrypt = opts.s3_encrypt || false
31
- s3_secure = opts.s3_secure || true
34
+ if s3_access_key || s3_secret_key
35
+ abort('--s3-access-key is missing') if s3_access_key.nil?
36
+ abort('--s3-secret-key is missing') if s3_secret_key.nil?
37
+ abort('--s3-bucket is missing') if s3_bucket.nil?
32
38
  env = [
33
39
  "REGISTRY_STORAGE=s3",
34
40
  "REGISTRY_STORAGE_S3_ACCESSKEY=#{opts.s3_access_key}",
@@ -38,10 +44,10 @@ module Kontena::Cli::Grids
38
44
  "REGISTRY_STORAGE_S3_ENCRYPT=#{s3_encrypt}",
39
45
  "REGISTRY_STORAGE_S3_SECURE=#{s3_secure}",
40
46
  ]
41
- elsif opts.azure_account_name || opts.azure_account_key
42
- raise ArgumentError.new('--azure-account-name is missing') if opts.azure_account_name.nil?
43
- raise ArgumentError.new('--azure-account-key is missing') if opts.azure_account_key.nil?
44
- raise ArgumentError.new('--azure-container-name is missing') if opts.azure_container_name.nil?
47
+ elsif azure_account_name || azure_account_key
48
+ abort('--azure-account-name is missing') if azure_account_name.nil?
49
+ abort('--azure-account-key is missing') if azure_account_key.nil?
50
+ abort('--azure-container-name is missing') if azure_container_name.nil?
45
51
  env = [
46
52
  "REGISTRY_STORAGE=azure",
47
53
  "REGISTRY_STORAGE_AZURE_ACCOUNTNAME=#{opts.azure_account_name}",
@@ -55,11 +61,12 @@ module Kontena::Cli::Grids
55
61
  end
56
62
 
57
63
  env << "REGISTRY_HTTP_ADDR=0.0.0.0:80"
64
+ env << "AUTH_PASSWORD=#{auth_password}" if auth_password
58
65
 
59
66
  data = {
60
67
  name: 'registry',
61
68
  stateful: true,
62
- image: 'registry:2.0',
69
+ image: 'kontena/registry:2.1',
63
70
  volumes: ['/registry'],
64
71
  env: env,
65
72
  affinity: ["node==#{node['name']}"]
@@ -72,19 +79,9 @@ module Kontena::Cli::Grids
72
79
  sleep 1
73
80
  end
74
81
  puts ' done'
75
- puts "Docker Registry 2.0 is now running at registry.kontena.local."
76
- puts "Note: OpenVPN connection is needed to establish connection to this registry."
77
- puts 'Note 2: you must set "--insecure-registry 10.81.0.0/16" to your client docker daemon before you are able to push to this registry.'
78
- end
79
-
80
- def delete
81
- require_api_url
82
- token = require_token
83
-
84
- registry = client(token).get("services/#{current_grid}/registry") rescue nil
85
- raise ArgumentError.new("Docker Registry service does not exist") if registry.nil?
86
-
87
- client(token).delete("services/#{current_grid}/registry")
82
+ puts "Docker Registry 2.1 is now running at registry.kontena.local."
83
+ puts "Note: OpenVPN connection is needed to establish connection to this registry. See 'kontena vpn' for details."
84
+ puts 'Note 2: you must set "--insecure-registry 10.81.0.0/19" to your client docker daemon before you are able to push to this registry.'
88
85
  end
89
86
  end
90
87
  end