kuber_kit 0.3.4 → 0.3.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -5
- data/TODO.md +2 -2
- data/lib/kuber_kit.rb +2 -0
- data/lib/kuber_kit/actions/kubectl_attacher.rb +7 -1
- data/lib/kuber_kit/actions/kubectl_console.rb +32 -0
- data/lib/kuber_kit/actions/kubectl_logs.rb +37 -0
- data/lib/kuber_kit/actions/service_deployer.rb +5 -4
- data/lib/kuber_kit/cli.rb +27 -6
- data/lib/kuber_kit/configs.rb +2 -1
- data/lib/kuber_kit/container.rb +9 -1
- data/lib/kuber_kit/core/service.rb +5 -5
- data/lib/kuber_kit/core/service_factory.rb +0 -6
- data/lib/kuber_kit/service_deployer/strategies/docker.rb +12 -6
- data/lib/kuber_kit/service_deployer/strategies/docker_compose.rb +8 -3
- data/lib/kuber_kit/service_reader/reader.rb +6 -0
- data/lib/kuber_kit/shell/commands/docker_commands.rb +9 -4
- data/lib/kuber_kit/shell/commands/docker_compose_commands.rb +7 -3
- data/lib/kuber_kit/shell/commands/kubectl_commands.rb +29 -6
- data/lib/kuber_kit/tools/logger_factory.rb +6 -2
- data/lib/kuber_kit/ui/interactive.rb +7 -1
- data/lib/kuber_kit/ui/simple.rb +2 -1
- data/lib/kuber_kit/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8321dfb87de00ef987aa2c826e5310fd721664135b90e194562a9c9f26ad044e
|
4
|
+
data.tar.gz: dccbfdc6df8ed8bedd6e6d30ddfd576c42c1a12ec36aa465769a1fcc207d38af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cde945512a525f1ef577f540ae3919bc602d442fb44eb14505fe2a4761ad1c15061f9bab1540b9b8de2592cf4d4f4f7396bfe451499af45cd6198659ad7cfaeb
|
7
|
+
data.tar.gz: cca667290f77ff94934ce302666655d1bdefc414f074915c8a6d091590786b20ff2aa26a04c02f9d07b5e3c88f2e48439c3cbe71add7d374ea255deda753e125
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kuber_kit (0.3.
|
4
|
+
kuber_kit (0.3.9)
|
5
5
|
cli-ui
|
6
6
|
contracts-lite
|
7
7
|
dry-auto_inject
|
@@ -19,16 +19,14 @@ GEM
|
|
19
19
|
docile (1.3.2)
|
20
20
|
dry-auto_inject (0.7.0)
|
21
21
|
dry-container (>= 0.3.4)
|
22
|
-
dry-configurable (0.
|
22
|
+
dry-configurable (0.12.0)
|
23
23
|
concurrent-ruby (~> 1.0)
|
24
|
-
dry-core (~> 0.
|
25
|
-
dry-equalizer (~> 0.2)
|
24
|
+
dry-core (~> 0.5, >= 0.5.0)
|
26
25
|
dry-container (0.7.2)
|
27
26
|
concurrent-ruby (~> 1.0)
|
28
27
|
dry-configurable (~> 0.1, >= 0.1.3)
|
29
28
|
dry-core (0.5.0)
|
30
29
|
concurrent-ruby (~> 1.0)
|
31
|
-
dry-equalizer (0.3.0)
|
32
30
|
method_source (1.0.0)
|
33
31
|
net-ssh (6.1.0)
|
34
32
|
pry (0.13.1)
|
data/TODO.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
+
- https://ttytoolkit.org/
|
2
|
+
- kit status should show the list of services and their status, with ability to select & view logs
|
1
3
|
- list services and require confirmation before deployment
|
2
|
-
- kit attach should list available deployments/pods, and ask for specific container if it has multiple containers
|
3
4
|
- add kit logs support, should work similar to kit attach
|
4
5
|
- allow deploying only services enabled for specific configuration
|
5
6
|
- find a way to always deploy some service, e.g. for migrations and env_files
|
6
|
-
- add ability to set container health checks
|
7
7
|
- template should be able to set default attributes
|
8
8
|
- template should be able to depend on image?
|
data/lib/kuber_kit.rb
CHANGED
@@ -166,6 +166,8 @@ module KuberKit
|
|
166
166
|
autoload :ConfigurationLoader, 'actions/configuration_loader'
|
167
167
|
autoload :KubectlApplier, 'actions/kubectl_applier'
|
168
168
|
autoload :KubectlAttacher, 'actions/kubectl_attacher'
|
169
|
+
autoload :KubectlConsole, 'actions/kubectl_console'
|
170
|
+
autoload :KubectlLogs, 'actions/kubectl_logs'
|
169
171
|
end
|
170
172
|
|
171
173
|
module Extensions
|
@@ -5,11 +5,17 @@ class KuberKit::Actions::KubectlAttacher
|
|
5
5
|
"ui"
|
6
6
|
]
|
7
7
|
|
8
|
-
Contract String, Hash => Any
|
8
|
+
Contract Maybe[String], Hash => Any
|
9
9
|
def call(pod_name, options)
|
10
10
|
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
11
11
|
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
12
12
|
|
13
|
+
if !pod_name
|
14
|
+
resources = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
|
15
|
+
options = resources.split(" ").map{|d| "deploy/#{d}" }
|
16
|
+
pod_name = ui.prompt("Please select deployment to attach", options)
|
17
|
+
end
|
18
|
+
|
13
19
|
kubectl_commands.exec(
|
14
20
|
local_shell, pod_name, "bash", args: "-it",
|
15
21
|
kubeconfig_path: kubeconfig_path,
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class KuberKit::Actions::KubectlConsole
|
2
|
+
include KuberKit::Import[
|
3
|
+
"shell.kubectl_commands",
|
4
|
+
"shell.local_shell",
|
5
|
+
"ui"
|
6
|
+
]
|
7
|
+
|
8
|
+
Contract Maybe[String], Hash => Any
|
9
|
+
def call(pod_name, options)
|
10
|
+
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
11
|
+
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
12
|
+
|
13
|
+
if !pod_name
|
14
|
+
resources = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
|
15
|
+
options = resources.split(" ").map{|d| "deploy/#{d}" }
|
16
|
+
pod_name = ui.prompt("Please select deployment to attach", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
kubectl_commands.exec(
|
20
|
+
local_shell, pod_name, "bin/console", args: "-it",
|
21
|
+
kubeconfig_path: kubeconfig_path,
|
22
|
+
interactive: true,
|
23
|
+
namespace: deployer_namespace
|
24
|
+
)
|
25
|
+
|
26
|
+
true
|
27
|
+
rescue KuberKit::Error => e
|
28
|
+
ui.print_error("Error", e.message)
|
29
|
+
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class KuberKit::Actions::KubectlLogs
|
2
|
+
include KuberKit::Import[
|
3
|
+
"shell.kubectl_commands",
|
4
|
+
"shell.local_shell",
|
5
|
+
"ui"
|
6
|
+
]
|
7
|
+
|
8
|
+
Contract Maybe[String], Hash => Any
|
9
|
+
def call(pod_name, options)
|
10
|
+
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
11
|
+
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
12
|
+
|
13
|
+
if !pod_name
|
14
|
+
deployments = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
|
15
|
+
deploy_options = deployments.split(" ").map{|d| "deploy/#{d}" }
|
16
|
+
pod_name = ui.prompt("Please select deployment to attach", deploy_options)
|
17
|
+
end
|
18
|
+
|
19
|
+
args = nil
|
20
|
+
if options[:follow]
|
21
|
+
args = "-f"
|
22
|
+
end
|
23
|
+
|
24
|
+
kubectl_commands.logs(
|
25
|
+
local_shell, pod_name,
|
26
|
+
args: args,
|
27
|
+
kubeconfig_path: kubeconfig_path,
|
28
|
+
namespace: deployer_namespace
|
29
|
+
)
|
30
|
+
|
31
|
+
true
|
32
|
+
rescue KuberKit::Error => e
|
33
|
+
ui.print_error("Error", e.message)
|
34
|
+
|
35
|
+
false
|
36
|
+
end
|
37
|
+
end
|
@@ -10,10 +10,11 @@ class KuberKit::Actions::ServiceDeployer
|
|
10
10
|
]
|
11
11
|
|
12
12
|
Contract KeywordArgs[
|
13
|
-
services:
|
14
|
-
tags:
|
13
|
+
services: Maybe[ArrayOf[String]],
|
14
|
+
tags: Maybe[ArrayOf[String]],
|
15
|
+
skip_compile: Maybe[Bool],
|
15
16
|
] => Any
|
16
|
-
def call(services:, tags:)
|
17
|
+
def call(services:, tags:, skip_compile: false)
|
17
18
|
if services.empty? && tags.empty?
|
18
19
|
services, tags = show_tags_selection
|
19
20
|
end
|
@@ -33,7 +34,7 @@ class KuberKit::Actions::ServiceDeployer
|
|
33
34
|
|
34
35
|
images_names = services.map(&:images).flatten.uniq
|
35
36
|
|
36
|
-
compile_images(images_names)
|
37
|
+
compile_images(images_names) unless skip_compile
|
37
38
|
deploy_services(service_names)
|
38
39
|
|
39
40
|
true
|
data/lib/kuber_kit/cli.rb
CHANGED
@@ -31,15 +31,17 @@ class KuberKit::CLI < Thor
|
|
31
31
|
end
|
32
32
|
|
33
33
|
desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
|
34
|
-
method_option :services,
|
35
|
-
method_option :tags,
|
34
|
+
method_option :services, :type => :array, aliases: ["-s"]
|
35
|
+
method_option :tags, :type => :array, aliases: ["-t"]
|
36
|
+
method_option :skip_compile, :type => :boolean, aliases: ["-B"]
|
36
37
|
def deploy
|
37
38
|
KuberKit.set_debug_mode(options[:debug])
|
38
39
|
|
39
40
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
40
41
|
result = KuberKit::Container['actions.service_deployer'].call(
|
41
|
-
services:
|
42
|
-
tags:
|
42
|
+
services: options[:services] || [],
|
43
|
+
tags: options[:tags] || [],
|
44
|
+
skip_compile: options[:skip_compile] || false
|
43
45
|
)
|
44
46
|
end
|
45
47
|
|
@@ -91,8 +93,8 @@ class KuberKit::CLI < Thor
|
|
91
93
|
end
|
92
94
|
end
|
93
95
|
|
94
|
-
desc "attach POD_NAME", "Attach to POD_NAME
|
95
|
-
def attach(pod_name)
|
96
|
+
desc "attach POD_NAME", "Attach to POD_NAME using kubectl"
|
97
|
+
def attach(pod_name = nil)
|
96
98
|
KuberKit.set_debug_mode(options[:debug])
|
97
99
|
|
98
100
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
@@ -100,6 +102,25 @@ class KuberKit::CLI < Thor
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
105
|
+
desc "launch console in POD_NAME", "Attach to POD_NAME using kubectl & launch bin/console"
|
106
|
+
def console(pod_name = nil)
|
107
|
+
KuberKit.set_debug_mode(options[:debug])
|
108
|
+
|
109
|
+
if KuberKit::Container['actions.configuration_loader'].call(options)
|
110
|
+
KuberKit::Container['actions.kubectl_console'].call(pod_name, options)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
desc "show logs for POD_NAME", "Show logs for POD_NAME using kubectl"
|
115
|
+
method_option :follow, :type => :boolean, aliases: ["-f"]
|
116
|
+
def logs(pod_name = nil)
|
117
|
+
KuberKit.set_debug_mode(options[:debug])
|
118
|
+
|
119
|
+
if KuberKit::Container['actions.configuration_loader'].call(options)
|
120
|
+
KuberKit::Container['actions.kubectl_logs'].call(pod_name, options)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
103
124
|
desc "version", "Print current version"
|
104
125
|
def version
|
105
126
|
puts KuberKit::VERSION
|
data/lib/kuber_kit/configs.rb
CHANGED
@@ -5,7 +5,7 @@ class KuberKit::Configs
|
|
5
5
|
:image_dockerfile_name, :image_build_context_dir, :image_tag, :docker_ignore_list, :image_compile_dir,
|
6
6
|
:kuber_kit_dirname, :kuber_kit_min_version, :images_dirname, :services_dirname, :infra_dirname, :configurations_dirname,
|
7
7
|
:artifact_clone_dir, :service_config_dir, :deployer_strategy, :compile_simultaneous_limit,
|
8
|
-
:additional_images_paths, :deprecation_warnings_disabled
|
8
|
+
:additional_images_paths, :deprecation_warnings_disabled, :log_file_path
|
9
9
|
]
|
10
10
|
DOCKER_IGNORE_LIST = [
|
11
11
|
'Dockerfile',
|
@@ -51,6 +51,7 @@ class KuberKit::Configs
|
|
51
51
|
set :compile_simultaneous_limit, 5
|
52
52
|
set :additional_images_paths, []
|
53
53
|
set :deprecation_warnings_disabled, false
|
54
|
+
set :log_file_path, "/tmp/kuber_kit.log"
|
54
55
|
end
|
55
56
|
|
56
57
|
def items
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -33,6 +33,14 @@ class KuberKit::Container
|
|
33
33
|
KuberKit::Actions::KubectlAttacher.new
|
34
34
|
end
|
35
35
|
|
36
|
+
register "actions.kubectl_console" do
|
37
|
+
KuberKit::Actions::KubectlConsole.new
|
38
|
+
end
|
39
|
+
|
40
|
+
register "actions.kubectl_logs" do
|
41
|
+
KuberKit::Actions::KubectlLogs.new
|
42
|
+
end
|
43
|
+
|
36
44
|
register "configs" do
|
37
45
|
KuberKit::Configs.new
|
38
46
|
end
|
@@ -106,7 +114,7 @@ class KuberKit::Container
|
|
106
114
|
end
|
107
115
|
|
108
116
|
register "tools.logger" do
|
109
|
-
KuberKit::Container["tools.logger_factory"].create(
|
117
|
+
KuberKit::Container["tools.logger_factory"].create()
|
110
118
|
end
|
111
119
|
|
112
120
|
register "shell.bash_commands" do
|
@@ -4,11 +4,11 @@ class KuberKit::Core::Service
|
|
4
4
|
attr_reader :name, :template_name, :tags, :images, :attributes, :deployer_strategy
|
5
5
|
|
6
6
|
Contract KeywordArgs[
|
7
|
-
name:
|
8
|
-
template_name:
|
9
|
-
tags:
|
10
|
-
images:
|
11
|
-
attributes:
|
7
|
+
name: Symbol,
|
8
|
+
template_name: Maybe[Symbol],
|
9
|
+
tags: ArrayOf[Symbol],
|
10
|
+
images: ArrayOf[Symbol],
|
11
|
+
attributes: HashOf[Symbol => Any],
|
12
12
|
deployer_strategy: Maybe[Symbol]
|
13
13
|
] => Any
|
14
14
|
def initialize(name:, template_name:, tags:, images:, attributes:, deployer_strategy:)
|
@@ -1,13 +1,7 @@
|
|
1
1
|
class KuberKit::Core::ServiceFactory
|
2
|
-
AttributeNotSetError = Class.new(KuberKit::Error)
|
3
|
-
|
4
2
|
def create(definition)
|
5
3
|
service_attrs = definition.to_service_attrs
|
6
4
|
|
7
|
-
if service_attrs.template_name.nil?
|
8
|
-
raise AttributeNotSetError, "Please set template for service using #template method"
|
9
|
-
end
|
10
|
-
|
11
5
|
configuration_attributes = KuberKit.current_configuration.service_attributes(service_attrs.name)
|
12
6
|
attributes = (service_attrs.attributes || {}).merge(configuration_attributes)
|
13
7
|
|
@@ -8,8 +8,9 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
8
8
|
STRATEGY_OPTIONS = [
|
9
9
|
:container_name,
|
10
10
|
:image_name,
|
11
|
-
:
|
12
|
-
:
|
11
|
+
:detached,
|
12
|
+
:command_name,
|
13
|
+
:command_args,
|
13
14
|
:delete_if_exists
|
14
15
|
]
|
15
16
|
|
@@ -21,9 +22,9 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
21
22
|
raise KuberKit::Error, "Unknow options for deploy strategy: #{unknown_options}. Available options: #{STRATEGY_OPTIONS}"
|
22
23
|
end
|
23
24
|
|
24
|
-
container_name
|
25
|
-
|
26
|
-
|
25
|
+
container_name = strategy_options.fetch(:container_name, service.uri)
|
26
|
+
command_name = strategy_options.fetch(:command_name, "bash")
|
27
|
+
command_args = strategy_options.fetch(:command_args, nil)
|
27
28
|
|
28
29
|
image_name = strategy_options.fetch(:image_name, nil)
|
29
30
|
if image_name.nil?
|
@@ -36,6 +37,11 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
36
37
|
docker_commands.delete_container(shell, container_name)
|
37
38
|
end
|
38
39
|
|
39
|
-
docker_commands.run(
|
40
|
+
docker_commands.run(
|
41
|
+
shell, image.remote_registry_url,
|
42
|
+
command: command_name,
|
43
|
+
args: command_args,
|
44
|
+
detached: !!strategy_options[:detached]
|
45
|
+
)
|
40
46
|
end
|
41
47
|
end
|
@@ -7,7 +7,9 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
|
|
7
7
|
|
8
8
|
STRATEGY_OPTIONS = [
|
9
9
|
:service_name,
|
10
|
-
:command_name
|
10
|
+
:command_name,
|
11
|
+
:command_args,
|
12
|
+
:detached
|
11
13
|
]
|
12
14
|
|
13
15
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
@@ -24,10 +26,13 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
|
|
24
26
|
|
25
27
|
service_name = strategy_options.fetch(:service_name, service.name.to_s)
|
26
28
|
command_name = strategy_options.fetch(:command_name, "bash")
|
29
|
+
command_args = strategy_options.fetch(:command_args, nil)
|
27
30
|
|
28
31
|
docker_compose_commands.run(shell, config_path,
|
29
|
-
service:
|
30
|
-
command:
|
32
|
+
service: service_name,
|
33
|
+
command: command_name,
|
34
|
+
args: command_args,
|
35
|
+
detached: !!strategy_options[:detached]
|
31
36
|
)
|
32
37
|
end
|
33
38
|
end
|
@@ -6,8 +6,14 @@ class KuberKit::ServiceReader::Reader
|
|
6
6
|
"preprocessing.text_preprocessor"
|
7
7
|
]
|
8
8
|
|
9
|
+
AttributeNotSetError = Class.new(KuberKit::Error)
|
10
|
+
|
9
11
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
10
12
|
def read(shell, service)
|
13
|
+
if service.template_name.nil?
|
14
|
+
raise AttributeNotSetError, "Please set template for service using #template method"
|
15
|
+
end
|
16
|
+
|
11
17
|
template = template_store.get(service.template_name)
|
12
18
|
|
13
19
|
context_helper = context_helper_factory.build_service_context(shell, service)
|
@@ -14,14 +14,19 @@ class KuberKit::Shell::Commands::DockerCommands
|
|
14
14
|
shell.exec!(%Q{docker push #{tag_name}})
|
15
15
|
end
|
16
16
|
|
17
|
-
def run(shell, image_name,
|
17
|
+
def run(shell, image_name, args: nil, command: nil, detached: false, interactive: false)
|
18
18
|
command_parts = []
|
19
19
|
command_parts << "docker run"
|
20
|
-
command_parts <<
|
20
|
+
command_parts << "-d" if detached
|
21
|
+
command_parts << args if args
|
21
22
|
command_parts << image_name
|
22
|
-
command_parts <<
|
23
|
+
command_parts << command if command
|
23
24
|
|
24
|
-
|
25
|
+
if interactive
|
26
|
+
shell.interactive!(command_parts.join(" "))
|
27
|
+
else
|
28
|
+
shell.exec!(command_parts.join(" "))
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
32
|
def container_exists?(shell, container_name)
|
@@ -1,13 +1,17 @@
|
|
1
1
|
class KuberKit::Shell::Commands::DockerComposeCommands
|
2
|
-
def run(shell, path, service:, command
|
2
|
+
def run(shell, path, service:, args: nil, command: nil, detached: false, interactive: false)
|
3
3
|
command_parts = [
|
4
4
|
"docker-compose",
|
5
5
|
"-f #{path}",
|
6
6
|
"run",
|
7
|
-
service,
|
8
|
-
command
|
9
7
|
]
|
10
8
|
|
9
|
+
|
10
|
+
command_parts << "-d" if detached
|
11
|
+
command_parts << args if args
|
12
|
+
command_parts << service
|
13
|
+
command_parts << command if command
|
14
|
+
|
11
15
|
if interactive
|
12
16
|
shell.interactive!(command_parts.join(" "))
|
13
17
|
else
|
@@ -40,15 +40,38 @@ class KuberKit::Shell::Commands::KubectlCommands
|
|
40
40
|
kubectl_run(shell, command_parts, kubeconfig_path: kubeconfig_path, interactive: interactive, namespace: namespace)
|
41
41
|
end
|
42
42
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
43
|
+
def logs(shell, pod_name, args: nil, kubeconfig_path: nil, namespace: nil)
|
44
|
+
command_parts = []
|
45
|
+
command_parts << "logs"
|
46
|
+
|
47
|
+
if args
|
48
|
+
command_parts << args
|
49
|
+
end
|
50
|
+
|
51
|
+
command_parts << pod_name
|
52
|
+
kubectl_run(shell, command_parts, kubeconfig_path: kubeconfig_path, interactive: true, namespace: namespace)
|
46
53
|
end
|
47
54
|
|
48
|
-
def
|
49
|
-
|
55
|
+
def get_resources(shell, resource_type, field_selector: nil, jsonpath: ".items[*].metadata.name", kubeconfig_path: nil, namespace: nil)
|
56
|
+
command_parts = []
|
57
|
+
command_parts << "get #{resource_type}"
|
50
58
|
|
51
|
-
|
59
|
+
if field_selector
|
60
|
+
command_parts << "--field-selector=#{field_selector}"
|
61
|
+
end
|
62
|
+
|
63
|
+
if jsonpath
|
64
|
+
command_parts << "-o jsonpath='{#{jsonpath}}'"
|
65
|
+
end
|
66
|
+
|
67
|
+
kubectl_run(shell, command_parts, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
68
|
+
end
|
69
|
+
|
70
|
+
def resource_exists?(shell, resource_type, resource_name, kubeconfig_path: nil, namespace: nil)
|
71
|
+
result = get_resources(shell, resource_type,
|
72
|
+
field_selector: "metadata.name=#{resource_name}", kubeconfig_path: kubeconfig_path, namespace: namespace
|
73
|
+
)
|
74
|
+
result && result != ""
|
52
75
|
end
|
53
76
|
|
54
77
|
def delete_resource(shell, resource_type, resource_name, kubeconfig_path: nil, namespace: nil)
|
@@ -9,8 +9,12 @@ class KuberKit::Tools::LoggerFactory
|
|
9
9
|
Logger::FATAL => String::Colors::PURPLE,
|
10
10
|
}
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
include KuberKit::Import[
|
13
|
+
"configs",
|
14
|
+
]
|
15
|
+
|
16
|
+
def create(stdout = nil, level = nil)
|
17
|
+
logger = Logger.new(stdout || configs.log_file_path)
|
14
18
|
|
15
19
|
logger.level = level || Logger::DEBUG
|
16
20
|
|
@@ -29,7 +29,13 @@ class KuberKit::UI::Interactive
|
|
29
29
|
def prompt(text, options, &callback)
|
30
30
|
CLI::UI::Prompt.ask(text) do |handler|
|
31
31
|
options.each do |option|
|
32
|
-
|
32
|
+
if callback
|
33
|
+
handler.option(option, &callback)
|
34
|
+
else
|
35
|
+
handler.option(option) do |selection|
|
36
|
+
selection
|
37
|
+
end
|
38
|
+
end
|
33
39
|
end
|
34
40
|
end
|
35
41
|
end
|
data/lib/kuber_kit/ui/simple.rb
CHANGED
data/lib/kuber_kit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuber_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts-lite
|
@@ -191,6 +191,8 @@ files:
|
|
191
191
|
- lib/kuber_kit/actions/image_compiler.rb
|
192
192
|
- lib/kuber_kit/actions/kubectl_applier.rb
|
193
193
|
- lib/kuber_kit/actions/kubectl_attacher.rb
|
194
|
+
- lib/kuber_kit/actions/kubectl_console.rb
|
195
|
+
- lib/kuber_kit/actions/kubectl_logs.rb
|
194
196
|
- lib/kuber_kit/actions/service_deployer.rb
|
195
197
|
- lib/kuber_kit/actions/service_reader.rb
|
196
198
|
- lib/kuber_kit/actions/template_reader.rb
|