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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/kontena +64 -2
- data/kontena-cli.gemspec +4 -2
- data/lib/kontena/cli/app_command.rb +20 -0
- data/lib/kontena/cli/apps/common.rb +53 -0
- data/lib/kontena/cli/{stacks/stacks.rb → apps/deploy_command.rb} +17 -31
- data/lib/kontena/cli/apps/init_command.rb +101 -0
- data/lib/kontena/cli/apps/list_command.rb +41 -0
- data/lib/kontena/cli/apps/logs_command.rb +58 -0
- data/lib/kontena/cli/apps/remove_command.rb +64 -0
- data/lib/kontena/cli/apps/start_command.rb +38 -0
- data/lib/kontena/cli/apps/stop_command.rb +38 -0
- data/lib/kontena/cli/container_command.rb +9 -0
- data/lib/kontena/cli/containers/{containers.rb → exec_command.rb} +5 -5
- data/lib/kontena/cli/deploy_command.rb +159 -0
- data/lib/kontena/cli/external_registries/add_command.rb +22 -0
- data/lib/kontena/cli/external_registries/delete_command.rb +13 -0
- data/lib/kontena/cli/external_registries/list_command.rb +16 -0
- data/lib/kontena/cli/external_registry_command.rb +14 -0
- data/lib/kontena/cli/forgot_password_command.rb +13 -0
- data/lib/kontena/cli/grid_command.rb +27 -0
- data/lib/kontena/cli/grids/add_user_command.rb +17 -0
- data/lib/kontena/cli/grids/{audit_log.rb → audit_log_command.rb} +7 -6
- data/lib/kontena/cli/grids/common.rb +24 -0
- data/lib/kontena/cli/grids/create_command.rb +26 -0
- data/lib/kontena/cli/grids/current_command.rb +18 -0
- data/lib/kontena/cli/grids/list_command.rb +26 -0
- data/lib/kontena/cli/grids/list_users_command.rb +18 -0
- data/lib/kontena/cli/grids/remove_command.rb +26 -0
- data/lib/kontena/cli/grids/remove_user_command.rb +16 -0
- data/lib/kontena/cli/grids/show_command.rb +19 -0
- data/lib/kontena/cli/grids/use_command.rb +21 -0
- data/lib/kontena/cli/invite_command.rb +13 -0
- data/lib/kontena/cli/login_command.rb +114 -0
- data/lib/kontena/cli/logout_command.rb +8 -0
- data/lib/kontena/cli/node_command.rb +21 -0
- data/lib/kontena/cli/nodes/digital_ocean/create_command.rb +31 -0
- data/lib/kontena/cli/nodes/digital_ocean/restart_command.rb +26 -0
- data/lib/kontena/cli/nodes/digital_ocean/terminate_command.rb +18 -0
- data/lib/kontena/cli/nodes/digital_ocean_command.rb +15 -0
- data/lib/kontena/cli/nodes/list_command.rb +28 -0
- data/lib/kontena/cli/nodes/remove_command.rb +15 -0
- data/lib/kontena/cli/nodes/show_command.rb +31 -0
- data/lib/kontena/cli/nodes/update_command.rb +18 -0
- data/lib/kontena/cli/nodes/vagrant/create_command.rb +26 -0
- data/lib/kontena/cli/nodes/vagrant/restart_command.rb +25 -0
- data/lib/kontena/cli/nodes/vagrant/ssh_command.rb +20 -0
- data/lib/kontena/cli/nodes/vagrant/start_command.rb +25 -0
- data/lib/kontena/cli/nodes/vagrant/stop_command.rb +25 -0
- data/lib/kontena/cli/nodes/vagrant/terminate_command.rb +16 -0
- data/lib/kontena/cli/nodes/vagrant_command.rb +21 -0
- data/lib/kontena/cli/register_command.rb +21 -0
- data/lib/kontena/cli/{grids/registry.rb → registry/create_command.rb} +32 -35
- data/lib/kontena/cli/registry/delete_command.rb +15 -0
- data/lib/kontena/cli/registry_command.rb +11 -0
- data/lib/kontena/cli/reset_password_command.rb +17 -0
- data/lib/kontena/cli/service_command.rb +33 -0
- data/lib/kontena/cli/services/container_command.rb +9 -0
- data/lib/kontena/cli/services/containers_command.rb +31 -0
- data/lib/kontena/cli/services/create_command.rb +62 -0
- data/lib/kontena/cli/services/delete_command.rb +17 -0
- data/lib/kontena/cli/services/deploy_command.rb +23 -0
- data/lib/kontena/cli/services/list_command.rb +20 -0
- data/lib/kontena/cli/services/logs_command.rb +51 -0
- data/lib/kontena/cli/services/restart_command.rb +16 -0
- data/lib/kontena/cli/services/scale_command.rb +20 -0
- data/lib/kontena/cli/services/services_helper.rb +94 -0
- data/lib/kontena/cli/services/show_command.rb +17 -0
- data/lib/kontena/cli/services/start_command.rb +16 -0
- data/lib/kontena/cli/services/{stats.rb → stats_command.rb} +11 -10
- data/lib/kontena/cli/services/stop_command.rb +16 -0
- data/lib/kontena/cli/services/update_command.rb +51 -0
- data/lib/kontena/cli/verify_account_command.rb +13 -0
- data/lib/kontena/cli/version_command.rb +8 -0
- data/lib/kontena/cli/vpn/config_command.rb +12 -0
- data/lib/kontena/cli/{grids/vpn.rb → vpn/create_command.rb} +12 -29
- data/lib/kontena/cli/vpn/delete_command.rb +15 -0
- data/lib/kontena/cli/vpn_command.rb +13 -0
- data/lib/kontena/cli/whoami_command.rb +19 -0
- data/lib/kontena/client.rb +14 -11
- data/lib/kontena/machine/common.rb +17 -0
- data/lib/kontena/machine/digital_ocean.rb +11 -0
- data/lib/kontena/machine/digital_ocean/cloudinit.yml +66 -0
- data/lib/kontena/machine/digital_ocean/node_destroyer.rb +38 -0
- data/lib/kontena/machine/digital_ocean/node_provisioner.rb +74 -0
- data/lib/kontena/machine/random_name.rb +42 -0
- data/lib/kontena/machine/vagrant.rb +10 -0
- data/lib/kontena/machine/vagrant/Vagrantfile.coreos.rb.erb +32 -0
- data/lib/kontena/machine/vagrant/cloudinit.yml +65 -0
- data/lib/kontena/machine/vagrant/node_destroyer.rb +36 -0
- data/lib/kontena/machine/vagrant/node_provisioner.rb +68 -0
- data/lib/kontena/scripts/completer +5 -5
- data/spec/kontena/cli/app/deploy_command_spec.rb +227 -0
- data/spec/kontena/cli/deploy_command_spec.rb +213 -0
- data/spec/kontena/cli/login_command_spec.rb +22 -0
- data/spec/kontena/cli/register_command_spec.rb +57 -0
- data/spec/spec_helper.rb +5 -1
- metadata +132 -36
- data/lib/kontena/cli/commands.rb +0 -20
- data/lib/kontena/cli/containers/commands.rb +0 -12
- data/lib/kontena/cli/grids/commands.rb +0 -169
- data/lib/kontena/cli/grids/external_registries.rb +0 -40
- data/lib/kontena/cli/grids/grids.rb +0 -108
- data/lib/kontena/cli/grids/users.rb +0 -32
- data/lib/kontena/cli/nodes/commands.rb +0 -27
- data/lib/kontena/cli/nodes/nodes.rb +0 -64
- data/lib/kontena/cli/server/commands.rb +0 -69
- data/lib/kontena/cli/server/server.rb +0 -45
- data/lib/kontena/cli/server/user.rb +0 -174
- data/lib/kontena/cli/services/commands.rb +0 -138
- data/lib/kontena/cli/services/containers.rb +0 -24
- data/lib/kontena/cli/services/logs.rb +0 -44
- data/lib/kontena/cli/services/services.rb +0 -175
- data/lib/kontena/cli/stacks/commands.rb +0 -13
- data/spec/kontena/cli/server/user_spec.rb +0 -59
- data/spec/kontena/cli/stacks/stacks_spec.rb +0 -212
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
module Kontena::Cli::Server; end;
|
|
2
|
-
|
|
3
|
-
require_relative 'server'
|
|
4
|
-
require_relative 'user'
|
|
5
|
-
|
|
6
|
-
command 'login' do |c|
|
|
7
|
-
c.syntax = 'kontena login'
|
|
8
|
-
c.description = 'Login to Kontena server'
|
|
9
|
-
c.action do |args, options|
|
|
10
|
-
Kontena::Cli::Server::User.new.login(args[0])
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
command 'logout' do |c|
|
|
15
|
-
c.syntax = 'kontena logout'
|
|
16
|
-
c.description = 'Logout from Kontena server'
|
|
17
|
-
c.action do |args, options|
|
|
18
|
-
Kontena::Cli::Server::User.new.logout
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
command 'whoami' do |c|
|
|
23
|
-
c.syntax = 'kontena whoami'
|
|
24
|
-
c.description = 'Display your Kontena email address and server url'
|
|
25
|
-
c.option '--bash-completion-path'
|
|
26
|
-
c.action do |args, options|
|
|
27
|
-
Kontena::Cli::Server::User.new.whoami(options)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
command 'register' do |c|
|
|
32
|
-
c.syntax = 'kontena register'
|
|
33
|
-
c.description = 'Register Kontena account. URL of auth provider can be given optionally.'
|
|
34
|
-
c.action do |args, options|
|
|
35
|
-
Kontena::Cli::Server::User.new.register(args[0], options)
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
command 'verify account' do |c|
|
|
40
|
-
c.syntax = 'kontena verify account <token>'
|
|
41
|
-
c.description = 'Verify Kontena.io account'
|
|
42
|
-
c.action do |args, options|
|
|
43
|
-
Kontena::Cli::Server::User.new.verify_account(args[0])
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
command 'invite' do |c|
|
|
48
|
-
c.syntax = 'kontena invite <email>'
|
|
49
|
-
c.description = 'Invite user to Kontena server'
|
|
50
|
-
c.action do |args, options|
|
|
51
|
-
Kontena::Cli::Server::User.new.invite(args[0])
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
command 'forgot password' do |c|
|
|
56
|
-
c.syntax = 'kontena forgot password <email>'
|
|
57
|
-
c.description = 'Request password reset for Kontena account'
|
|
58
|
-
c.action do |args, options|
|
|
59
|
-
Kontena::Cli::Server::User.new.request_password_reset(args[0])
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
command 'reset password' do |c|
|
|
64
|
-
c.syntax = 'kontena reset password <token>'
|
|
65
|
-
c.description = 'Reset Kontena password'
|
|
66
|
-
c.action do |args, options|
|
|
67
|
-
Kontena::Cli::Server::User.new.reset_password(args[0])
|
|
68
|
-
end
|
|
69
|
-
end
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require 'kontena/client'
|
|
2
|
-
require_relative '../common'
|
|
3
|
-
|
|
4
|
-
module Kontena::Cli::Server
|
|
5
|
-
class Server
|
|
6
|
-
include Kontena::Cli::Common
|
|
7
|
-
|
|
8
|
-
def connect(api_url = nil, options)
|
|
9
|
-
until !api_url.nil? && !api_url.empty?
|
|
10
|
-
api_url = ask('Kontena server url: ')
|
|
11
|
-
end
|
|
12
|
-
settings['server']['url'] = api_url
|
|
13
|
-
save_settings
|
|
14
|
-
|
|
15
|
-
sleep 0.1
|
|
16
|
-
if client.get('ping') # test server connection
|
|
17
|
-
display_logo
|
|
18
|
-
else
|
|
19
|
-
print color('Could not connect to server', :red)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def disconnect
|
|
25
|
-
settings['server'].delete('url')
|
|
26
|
-
save_settings
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
def display_logo
|
|
31
|
-
logo = <<LOGO
|
|
32
|
-
_ _
|
|
33
|
-
| | _____ _ __ | |_ ___ _ __ __ _
|
|
34
|
-
| |/ / _ \\| '_ \\| __/ _ \\ '_ \\ / _` |
|
|
35
|
-
| < (_) | | | | || __/ | | | (_| |
|
|
36
|
-
|_|\\_\\___/|_| |_|\\__\\___|_| |_|\\__,_|
|
|
37
|
-
-------------------------------------
|
|
38
|
-
Copyright (c)2015 Kontena, Inc.
|
|
39
|
-
|
|
40
|
-
LOGO
|
|
41
|
-
puts logo
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
end
|
|
45
|
-
end
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
require 'kontena/client'
|
|
2
|
-
require_relative '../common'
|
|
3
|
-
|
|
4
|
-
module Kontena::Cli::Server
|
|
5
|
-
class User
|
|
6
|
-
include Kontena::Cli::Common
|
|
7
|
-
|
|
8
|
-
def login(api_url = nil)
|
|
9
|
-
until !api_url.nil? && !api_url.empty?
|
|
10
|
-
api_url = ask('Kontena Master Node URL: ')
|
|
11
|
-
end
|
|
12
|
-
update_api_url(api_url)
|
|
13
|
-
|
|
14
|
-
unless request_server_info
|
|
15
|
-
print color('Could not connect to server', :red)
|
|
16
|
-
return false
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
email = ask("Email: ")
|
|
20
|
-
password = password("Password: ")
|
|
21
|
-
response = do_login(email, password)
|
|
22
|
-
|
|
23
|
-
if response
|
|
24
|
-
update_access_token(response['access_token'])
|
|
25
|
-
display_logo
|
|
26
|
-
puts "Welcome #{response['user']['name'].green}"
|
|
27
|
-
puts ''
|
|
28
|
-
reset_client
|
|
29
|
-
grid = client(require_token).get('grids')['grids'][0]
|
|
30
|
-
if grid
|
|
31
|
-
self.current_grid = grid
|
|
32
|
-
puts "Using grid: #{grid['name'].cyan}"
|
|
33
|
-
else
|
|
34
|
-
clear_current_grid
|
|
35
|
-
end
|
|
36
|
-
true
|
|
37
|
-
else
|
|
38
|
-
print color('Login Failed', :red)
|
|
39
|
-
false
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
def logout
|
|
44
|
-
settings['server'].delete('token')
|
|
45
|
-
save_settings
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def whoami(options)
|
|
49
|
-
if options.bash_completion_path
|
|
50
|
-
puts File.realpath(File.join(__dir__, '../../scripts/init'))
|
|
51
|
-
exit 0
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
require_api_url
|
|
55
|
-
puts "Master: #{settings['server']['url']}"
|
|
56
|
-
token = require_token
|
|
57
|
-
response = client(token).get('user')
|
|
58
|
-
puts "User: #{response['email']}"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def invite(email)
|
|
62
|
-
require_api_url
|
|
63
|
-
token = require_token
|
|
64
|
-
data = { email: email }
|
|
65
|
-
response = client(token).post('users', data)
|
|
66
|
-
puts 'User invited' if response
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def register(api_url = nil, options)
|
|
70
|
-
auth_api_url = api_url || 'https://auth.kontena.io'
|
|
71
|
-
if !auth_api_url.start_with?('http://') && !auth_api_url.start_with?('https://')
|
|
72
|
-
auth_api_url = "https://#{auth_api_url}"
|
|
73
|
-
end
|
|
74
|
-
email = ask("Email: ")
|
|
75
|
-
password = password("Password: ")
|
|
76
|
-
password2 = password("Password again: ")
|
|
77
|
-
if password != password2
|
|
78
|
-
raise ArgumentError.new("Passwords don't match")
|
|
79
|
-
end
|
|
80
|
-
params = {email: email, password: password}
|
|
81
|
-
auth_client = Kontena::Client.new(auth_api_url)
|
|
82
|
-
auth_client.post('users', params)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def verify_account(token)
|
|
86
|
-
require_api_url
|
|
87
|
-
|
|
88
|
-
params = {token: token}
|
|
89
|
-
client.post('user/email_confirm', params)
|
|
90
|
-
print color('Account verified', :green)
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def request_password_reset(email)
|
|
94
|
-
require_api_url
|
|
95
|
-
|
|
96
|
-
params = {email: email}
|
|
97
|
-
client.post('user/password_reset', params)
|
|
98
|
-
puts 'Email with password reset instructions is sent to your email address. Please follow the instructions to change your password.'
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def reset_password(token)
|
|
102
|
-
require_api_url
|
|
103
|
-
password = password("Password: ")
|
|
104
|
-
password2 = password("Password again: ")
|
|
105
|
-
if password != password2
|
|
106
|
-
raise ArgumentError.new("Passwords don't match")
|
|
107
|
-
end
|
|
108
|
-
params = {token: token, password: password}
|
|
109
|
-
client.put('user/password_reset', params)
|
|
110
|
-
puts 'Password is now changed. To login with the new password, please run: kontena login'
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
private
|
|
114
|
-
|
|
115
|
-
def token
|
|
116
|
-
@token ||= require_token
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
def do_login(email, password)
|
|
120
|
-
params = {
|
|
121
|
-
username: email,
|
|
122
|
-
password: password,
|
|
123
|
-
grant_type: 'password',
|
|
124
|
-
scope: 'user'
|
|
125
|
-
}
|
|
126
|
-
client.post('auth', params)
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def request_server_info
|
|
130
|
-
valid = true
|
|
131
|
-
begin
|
|
132
|
-
client.get('ping') # test server connection
|
|
133
|
-
rescue OpenSSL::SSL::SSLError => _
|
|
134
|
-
raise 'Could not connect to server because of SSL problem. If you want to ignore SSL errors, set SSL_IGNORE_ERRORS=true environment variable'
|
|
135
|
-
rescue => exc
|
|
136
|
-
valid = false
|
|
137
|
-
end
|
|
138
|
-
valid
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
##
|
|
142
|
-
# Store access token to config file
|
|
143
|
-
#
|
|
144
|
-
# @param [String] access_token
|
|
145
|
-
def update_access_token(access_token)
|
|
146
|
-
settings['server']['token'] = access_token
|
|
147
|
-
save_settings
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
##
|
|
151
|
-
# Store api_url to config file
|
|
152
|
-
#
|
|
153
|
-
# @param [String] api_url
|
|
154
|
-
def update_api_url(api_url)
|
|
155
|
-
settings['server']['url'] = api_url
|
|
156
|
-
save_settings
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def display_logo
|
|
160
|
-
logo = <<LOGO
|
|
161
|
-
_ _
|
|
162
|
-
| | _____ _ __ | |_ ___ _ __ __ _
|
|
163
|
-
| |/ / _ \\| '_ \\| __/ _ \\ '_ \\ / _` |
|
|
164
|
-
| < (_) | | | | || __/ | | | (_| |
|
|
165
|
-
|_|\\_\\___/|_| |_|\\__\\___|_| |_|\\__,_|
|
|
166
|
-
-------------------------------------
|
|
167
|
-
Copyright (c)2015 Kontena, Inc.
|
|
168
|
-
|
|
169
|
-
LOGO
|
|
170
|
-
puts logo
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
end
|
|
174
|
-
end
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
module Kontena::Cli::Services; end;
|
|
2
|
-
|
|
3
|
-
require_relative 'containers'
|
|
4
|
-
require_relative 'logs'
|
|
5
|
-
require_relative 'services'
|
|
6
|
-
require_relative 'stats'
|
|
7
|
-
|
|
8
|
-
command 'service list' do |c|
|
|
9
|
-
c.syntax = 'kontena service list'
|
|
10
|
-
c.description = 'List all services'
|
|
11
|
-
c.action do |args, options|
|
|
12
|
-
Kontena::Cli::Services::Services.new.list
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
command 'service show' do |c|
|
|
17
|
-
c.syntax = 'kontena service show <service_id>'
|
|
18
|
-
c.description = 'Show service details'
|
|
19
|
-
c.action do |args, options|
|
|
20
|
-
Kontena::Cli::Services::Services.new.show(args[0])
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
command 'service deploy' do |c|
|
|
25
|
-
c.syntax = 'kontena service deploy <service_id>'
|
|
26
|
-
c.description = 'Deploy service to nodes'
|
|
27
|
-
c.option '--strategy String', String, 'Define deploy strategy (ha / random)'
|
|
28
|
-
c.option '--wait-for-port String', String, 'Wait for given container port before deploying next container'
|
|
29
|
-
c.action do |args, options|
|
|
30
|
-
Kontena::Cli::Services::Services.new.deploy(args[0], options)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
command 'service restart' do |c|
|
|
35
|
-
c.syntax = 'kontena service restart <service_id>'
|
|
36
|
-
c.description = 'Restart service containers'
|
|
37
|
-
c.action do |args, options|
|
|
38
|
-
Kontena::Cli::Services::Services.new.restart(args[0])
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
command 'service stop' do |c|
|
|
43
|
-
c.syntax = 'kontena service stop <service_id>'
|
|
44
|
-
c.description = 'Stop service containers'
|
|
45
|
-
c.action do |args, options|
|
|
46
|
-
Kontena::Cli::Services::Services.new.stop(args[0])
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
command 'service start' do |c|
|
|
51
|
-
c.syntax = 'kontena service start <service_id>'
|
|
52
|
-
c.description = 'Start service containers'
|
|
53
|
-
c.action do |args, options|
|
|
54
|
-
Kontena::Cli::Services::Services.new.start(args[0])
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
command 'service create' do |c|
|
|
59
|
-
c.syntax = 'kontena service create <name> <image>'
|
|
60
|
-
c.description = 'Create new service'
|
|
61
|
-
c.option '-p', '--ports Array', Array, 'Publish a service\'s port to the host'
|
|
62
|
-
c.option '-e', '--env Array', Array, 'Set environment variables'
|
|
63
|
-
c.option '-l', '--link Array', Array, 'Add link to another service in the form of name:alias'
|
|
64
|
-
c.option '-v', '--volume Array', Array, 'Mount a volume'
|
|
65
|
-
c.option '--volumes_from Array', Array, 'Mount volumes from another container'
|
|
66
|
-
c.option '-a', '--affinity Array', Array, 'Set service affinity'
|
|
67
|
-
c.option '-c', '--cpu-shares INTEGER', Integer, 'CPU shares (relative weight)'
|
|
68
|
-
c.option '-m', '--memory INTEGER', String, 'Memory limit (format: <number><optional unit>, where unit = b, k, m or g)'
|
|
69
|
-
c.option '--memory-swap INTEGER', String, 'Total memory usage (memory + swap), set \'-1\' to disable swap (format: <number><optional unit>, where unit = b, k, m or g)'
|
|
70
|
-
c.option '--cmd STRING', String, 'Command to execute'
|
|
71
|
-
c.option '--instances INTEGER', Integer, 'How many instances should be deployed'
|
|
72
|
-
c.option '-u', '--user String', String, 'Username who executes first process inside container'
|
|
73
|
-
c.option '--stateful', 'Set service as stateful'
|
|
74
|
-
c.option '--cap-add Array', Array, 'Add capabilities'
|
|
75
|
-
c.option '--cap-drop Array', Array, 'Drop capabilities'
|
|
76
|
-
|
|
77
|
-
c.action do |args, options|
|
|
78
|
-
Kontena::Cli::Services::Services.new.create(args[0], args[1], options)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
command 'service update' do |c|
|
|
83
|
-
c.syntax = 'kontena service update <service_id>'
|
|
84
|
-
c.description = 'Update service'
|
|
85
|
-
c.option '-p', '--ports Array', Array, 'Exposed ports'
|
|
86
|
-
c.option '-e', '--env Array', Array, 'Environment variables separated with commas'
|
|
87
|
-
c.option '--image STRING', String, 'Service image'
|
|
88
|
-
c.option '--instances INTEGER', Integer, 'How many instances should be deployed'
|
|
89
|
-
c.option '--cmd STRING', String, 'Command to execute'
|
|
90
|
-
c.option '--cap-add Array', Array, 'Add capabilities'
|
|
91
|
-
c.option '--cap-drop Array', Array, 'Drop capabilities'
|
|
92
|
-
c.action do |args, options|
|
|
93
|
-
Kontena::Cli::Services::Services.new.update(args[0], options)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
command 'service scale' do |c|
|
|
98
|
-
c.syntax = 'kontena service scale <service_id> <instances>'
|
|
99
|
-
c.description = 'Scale service horizontally'
|
|
100
|
-
c.option '--strategy String', String, 'Define deploy strategy (ha / random)'
|
|
101
|
-
c.action do |args, options|
|
|
102
|
-
Kontena::Cli::Services::Services.new.scale(args[0], args[1], options)
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
command 'service delete' do |c|
|
|
107
|
-
c.syntax = 'kontena service delete <service_id>'
|
|
108
|
-
c.description = 'Delete service'
|
|
109
|
-
c.action do |args, options|
|
|
110
|
-
Kontena::Cli::Services::Services.new.destroy(args[0])
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
command 'service containers' do |c|
|
|
115
|
-
c.syntax = 'kontena service containers <service_id>'
|
|
116
|
-
c.description = 'Show service containers'
|
|
117
|
-
c.action do |args, options|
|
|
118
|
-
Kontena::Cli::Services::Containers.new.list(args[0])
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
command 'service logs' do |c|
|
|
123
|
-
c.syntax = 'kontena service logs <service_id>'
|
|
124
|
-
c.description = 'Show service logs'
|
|
125
|
-
c.option '-f', '--follow', 'Follow logs in real time'
|
|
126
|
-
c.action do |args, options|
|
|
127
|
-
Kontena::Cli::Services::Logs.new.show(args[0], options)
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
command 'service stats' do |c|
|
|
132
|
-
c.syntax = 'kontena service stats <name>'
|
|
133
|
-
c.description = 'Show service stats'
|
|
134
|
-
c.option '-f', '--follow', 'Follow stats in real time'
|
|
135
|
-
c.action do |args, options|
|
|
136
|
-
Kontena::Cli::Services::Stats.new.show(args[0], options)
|
|
137
|
-
end
|
|
138
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require 'kontena/client'
|
|
2
|
-
require_relative '../common'
|
|
3
|
-
|
|
4
|
-
module Kontena::Cli::Services
|
|
5
|
-
class Containers
|
|
6
|
-
include Kontena::Cli::Common
|
|
7
|
-
|
|
8
|
-
##
|
|
9
|
-
# @param [String] service_id
|
|
10
|
-
def list(service_id)
|
|
11
|
-
require_api_url
|
|
12
|
-
token = require_token
|
|
13
|
-
|
|
14
|
-
result = client(token).get("services/#{current_grid}/#{service_id}/containers")
|
|
15
|
-
result['containers'].each do |container|
|
|
16
|
-
puts "#{container['id']}:"
|
|
17
|
-
puts " node: #{container['node']['name']}"
|
|
18
|
-
puts " ip (internal): #{container['network_settings']['ip_address']}"
|
|
19
|
-
puts " status: #{container['status']}"
|
|
20
|
-
puts ""
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|