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
@@ -4,11 +4,11 @@ module Kontena::Cli::Apps
|
|
4
4
|
class Validator
|
5
5
|
require_relative 'validations'
|
6
6
|
include Validations
|
7
|
-
|
7
|
+
|
8
8
|
VALID_KEYS = %w(
|
9
9
|
affinity build dockerfile cap_add cap_drop command deploy env_file environment extends external_links
|
10
10
|
image links log_driver log_opt net pid ports volumes volumes_from cpu_shares
|
11
|
-
mem_limit memswap_limit privileged stateful user instances hooks secrets
|
11
|
+
mem_limit memswap_limit privileged stateful user instances hooks secrets health_check
|
12
12
|
).freeze
|
13
13
|
|
14
14
|
UNSUPPORTED_KEYS = %w(
|
@@ -24,12 +24,12 @@ module Kontena::Cli::Apps
|
|
24
24
|
base = self
|
25
25
|
@yaml_schema = Dry::Validation.Schema do
|
26
26
|
base.append_common_validations(self)
|
27
|
-
optional('build').maybe(:str?)
|
28
|
-
optional('dockerfile') { str? }
|
29
|
-
optional('net') { inclusion?(%w(host bridge)) }
|
30
|
-
optional('log_driver') { str? }
|
31
|
-
optional('log_opts') { type?(Hash) }
|
32
27
|
|
28
|
+
optional('build').value(:str?)
|
29
|
+
optional('dockerfile').value(:str?)
|
30
|
+
optional('net').value(included_in?: (%w(host bridge)))
|
31
|
+
optional('log_driver').value(:str?)
|
32
|
+
optional('log_opts').value(type?: Hash)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
@@ -10,7 +10,7 @@ module Kontena::Cli::Apps
|
|
10
10
|
VALID_KEYS = %w(
|
11
11
|
affinity build cap_add cap_drop command deploy depends_on env_file environment extends external_links
|
12
12
|
image links logging network_mode pid ports volumes volumes_from cpu_shares
|
13
|
-
mem_limit memswap_limit privileged stateful user instances hooks secrets
|
13
|
+
mem_limit memswap_limit privileged stateful user instances hooks secrets health_check
|
14
14
|
).freeze
|
15
15
|
|
16
16
|
UNSUPPORTED_KEYS = %w(
|
@@ -30,14 +30,15 @@ module Kontena::Cli::Apps
|
|
30
30
|
|
31
31
|
rule(build_hash: ['build']) do |build|
|
32
32
|
build.type?(Hash) > build.schema do
|
33
|
-
|
34
|
-
optional('dockerfile')
|
33
|
+
required('context').filled
|
34
|
+
optional('dockerfile').value(:str?)
|
35
|
+
optional('args') { array? | type?(Hash) }
|
35
36
|
end
|
36
37
|
end
|
37
|
-
optional('depends_on')
|
38
|
-
optional('network_mode')
|
38
|
+
optional('depends_on').value(:array?)
|
39
|
+
optional('network_mode').value(included_in?: (%w(host bridge)))
|
39
40
|
optional('logging').schema do
|
40
|
-
optional('driver')
|
41
|
+
optional('driver').value(:str?)
|
41
42
|
optional('options') { type?(Hash) }
|
42
43
|
end
|
43
44
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
|
2
|
+
module Kontena::Cli::Certificate
|
3
|
+
class AuthorizeCommand < Clamp::Command
|
4
|
+
include Kontena::Cli::Common
|
5
|
+
include Kontena::Cli::GridOptions
|
6
|
+
|
7
|
+
|
8
|
+
parameter "DOMAIN", "Domain to authorize"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require_api_url
|
12
|
+
token = require_token
|
13
|
+
|
14
|
+
data = {domain: domain}
|
15
|
+
response = client(token).post("certificates/#{current_grid}/authorize", data)
|
16
|
+
puts "Authorization successfully created. Use the following details to create necessary validations:"
|
17
|
+
puts "Record name:#{response['record_name']}"
|
18
|
+
puts "Record type:#{response['record_type']}"
|
19
|
+
puts "Record content:#{response['record_content']}"
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
module Kontena::Cli::Certificate
|
3
|
+
class GetCommand < Clamp::Command
|
4
|
+
include Kontena::Cli::Common
|
5
|
+
include Kontena::Cli::GridOptions
|
6
|
+
|
7
|
+
|
8
|
+
option '--secret-name', 'SECRET_NAME', 'The name for the secret to store the certificate in'
|
9
|
+
parameter "DOMAIN ...", "Domain(s) to get certificate for"
|
10
|
+
|
11
|
+
|
12
|
+
def execute
|
13
|
+
require_api_url
|
14
|
+
token = require_token
|
15
|
+
secret = secret_name || "LE_CERTIFICATE_#{domain_list[0].gsub('.', '_')}"
|
16
|
+
data = {domains: domain_list, secret_name: secret}
|
17
|
+
response = client(token).post("certificates/#{current_grid}/certificate", data)
|
18
|
+
puts "Certificate successfully received and stored into vault with keys:"
|
19
|
+
response.each do |secret|
|
20
|
+
puts secret.colorize(:green)
|
21
|
+
end
|
22
|
+
puts "Use the #{secret}_BUNDLE with Kontena loadbalancer!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
module Kontena::Cli::Certificate
|
3
|
+
class RegisterCommand < Clamp::Command
|
4
|
+
include Kontena::Cli::Common
|
5
|
+
include Kontena::Cli::GridOptions
|
6
|
+
|
7
|
+
|
8
|
+
parameter "EMAIL", "Email to register"
|
9
|
+
|
10
|
+
def execute
|
11
|
+
require_api_url
|
12
|
+
token = require_token
|
13
|
+
|
14
|
+
data = {email: email}
|
15
|
+
response = client(token).post("certificates/#{current_grid}/register", data)
|
16
|
+
puts 'Email registered to LetsEncrypt'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'certificate/register_command'
|
2
|
+
require_relative 'certificate/authorize_command'
|
3
|
+
require_relative 'certificate/get_command'
|
4
|
+
|
5
|
+
class Kontena::Cli::CertificateCommand < Clamp::Command
|
6
|
+
|
7
|
+
|
8
|
+
subcommand "register", "Register to LetsEncrypt", Kontena::Cli::Certificate::RegisterCommand
|
9
|
+
subcommand "authorize", "Create DNS authorization for domain", Kontena::Cli::Certificate::AuthorizeCommand
|
10
|
+
subcommand "get", "Get certificate for domain", Kontena::Cli::Certificate::GetCommand
|
11
|
+
|
12
|
+
def execute
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Kontena
|
2
|
+
module Cli
|
3
|
+
module Containers
|
4
|
+
module ContainersHelper
|
5
|
+
|
6
|
+
# @param [Array<String>] args
|
7
|
+
# @return [String]
|
8
|
+
def build_command(args)
|
9
|
+
return args.first if args.size == 1
|
10
|
+
|
11
|
+
args.reduce('') do |cmd, arg|
|
12
|
+
if arg.include?(' ') || arg.include?('"')
|
13
|
+
arg = '"' + arg.gsub('"', '\\"') + '"'
|
14
|
+
end
|
15
|
+
cmd + ' ' + arg
|
16
|
+
end.strip
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,7 +1,11 @@
|
|
1
|
+
require_relative '../grid_options'
|
2
|
+
require_relative './containers_helper'
|
3
|
+
|
1
4
|
module Kontena::Cli::Containers
|
2
5
|
class ExecCommand < Clamp::Command
|
3
6
|
include Kontena::Cli::Common
|
4
7
|
include Kontena::Cli::GridOptions
|
8
|
+
include ContainersHelper
|
5
9
|
|
6
10
|
parameter "CONTAINER_ID", "Container id"
|
7
11
|
parameter "CMD ...", "Command"
|
@@ -10,9 +14,12 @@ module Kontena::Cli::Containers
|
|
10
14
|
require_api_url
|
11
15
|
token = require_token
|
12
16
|
|
13
|
-
|
14
|
-
|
17
|
+
cmd = build_command(cmd_list)
|
18
|
+
payload = {cmd: ["sh", "-c", cmd]}
|
19
|
+
|
20
|
+
service_name = container_id.match(/(.+)-(\d+)/)[1] rescue nil
|
15
21
|
result = client(token).post("containers/#{current_grid}/#{service_name}/#{container_id}/exec", payload)
|
22
|
+
|
16
23
|
puts result[0].join(" ") unless result[0].size == 0
|
17
24
|
STDERR.puts result[1].join(" ") unless result[1].size == 0
|
18
25
|
exit result[2]
|
@@ -55,14 +55,25 @@ module Kontena::Cli::Grids
|
|
55
55
|
@buffer << chunk
|
56
56
|
end
|
57
57
|
if log
|
58
|
+
@last_seen = log['id']
|
58
59
|
color = color_for_container(log['name'])
|
59
60
|
puts "#{log['name'].colorize(color)} | #{log['data']}"
|
60
61
|
end
|
61
62
|
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
begin
|
65
|
+
if @last_seen
|
66
|
+
query_params[:from] = @last_seen
|
67
|
+
end
|
68
|
+
result = client(token).get_stream(
|
69
|
+
"grids/#{current_grid}/container_logs", streamer, query_params
|
70
|
+
)
|
71
|
+
rescue => exc
|
72
|
+
if exc.cause.is_a?(EOFError) # Excon wraps the EOFerror into SockerError
|
73
|
+
retry
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
66
77
|
end
|
67
78
|
|
68
79
|
def color_for_container(container_id)
|
@@ -1,9 +1,3 @@
|
|
1
|
-
require_relative 'master/vagrant_command'
|
2
|
-
require_relative 'master/aws_command'
|
3
|
-
require_relative 'master/digital_ocean_command'
|
4
|
-
require_relative 'master/packet_command'
|
5
|
-
require_relative 'master/upcloud_command'
|
6
|
-
require_relative 'master/azure_command'
|
7
1
|
require_relative 'master/use_command'
|
8
2
|
require_relative 'master/list_command'
|
9
3
|
require_relative 'master/users_command'
|
@@ -11,16 +5,11 @@ require_relative 'master/current_command'
|
|
11
5
|
|
12
6
|
class Kontena::Cli::MasterCommand < Clamp::Command
|
13
7
|
|
14
|
-
subcommand "vagrant", "Vagrant specific commands", Kontena::Cli::Master::VagrantCommand
|
15
|
-
subcommand "aws", "AWS specific commands", Kontena::Cli::Master::AwsCommand
|
16
|
-
subcommand "digitalocean", "DigitalOcean specific commands", Kontena::Cli::Master::DigitalOceanCommand
|
17
|
-
subcommand "packet", "Packet specific commands", Kontena::Cli::Master::PacketCommand
|
18
|
-
subcommand "upcloud", "Upcloud specific commands", Kontena::Cli::Master::UpcloudCommand
|
19
|
-
subcommand "azure", "Azure specific commands", Kontena::Cli::Master::AzureCommand
|
20
8
|
subcommand ["list", "ls"], "List masters where client has logged in", Kontena::Cli::Master::ListCommand
|
21
9
|
subcommand "use", "Switch to use selected master", Kontena::Cli::Master::UseCommand
|
22
10
|
subcommand "users", "Users specific commands", Kontena::Cli::Master::UsersCommand
|
23
11
|
subcommand "current", "Show current master details", Kontena::Cli::Master::CurrentCommand
|
12
|
+
|
24
13
|
def execute
|
25
14
|
end
|
26
15
|
end
|
@@ -3,16 +3,8 @@ require_relative 'nodes/remove_command'
|
|
3
3
|
require_relative 'nodes/show_command'
|
4
4
|
require_relative 'nodes/update_command'
|
5
5
|
require_relative 'nodes/ssh_command'
|
6
|
-
|
7
6
|
require_relative 'nodes/label_command'
|
8
7
|
|
9
|
-
require_relative 'nodes/vagrant_command'
|
10
|
-
require_relative 'nodes/digital_ocean_command'
|
11
|
-
require_relative 'nodes/packet_command'
|
12
|
-
require_relative 'nodes/upcloud_command'
|
13
|
-
require_relative 'nodes/aws_command'
|
14
|
-
require_relative 'nodes/azure_command'
|
15
|
-
|
16
8
|
class Kontena::Cli::NodeCommand < Clamp::Command
|
17
9
|
|
18
10
|
subcommand ["list","ls"], "List grid nodes", Kontena::Cli::Nodes::ListCommand
|
@@ -20,16 +12,8 @@ class Kontena::Cli::NodeCommand < Clamp::Command
|
|
20
12
|
subcommand "ssh", "Ssh into node", Kontena::Cli::Nodes::SshCommand
|
21
13
|
subcommand "update", "Update node", Kontena::Cli::Nodes::UpdateCommand
|
22
14
|
subcommand ["remove","rm"], "Remove node", Kontena::Cli::Nodes::RemoveCommand
|
23
|
-
|
24
15
|
subcommand "label", "Node label specific commands", Kontena::Cli::Nodes::LabelCommand
|
25
16
|
|
26
|
-
subcommand "vagrant", "Vagrant specific commands", Kontena::Cli::Nodes::VagrantCommand
|
27
|
-
subcommand "digitalocean", "DigitalOcean specific commands", Kontena::Cli::Nodes::DigitalOceanCommand
|
28
|
-
subcommand "packet", "Packet specific commands", Kontena::Cli::Nodes::PacketCommand
|
29
|
-
subcommand "upcloud", "Upcloud specific commands", Kontena::Cli::Nodes::UpcloudCommand
|
30
|
-
subcommand "aws", "AWS specific commands", Kontena::Cli::Nodes::AwsCommand
|
31
|
-
subcommand "azure", "Azure specific commands", Kontena::Cli::Nodes::AzureCommand
|
32
|
-
|
33
17
|
def execute
|
34
18
|
end
|
35
19
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative 'plugins/list_command'
|
2
|
+
require_relative 'plugins/search_command'
|
3
|
+
require_relative 'plugins/install_command'
|
4
|
+
require_relative 'plugins/uninstall_command'
|
5
|
+
|
6
|
+
class Kontena::Cli::PluginCommand < Clamp::Command
|
7
|
+
|
8
|
+
subcommand ["list","ls"], "List plugins", Kontena::Cli::Plugins::ListCommand
|
9
|
+
subcommand "search", "Search plugins", Kontena::Cli::Plugins::SearchCommand
|
10
|
+
subcommand "install", "Install a plugin", Kontena::Cli::Plugins::InstallCommand
|
11
|
+
subcommand "uninstall", "Uninstall a plugin", Kontena::Cli::Plugins::UninstallCommand
|
12
|
+
|
13
|
+
def execute
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Kontena::Cli::Plugins
|
4
|
+
class InstallCommand < Clamp::Command
|
5
|
+
include Kontena::Util
|
6
|
+
|
7
|
+
parameter 'NAME', 'Plugin name'
|
8
|
+
|
9
|
+
def execute
|
10
|
+
install_plugin(name)
|
11
|
+
end
|
12
|
+
|
13
|
+
def install_plugin(name)
|
14
|
+
plugin = "kontena-plugin-#{name}"
|
15
|
+
gem_bin = which('gem')
|
16
|
+
install_command = "#{gem_bin} install --no-ri --no-doc #{plugin}"
|
17
|
+
success = false
|
18
|
+
ShellSpinner "Installing plugin #{name.colorize(:cyan)}" do
|
19
|
+
stdout, stderr, status = Open3.capture3(install_command)
|
20
|
+
unless stderr.empty?
|
21
|
+
raise stderr
|
22
|
+
end
|
23
|
+
end
|
24
|
+
rescue => exc
|
25
|
+
puts exc.message
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
module Kontena::Cli::Plugins
|
3
|
+
class ListCommand < Clamp::Command
|
4
|
+
|
5
|
+
def execute
|
6
|
+
titles = ['NAME', 'VERSION', 'DESCRIPTION']
|
7
|
+
puts "%-40s %-10s %-40s" % titles
|
8
|
+
Kontena::PluginManager.instance.plugins.each do |plugin|
|
9
|
+
puts "%-40s %-10s %-40s" % [plugin.name, plugin.version, plugin.description]
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Kontena::Cli::Plugins
|
2
|
+
class SearchCommand < Clamp::Command
|
3
|
+
|
4
|
+
parameter '[NAME]', 'Search text'
|
5
|
+
|
6
|
+
def execute
|
7
|
+
results = fetch_plugins(name)
|
8
|
+
abort("Cannot access plugin server") unless results
|
9
|
+
puts "%-50s %-10s %-60s" % ['NAME', 'VERSION', 'DESCRIPTION']
|
10
|
+
results.each do |item|
|
11
|
+
name = item['name'].sub('kontena-plugin-', '')
|
12
|
+
puts "%-50s %-10s %-60s" % [name, item['version'], item['info']]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch_plugins(name)
|
17
|
+
client = Excon.new('https://rubygems.org')
|
18
|
+
response = client.get(
|
19
|
+
path: "/api/v1/search.json?query=kontena-plugin-#{name}",
|
20
|
+
headers: {
|
21
|
+
'Content-Type' => 'application/json',
|
22
|
+
'Accept' => 'application/json'
|
23
|
+
}
|
24
|
+
)
|
25
|
+
|
26
|
+
JSON.parse(response.body) rescue nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Kontena::Cli::Plugins
|
4
|
+
class UninstallCommand < Clamp::Command
|
5
|
+
include Kontena::Cli::Common
|
6
|
+
|
7
|
+
parameter 'NAME', 'Plugin name'
|
8
|
+
option "--force", :flag, "Force remove", default: false, attribute_name: :forced
|
9
|
+
|
10
|
+
def execute
|
11
|
+
confirm unless forced?
|
12
|
+
uninstall_plugin(name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def uninstall_plugin(name)
|
16
|
+
plugin = "kontena-plugin-#{name}"
|
17
|
+
gem_bin = `which gem`.strip
|
18
|
+
install_command = "#{gem_bin} install -q #{plugin}"
|
19
|
+
success = false
|
20
|
+
ShellSpinner "Uninstalling plugin #{name.colorize(:cyan)}" do
|
21
|
+
stdout, stderr, status = Open3.capture3(install_command)
|
22
|
+
unless stderr.empty?
|
23
|
+
raise stderr
|
24
|
+
end
|
25
|
+
end
|
26
|
+
rescue => exc
|
27
|
+
puts exc.message
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -55,7 +55,7 @@ module Kontena::Cli::Registry
|
|
55
55
|
env = [
|
56
56
|
"REGISTRY_STORAGE=azure",
|
57
57
|
"REGISTRY_STORAGE_AZURE_ACCOUNTNAME=#{azure_account_name}",
|
58
|
-
"
|
58
|
+
"REGISTRY_STORAGE_AZURE_CONTAINER=#{azure_container_name}"
|
59
59
|
]
|
60
60
|
secrets = [
|
61
61
|
{secret: 'REGISTRY_STORAGE_AZURE_ACCOUNTKEY', name: 'REGISTRY_STORAGE_AZURE_ACCOUNTKEY', type: 'env'}
|
@@ -34,6 +34,12 @@ module Kontena::Cli::Services
|
|
34
34
|
option "--deploy-interval", "TIME", "Auto-deploy with given interval (format: <number><unit>, where unit = min, h, d)"
|
35
35
|
option "--pid", "PID", "Pid namespace to use"
|
36
36
|
option "--secret", "SECRET", "Import secret from Vault (format: <secret>:<name>:<env>)", multivalued: true
|
37
|
+
option "--health-check-uri", "HEALTH CHECK URI", "URI path for HTTP health check"
|
38
|
+
option "--health-check-timeout", "HEALTH CHECK TIMEOUT", "Timeout for health check"
|
39
|
+
option "--health-check-interval", "HEALTH CHECK INTERVAL", "Interval for health check"
|
40
|
+
option "--health-check-initial-delay", "HEALTH CHECK INITIAL DELAY", "Initial delay for health check"
|
41
|
+
option "--health-check-port", "HEALTH CHECK PORT", "Port for health check"
|
42
|
+
option "--health-check-protocol", "HEALTH CHECK PROTOCOL", "Protocol of health check"
|
37
43
|
|
38
44
|
def execute
|
39
45
|
require_api_url
|
@@ -83,6 +89,16 @@ module Kontena::Cli::Services
|
|
83
89
|
if deploy_interval
|
84
90
|
data[:deploy_opts][:interval] = parse_relative_time(deploy_interval)
|
85
91
|
end
|
92
|
+
if health_check_port
|
93
|
+
data[:health_check] = {
|
94
|
+
protocol: health_check_protocol,
|
95
|
+
uri: health_check_uri,
|
96
|
+
port: health_check_port,
|
97
|
+
timeout: health_check_timeout,
|
98
|
+
interval: health_check_interval,
|
99
|
+
initial_delay: health_check_initial_delay
|
100
|
+
}
|
101
|
+
end
|
86
102
|
data[:pid] = pid if pid
|
87
103
|
data
|
88
104
|
end
|