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.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/VERSION +1 -1
  4. data/bin/kontena +3 -50
  5. data/examples/kontena-plugin-hello/.gitignore +9 -0
  6. data/examples/kontena-plugin-hello/Gemfile +4 -0
  7. data/examples/kontena-plugin-hello/README.md +3 -0
  8. data/examples/kontena-plugin-hello/bin/console +14 -0
  9. data/examples/kontena-plugin-hello/bin/setup +8 -0
  10. data/examples/kontena-plugin-hello/kontena-plugin-hello.gemspec +22 -0
  11. data/examples/kontena-plugin-hello/lib/kontena/plugin/hello.rb +7 -0
  12. data/examples/kontena-plugin-hello/lib/kontena/plugin/hello/world_command.rb +6 -0
  13. data/examples/kontena-plugin-hello/lib/kontena/plugin/hello_command.rb +9 -0
  14. data/examples/kontena-plugin-hello/lib/kontena_cli_plugin.rb +5 -0
  15. data/kontena-cli.gemspec +1 -3
  16. data/lib/kontena/cli/apps/build_command.rb +3 -0
  17. data/lib/kontena/cli/apps/common.rb +6 -1
  18. data/lib/kontena/cli/apps/deploy_command.rb +1 -1
  19. data/lib/kontena/cli/apps/docker_helper.rb +13 -14
  20. data/lib/kontena/cli/apps/service_generator.rb +19 -11
  21. data/lib/kontena/cli/apps/service_generator_v2.rb +1 -0
  22. data/lib/kontena/cli/apps/yaml/reader.rb +15 -0
  23. data/lib/kontena/cli/apps/yaml/service_extender.rb +28 -0
  24. data/lib/kontena/cli/apps/yaml/validations.rb +38 -24
  25. data/lib/kontena/cli/apps/yaml/validator.rb +7 -7
  26. data/lib/kontena/cli/apps/yaml/validator_v2.rb +7 -6
  27. data/lib/kontena/cli/certificate/authorize_command.rb +23 -0
  28. data/lib/kontena/cli/certificate/get_command.rb +25 -0
  29. data/lib/kontena/cli/certificate/register_command.rb +19 -0
  30. data/lib/kontena/cli/certificate_command.rb +14 -0
  31. data/lib/kontena/cli/containers/containers_helper.rb +22 -0
  32. data/lib/kontena/cli/containers/exec_command.rb +9 -2
  33. data/lib/kontena/cli/grids/logs_command.rb +14 -3
  34. data/lib/kontena/cli/master_command.rb +1 -12
  35. data/lib/kontena/cli/node_command.rb +0 -16
  36. data/lib/kontena/cli/plugin_command.rb +15 -0
  37. data/lib/kontena/cli/plugins/install_command.rb +28 -0
  38. data/lib/kontena/cli/plugins/list_command.rb +13 -0
  39. data/lib/kontena/cli/plugins/search_command.rb +29 -0
  40. data/lib/kontena/cli/plugins/uninstall_command.rb +30 -0
  41. data/lib/kontena/cli/registry/create_command.rb +1 -1
  42. data/lib/kontena/cli/services/create_command.rb +16 -0
  43. data/lib/kontena/cli/services/list_command.rb +17 -3
  44. data/lib/kontena/cli/services/logs_command.rb +63 -18
  45. data/lib/kontena/cli/services/services_helper.rb +47 -4
  46. data/lib/kontena/cli/services/update_command.rb +16 -0
  47. data/lib/kontena/cli/stack_command.rb +20 -0
  48. data/lib/kontena/cli/stacks/common.rb +39 -0
  49. data/lib/kontena/cli/stacks/create_command.rb +27 -0
  50. data/lib/kontena/cli/stacks/deploy_command.rb +26 -0
  51. data/lib/kontena/cli/stacks/list_command.rb +38 -0
  52. data/lib/kontena/cli/stacks/remove_command.rb +26 -0
  53. data/lib/kontena/cli/stacks/show_command.rb +38 -0
  54. data/lib/kontena/cli/stacks/update_command.rb +27 -0
  55. data/lib/kontena/client.rb +11 -4
  56. data/lib/kontena/command.rb +4 -0
  57. data/lib/kontena/main_command.rb +61 -0
  58. data/lib/kontena/plugin_manager.rb +38 -0
  59. data/lib/kontena/util.rb +17 -0
  60. data/lib/kontena_cli.rb +6 -0
  61. data/spec/fixtures/health.yml +26 -0
  62. data/spec/fixtures/kontena-build.yml +16 -0
  63. data/spec/fixtures/kontena_build_v2.yaml +26 -0
  64. data/spec/kontena/cli/app/build_command_spec.rb +13 -1
  65. data/spec/kontena/cli/app/common_spec.rb +11 -0
  66. data/spec/kontena/cli/app/deploy_command_spec.rb +1 -1
  67. data/spec/kontena/cli/app/docker_helper_spec.rb +45 -0
  68. data/spec/kontena/cli/app/service_generator_spec.rb +52 -1
  69. data/spec/kontena/cli/app/yaml/service_extender_spec.rb +24 -0
  70. data/spec/kontena/cli/app/yaml/validator_spec.rb +97 -14
  71. data/spec/kontena/cli/common_spec.rb +0 -5
  72. data/spec/kontena/cli/containers/containers_helper_spec.rb +16 -0
  73. data/spec/kontena/cli/services/services_helper_spec.rb +50 -1
  74. data/spec/kontena/cli/version_command_spec.rb +1 -1
  75. data/spec/kontena/client_spec.rb +156 -0
  76. data/spec/kontena/plugin_manager_spec.rb +22 -0
  77. data/spec/spec_helper.rb +1 -0
  78. metadata +54 -125
  79. data/lib/kontena/cli/master/aws/create_command.rb +0 -48
  80. data/lib/kontena/cli/master/aws_command.rb +0 -8
  81. data/lib/kontena/cli/master/azure/create_command.rb +0 -37
  82. data/lib/kontena/cli/master/azure_command.rb +0 -13
  83. data/lib/kontena/cli/master/digital_ocean/create_command.rb +0 -38
  84. data/lib/kontena/cli/master/digital_ocean_command.rb +0 -13
  85. data/lib/kontena/cli/master/packet/create_command.rb +0 -42
  86. data/lib/kontena/cli/master/packet_command.rb +0 -14
  87. data/lib/kontena/cli/master/upcloud/create_command.rb +0 -39
  88. data/lib/kontena/cli/master/upcloud_command.rb +0 -13
  89. data/lib/kontena/cli/master/vagrant/create_command.rb +0 -25
  90. data/lib/kontena/cli/master/vagrant/restart_command.rb +0 -20
  91. data/lib/kontena/cli/master/vagrant/ssh_command.rb +0 -15
  92. data/lib/kontena/cli/master/vagrant/start_command.rb +0 -20
  93. data/lib/kontena/cli/master/vagrant/stop_command.rb +0 -20
  94. data/lib/kontena/cli/master/vagrant/terminate_command.rb +0 -13
  95. data/lib/kontena/cli/master/vagrant_command.rb +0 -23
  96. data/lib/kontena/cli/nodes/aws/create_command.rb +0 -44
  97. data/lib/kontena/cli/nodes/aws/restart_command.rb +0 -29
  98. data/lib/kontena/cli/nodes/aws/terminate_command.rb +0 -21
  99. data/lib/kontena/cli/nodes/aws_command.rb +0 -15
  100. data/lib/kontena/cli/nodes/azure/create_command.rb +0 -38
  101. data/lib/kontena/cli/nodes/azure/restart_command.rb +0 -32
  102. data/lib/kontena/cli/nodes/azure/terminate_command.rb +0 -21
  103. data/lib/kontena/cli/nodes/azure_command.rb +0 -15
  104. data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +0 -32
  105. data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +0 -27
  106. data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +0 -19
  107. data/lib/kontena/cli/nodes/digital_ocean_command.rb +0 -15
  108. data/lib/kontena/cli/nodes/packet/create_command.rb +0 -35
  109. data/lib/kontena/cli/nodes/packet/restart_command.rb +0 -17
  110. data/lib/kontena/cli/nodes/packet/terminate_command.rb +0 -20
  111. data/lib/kontena/cli/nodes/packet_command.rb +0 -15
  112. data/lib/kontena/cli/nodes/upcloud/create_command.rb +0 -33
  113. data/lib/kontena/cli/nodes/upcloud/restart_command.rb +0 -20
  114. data/lib/kontena/cli/nodes/upcloud/terminate_command.rb +0 -20
  115. data/lib/kontena/cli/nodes/upcloud_command.rb +0 -15
  116. data/lib/kontena/cli/nodes/vagrant/create_command.rb +0 -27
  117. data/lib/kontena/cli/nodes/vagrant/restart_command.rb +0 -26
  118. data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +0 -21
  119. data/lib/kontena/cli/nodes/vagrant/start_command.rb +0 -26
  120. data/lib/kontena/cli/nodes/vagrant/stop_command.rb +0 -26
  121. data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +0 -17
  122. data/lib/kontena/cli/nodes/vagrant_command.rb +0 -21
  123. data/lib/kontena/machine/aws.rb +0 -13
  124. data/lib/kontena/machine/aws/cloudinit.yml +0 -71
  125. data/lib/kontena/machine/aws/cloudinit_master.yml +0 -118
  126. data/lib/kontena/machine/aws/common.rb +0 -58
  127. data/lib/kontena/machine/aws/master_provisioner.rb +0 -187
  128. data/lib/kontena/machine/aws/node_destroyer.rb +0 -51
  129. data/lib/kontena/machine/aws/node_provisioner.rb +0 -204
  130. data/lib/kontena/machine/azure.rb +0 -13
  131. data/lib/kontena/machine/azure/cloudinit.yml +0 -64
  132. data/lib/kontena/machine/azure/cloudinit_master.yml +0 -106
  133. data/lib/kontena/machine/azure/logger.rb +0 -27
  134. data/lib/kontena/machine/azure/master_provisioner.rb +0 -128
  135. data/lib/kontena/machine/azure/node_destroyer.rb +0 -53
  136. data/lib/kontena/machine/azure/node_provisioner.rb +0 -132
  137. data/lib/kontena/machine/digital_ocean.rb +0 -13
  138. data/lib/kontena/machine/digital_ocean/cloudinit.yml +0 -64
  139. data/lib/kontena/machine/digital_ocean/cloudinit_master.yml +0 -118
  140. data/lib/kontena/machine/digital_ocean/master_provisioner.rb +0 -99
  141. data/lib/kontena/machine/digital_ocean/node_destroyer.rb +0 -40
  142. data/lib/kontena/machine/digital_ocean/node_provisioner.rb +0 -88
  143. data/lib/kontena/machine/packet.rb +0 -17
  144. data/lib/kontena/machine/packet/cloudinit.yml +0 -66
  145. data/lib/kontena/machine/packet/cloudinit_master.yml +0 -118
  146. data/lib/kontena/machine/packet/master_provisioner.rb +0 -93
  147. data/lib/kontena/machine/packet/node_destroyer.rb +0 -42
  148. data/lib/kontena/machine/packet/node_provisioner.rb +0 -77
  149. data/lib/kontena/machine/packet/node_restarter.rb +0 -41
  150. data/lib/kontena/machine/packet/packet_common.rb +0 -89
  151. data/lib/kontena/machine/upcloud.rb +0 -9
  152. data/lib/kontena/machine/upcloud/cloudinit.yml +0 -64
  153. data/lib/kontena/machine/upcloud/cloudinit_master.yml +0 -118
  154. data/lib/kontena/machine/upcloud/master_provisioner.rb +0 -138
  155. data/lib/kontena/machine/upcloud/node_destroyer.rb +0 -85
  156. data/lib/kontena/machine/upcloud/node_provisioner.rb +0 -121
  157. data/lib/kontena/machine/upcloud/node_restarter.rb +0 -49
  158. data/lib/kontena/machine/upcloud/upcloud_common.rb +0 -74
  159. data/lib/kontena/machine/vagrant.rb +0 -12
  160. data/lib/kontena/machine/vagrant/Vagrantfile.master.rb.erb +0 -104
  161. data/lib/kontena/machine/vagrant/Vagrantfile.node.rb.erb +0 -32
  162. data/lib/kontena/machine/vagrant/cloudinit.yml +0 -73
  163. data/lib/kontena/machine/vagrant/master_destroyer.rb +0 -37
  164. data/lib/kontena/machine/vagrant/master_provisioner.rb +0 -79
  165. data/lib/kontena/machine/vagrant/node_destroyer.rb +0 -40
  166. data/lib/kontena/machine/vagrant/node_provisioner.rb +0 -68
@@ -1,13 +0,0 @@
1
-
2
- module Kontena::Cli::Master
3
-
4
- require_relative 'digital_ocean/create_command'
5
-
6
- class DigitalOceanCommand < Clamp::Command
7
-
8
- subcommand "create", "Create a new DigitalOcean master", DigitalOcean::CreateCommand
9
-
10
- def execute
11
- end
12
- end
13
- end
@@ -1,42 +0,0 @@
1
- require 'securerandom'
2
-
3
- module Kontena::Cli::Master::Packet
4
- class CreateCommand < Clamp::Command
5
- include Kontena::Cli::Common
6
-
7
- option "--token", "TOKEN", "Packet API token", required: true
8
- option "--project", "PROJECT ID", "Packet project id", required: true
9
- option "--ssl-cert", "PATH", "SSL certificate file (optional)"
10
- option "--type", "TYPE", "Server type (baremetal_0, baremetal_1, ..)", default: 'baremetal_0', attribute_name: :plan
11
- option "--facility", "FACILITY CODE", "Facility", default: 'ams1'
12
- option "--billing", "BILLING", "Billing cycle", default: 'hourly'
13
- option "--ssh-key", "PATH", "Path to ssh public key (optional)"
14
- option "--vault-secret", "VAULT_SECRET", "Secret key for Vault (optional)"
15
- option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
16
- option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
17
- option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
18
- option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
19
-
20
- def execute
21
-
22
- require 'kontena/machine/packet'
23
-
24
- provisioner = Kontena::Machine::Packet::MasterProvisioner.new(token)
25
- provisioner.run!(
26
- project: project,
27
- billing: billing,
28
- ssh_key: ssh_key,
29
- ssl_cert: ssl_cert,
30
- plan: plan,
31
- facility: facility,
32
- version: version,
33
- auth_server: auth_provider_url,
34
- vault_secret: vault_secret || SecureRandom.hex(24),
35
- vault_iv: vault_iv || SecureRandom.hex(24),
36
- mongodb_uri: mongodb_uri
37
- )
38
- end
39
-
40
- end
41
- end
42
-
@@ -1,14 +0,0 @@
1
-
2
- module Kontena::Cli::Master
3
-
4
- require_relative 'packet/create_command'
5
-
6
- class PacketCommand < Clamp::Command
7
-
8
- subcommand "create", "Create a new Packet master", Packet::CreateCommand
9
-
10
- def execute
11
- end
12
- end
13
- end
14
-
@@ -1,39 +0,0 @@
1
- require 'securerandom'
2
-
3
- module Kontena::Cli::Master::Upcloud
4
- class CreateCommand < Clamp::Command
5
- include Kontena::Cli::Common
6
-
7
- option "--username", "USER", "Upcloud username", required: true
8
- option "--password", "PASS", "Upcloud password", required: true
9
- option "--ssh-key", "SSH_KEY", "Path to ssh public key", required: true
10
- option "--ssl-cert", "SSL CERT", "SSL certificate file (optional)"
11
- option "--plan", "PLAN", "Server plan", default: '1xCPU-1GB'
12
- option "--zone", "ZONE", "Zone", default: 'fi-hel1'
13
- option "--vault-secret", "VAULT_SECRET", "Secret key for Vault (optional)"
14
- option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
15
- option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
16
- option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
17
- option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
18
-
19
-
20
- def execute
21
-
22
- require 'kontena/machine/upcloud'
23
-
24
- provisioner = Kontena::Machine::Upcloud::MasterProvisioner.new(username, password)
25
- provisioner.run!(
26
- ssh_key: ssh_key,
27
- ssl_cert: ssl_cert,
28
- plan: plan,
29
- zone: zone,
30
- version: version,
31
- auth_server: auth_provider_url,
32
- vault_secret: vault_secret || SecureRandom.hex(24),
33
- vault_iv: vault_iv || SecureRandom.hex(24),
34
- mongodb_uri: mongodb_uri
35
- )
36
- end
37
-
38
- end
39
- end
@@ -1,13 +0,0 @@
1
-
2
- module Kontena::Cli::Master
3
-
4
- require_relative 'upcloud/create_command'
5
-
6
- class UpcloudCommand < Clamp::Command
7
-
8
- subcommand "create", "Create a new Upcloud master", Upcloud::CreateCommand
9
-
10
- def execute
11
- end
12
- end
13
- end
@@ -1,25 +0,0 @@
1
- require 'securerandom'
2
-
3
- module Kontena::Cli::Master::Vagrant
4
- class CreateCommand < Clamp::Command
5
- include Kontena::Cli::Common
6
-
7
- option "--memory", "MEMORY", "How much memory node has", default: '512'
8
- option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
9
- option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
10
- option "--vault-secret", "VAULT_SECRET", "Secret key for Vault"
11
- option "--vault-iv", "VAULT_IV", "Initialization vector for Vault"
12
-
13
- def execute
14
- require 'kontena/machine/vagrant'
15
- provisioner = Kontena::Machine::Vagrant::MasterProvisioner.new
16
- provisioner.run!(
17
- memory: memory,
18
- version: version,
19
- auth_server: auth_provider_url,
20
- vault_secret: vault_secret || SecureRandom.hex(24),
21
- vault_iv: vault_iv || SecureRandom.hex(24)
22
- )
23
- end
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- module Kontena::Cli::Master::Vagrant
2
- class RestartCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
-
5
- def execute
6
- require 'kontena/machine/vagrant'
7
- vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
8
- abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
9
- Dir.chdir(vagrant_path) do
10
- ShellSpinner "Restarting Vagrant kontena-master " do
11
- Open3.popen2('vagrant reload') do |stdin, output, wait|
12
- while o = output.gets
13
- print o if ENV['DEBUG']
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,15 +0,0 @@
1
- module Kontena::Cli::Master::Vagrant
2
- class SshCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
-
5
- def execute
6
- require 'kontena/machine/vagrant'
7
- vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
8
- abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
9
-
10
- Dir.chdir(vagrant_path) do
11
- system('vagrant ssh')
12
- end
13
- end
14
- end
15
- end
@@ -1,20 +0,0 @@
1
- module Kontena::Cli::Master::Vagrant
2
- class StartCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
-
5
- def execute
6
- require 'kontena/machine/vagrant'
7
- vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
8
- abort("Cannot find Vagrant node kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
9
- Dir.chdir(vagrant_path) do
10
- ShellSpinner "Starting Vagrant machine kontena-master " do
11
- Open3.popen2('vagrant up') do |stdin, output, wait|
12
- while o = output.gets
13
- print o if ENV['DEBUG']
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- module Kontena::Cli::Master::Vagrant
2
- class StopCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
-
5
- def execute
6
- require 'kontena/machine/vagrant'
7
- vagrant_path = "#{Dir.home}/.kontena/vagrant_master"
8
- abort("Cannot find Vagrant kontena-master".colorize(:red)) unless Dir.exist?(vagrant_path)
9
- Dir.chdir(vagrant_path) do
10
- ShellSpinner "Stopping Vagrant kontena-master " do
11
- Open3.popen2('vagrant halt') do |stdin, output, wait|
12
- while o = output.gets
13
- print o if ENV['DEBUG']
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,13 +0,0 @@
1
- module Kontena::Cli::Master::Vagrant
2
- class TerminateCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
-
5
- def execute
6
- require_api_url
7
-
8
- require 'kontena/machine/vagrant'
9
- destroyer = Kontena::Machine::Vagrant::MasterDestroyer.new(client(require_token))
10
- destroyer.run!
11
- end
12
- end
13
- end
@@ -1,23 +0,0 @@
1
-
2
- module Kontena::Cli::Master
3
-
4
- require_relative 'vagrant/create_command'
5
- require_relative 'vagrant/start_command'
6
- require_relative 'vagrant/stop_command'
7
- require_relative 'vagrant/restart_command'
8
- require_relative 'vagrant/ssh_command'
9
- require_relative 'vagrant/terminate_command'
10
-
11
- class VagrantCommand < Clamp::Command
12
-
13
- subcommand "create", "Create a new Vagrant master", Vagrant::CreateCommand
14
- subcommand "ssh", "SSH into Vagrant master", Vagrant::SshCommand
15
- subcommand "start", "Start Vagrant master", Vagrant::StartCommand
16
- subcommand "stop", "Stop Vagrant master", Vagrant::StopCommand
17
- subcommand "restart", "Restart Vagrant master", Vagrant::RestartCommand
18
- subcommand "terminate", "Terminate Vagrant master", Vagrant::TerminateCommand
19
-
20
- def execute
21
- end
22
- end
23
- end
@@ -1,44 +0,0 @@
1
- module Kontena::Cli::Nodes::Aws
2
- class CreateCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
- include Kontena::Cli::GridOptions
5
-
6
- parameter "[NAME]", "Node name"
7
- option "--access-key", "ACCESS_KEY", "AWS access key ID", required: true
8
- option "--secret-key", "SECRET_KEY", "AWS secret key", required: true
9
- option "--key-pair", "KEY_PAIR", "EC2 Key Pair", required: true
10
- option "--region", "REGION", "EC2 Region", default: 'eu-west-1'
11
- option "--zone", "ZONE", "EC2 Availability Zone", default: 'a'
12
- option "--vpc-id", "VPC ID", "Virtual Private Cloud (VPC) ID (default: default vpc)"
13
- option "--subnet-id", "SUBNET ID", "VPC option to specify subnet to launch instance into (default: first subnet in vpc/az)"
14
- option "--type", "SIZE", "Instance type", default: 't2.small'
15
- option "--storage", "STORAGE", "Storage size (GiB)", default: '30'
16
- option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
17
- option "--associate-public-ip-address", :flag, "Whether to associated public IP in case the VPC defaults to not doing it", default: true, attribute_name: :associate_public_ip
18
- option "--security-groups", "SECURITY GROUPS", "Comma separated list of security groups (names) where the new instance will be attached (default: create grid specific group if not already existing)"
19
-
20
- def execute
21
- require_api_url
22
- require_current_grid
23
-
24
- require 'kontena/machine/aws'
25
- grid = client(require_token).get("grids/#{current_grid}")
26
- provisioner = Kontena::Machine::Aws::NodeProvisioner.new(client(require_token), access_key, secret_key, region)
27
- provisioner.run!(
28
- master_uri: api_url,
29
- grid_token: grid['token'],
30
- grid: current_grid,
31
- name: name,
32
- type: type,
33
- vpc: vpc_id,
34
- zone: zone,
35
- subnet: subnet_id,
36
- storage: storage,
37
- version: version,
38
- key_pair: key_pair,
39
- associate_public_ip: associate_public_ip?,
40
- security_groups: security_groups
41
- )
42
- end
43
- end
44
- end
@@ -1,29 +0,0 @@
1
- module Kontena::Cli::Nodes::Aws
2
- class RestartCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
- include Kontena::Cli::GridOptions
5
-
6
- parameter "NAME", "Node name"
7
- option "--access-key", "ACCESS_KEY", "AWS access key ID", required: true
8
- option "--secret-key", "SECRET_KEY", "AWS secret key", required: true
9
- option "--region", "REGION", "EC2 Region", required: true
10
-
11
- def execute
12
- require_api_url
13
- require_current_grid
14
-
15
- require 'kontena/machine/aws'
16
-
17
- client = Fog::Compute.new(:provider => 'AWS', :aws_access_key_id => access_key, :aws_secret_access_key => secret_key, :region => region)
18
- instance = client.servers.all({'tag:kontena_name' => name}).first
19
- if instance
20
- instance.reboot
21
- ShellSpinner "Restarting AWS instance #{name.colorize(:cyan)} " do
22
- instance.wait_for { ready? }
23
- end
24
- else
25
- abort "Cannot find instance #{name.colorize(:cyan)} in AWS"
26
- end
27
- end
28
- end
29
- end
@@ -1,21 +0,0 @@
1
- module Kontena::Cli::Nodes::Aws
2
- class TerminateCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
- include Kontena::Cli::GridOptions
5
-
6
- parameter "NAME", "Node name"
7
- option "--access-key", "ACCESS_KEY", "AWS access key ID", required: true
8
- option "--secret-key", "SECRET_KEY", "AWS secret key", required: true
9
- option "--region", "REGION", "EC2 Region", default: 'eu-west-1'
10
-
11
- def execute
12
- require_api_url
13
- require_current_grid
14
-
15
- require 'kontena/machine/aws'
16
- grid = client(require_token).get("grids/#{current_grid}")
17
- destroyer = Kontena::Machine::Aws::NodeDestroyer.new(client(require_token), access_key, secret_key, region)
18
- destroyer.run!(grid, name)
19
- end
20
- end
21
- end
@@ -1,15 +0,0 @@
1
- require_relative 'aws/create_command'
2
- require_relative 'aws/terminate_command'
3
- require_relative 'aws/restart_command'
4
-
5
- module Kontena::Cli::Nodes
6
- class AwsCommand < Clamp::Command
7
-
8
- subcommand "create", "Create a new AWS node", Aws::CreateCommand
9
- subcommand "terminate", "Terminate AWS node", Aws::TerminateCommand
10
- subcommand "restart", "Restart AWS node", Aws::RestartCommand
11
-
12
- def execute
13
- end
14
- end
15
- end
@@ -1,38 +0,0 @@
1
- module Kontena::Cli::Nodes::Azure
2
- class CreateCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
- include Kontena::Cli::GridOptions
5
-
6
- option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
7
- option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
8
- option "--size", "SIZE", "SIZE", default: 'Small'
9
- option "--network", "NETWORK", "Virtual Network name"
10
- option "--subnet", "SUBNET", "Subnet name"
11
- option "--ssh-key", "SSH KEY", "SSH private key file", required: true
12
- option "--location", "LOCATION", "Location", default: 'West Europe'
13
- option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
14
-
15
- parameter "[NAME]", "Node name"
16
-
17
- def execute
18
- require_api_url
19
- require_current_grid
20
-
21
- require 'kontena/machine/azure'
22
- grid = client(require_token).get("grids/#{current_grid}")
23
- provisioner = Kontena::Machine::Azure::NodeProvisioner.new(client(require_token), subscription_id, certificate)
24
- provisioner.run!(
25
- master_uri: api_url,
26
- grid_token: grid['token'],
27
- grid: current_grid,
28
- ssh_key: ssh_key,
29
- name: name,
30
- size: size,
31
- virtual_network: network,
32
- subnet: subnet,
33
- location: location,
34
- version: version
35
- )
36
- end
37
- end
38
- end
@@ -1,32 +0,0 @@
1
- module Kontena::Cli::Nodes::Azure
2
- class RestartCommand < Clamp::Command
3
- include Kontena::Cli::Common
4
- include Kontena::Cli::GridOptions
5
-
6
- parameter "NAME", "Node name"
7
- option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
8
- option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true
9
-
10
- def execute
11
- require_api_url
12
- require_current_grid
13
-
14
- require 'kontena/machine/azure'
15
-
16
- client = ::Azure
17
- client.management_certificate = certificate
18
- client.subscription_id = subscription_id
19
-
20
- client.vm_management.initialize_external_logger(Kontena::Machine::Azure::Logger.new) # We don't want all the output
21
- ShellSpinner "Restarting Azure VM #{name.colorize(:cyan)} " do
22
- vm = client.vm_management.get_virtual_machine(name, "kontena-#{current_grid}-#{name}")
23
- if vm
24
- client.vm_management.restart_virtual_machine(name, "kontena-#{current_grid}-#{name}")
25
- else
26
- abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
27
- end
28
- end
29
-
30
- end
31
- end
32
- end