kuber_kit 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/TODO.md +5 -4
- data/example/configurations/review.rb +1 -1
- data/example/services/ruby_app.rb +1 -0
- data/lib/kuber_kit.rb +5 -0
- data/lib/kuber_kit/actions/service_deployer.rb +75 -59
- data/lib/kuber_kit/configs.rb +2 -1
- data/lib/kuber_kit/container.rb +4 -0
- data/lib/kuber_kit/core/dependencies/abstract_dependency_resolver.rb +75 -0
- data/lib/kuber_kit/core/image.rb +2 -1
- data/lib/kuber_kit/core/service.rb +4 -2
- data/lib/kuber_kit/core/service_definition.rb +13 -6
- data/lib/kuber_kit/core/service_factory.rb +1 -0
- data/lib/kuber_kit/image_compiler/image_dependency_resolver.rb +5 -53
- data/lib/kuber_kit/service_deployer/service_dependency_resolver.rb +14 -0
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +9 -2
- data/lib/kuber_kit/shell/commands/kubectl_commands.rb +8 -0
- data/lib/kuber_kit/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 485e80726d7350ce239a165860ba4096b3549178d10e5ff8abdc918df983ab4c
|
4
|
+
data.tar.gz: 480a475c88bf4a6626a182ade7909e0a08143a978d96471faf0c2495021abf6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d285c169ea188e3c8d4679db94ea74a7c3b5cabc993fbd41e675d590505d1f714836de4b052cd1b1793d810069b1d61f2520d78bcc8c538a6efaa95730f0dc2d
|
7
|
+
data.tar.gz: b645418d23a5e68f5bebf571dcd2853d460cadd42247ccc749b5c938825b08671059fedd3cbb83fd960cc3deb8a6eb0a121c11468e4dc7e365dc89b803046383
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/TODO.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
- do not show result for images list, if list is too large (Mikhail)
|
2
|
-
- add kit get method for interactive kubernetes
|
3
|
-
-
|
4
|
-
-
|
2
|
+
- add kit get method for more interactive kubernetes
|
3
|
+
- env files should use a separate deployment method (with change detection)
|
4
|
+
- add automatical confirmation support for service deployer
|
5
5
|
- template should be able to set default attributes
|
6
6
|
- template should be able to depend on image?
|
7
7
|
- cleanup image builds older than some date
|
8
|
-
- add some rotation for deploy log
|
8
|
+
- add some rotation for deploy log
|
9
|
+
- kit status should show the list of services and their status, with ability to select & view logs
|
data/lib/kuber_kit.rb
CHANGED
@@ -46,6 +46,10 @@ module KuberKit
|
|
46
46
|
autoload :BuildServer, 'core/build_servers/build_server'
|
47
47
|
end
|
48
48
|
|
49
|
+
module Dependencies
|
50
|
+
autoload :AbstractDependencyResolver, 'core/dependencies/abstract_dependency_resolver'
|
51
|
+
end
|
52
|
+
|
49
53
|
module EnvFiles
|
50
54
|
autoload :EnvFileStore, 'core/env_files/env_file_store'
|
51
55
|
autoload :AbstractEnvFile, 'core/env_files/abstract_env_file'
|
@@ -145,6 +149,7 @@ module KuberKit
|
|
145
149
|
autoload :StrategyDetector, 'service_deployer/strategy_detector'
|
146
150
|
autoload :Deployer, 'service_deployer/deployer'
|
147
151
|
autoload :ServiceListResolver, 'service_deployer/service_list_resolver'
|
152
|
+
autoload :ServiceDependencyResolver, 'service_deployer/service_dependency_resolver'
|
148
153
|
|
149
154
|
module Strategies
|
150
155
|
autoload :Abstract, 'service_deployer/strategies/abstract'
|
@@ -2,9 +2,11 @@ class KuberKit::Actions::ServiceDeployer
|
|
2
2
|
include KuberKit::Import[
|
3
3
|
"actions.image_compiler",
|
4
4
|
"service_deployer.service_list_resolver",
|
5
|
+
"service_deployer.service_dependency_resolver",
|
5
6
|
"core.service_store",
|
6
7
|
"shell.local_shell",
|
7
8
|
"tools.process_cleaner",
|
9
|
+
"configs",
|
8
10
|
"ui",
|
9
11
|
service_deployer: "service_deployer.action_handler",
|
10
12
|
]
|
@@ -24,14 +26,17 @@ class KuberKit::Actions::ServiceDeployer
|
|
24
26
|
services: services || [],
|
25
27
|
tags: tags || [],
|
26
28
|
enabled_services: KuberKit.current_configuration.enabled_services.map(&:to_s)
|
27
|
-
)
|
29
|
+
).map(&:to_sym)
|
28
30
|
|
29
|
-
|
31
|
+
# Return the list of services with all dependencies.
|
32
|
+
all_service_names = service_dependency_resolver.get_all(service_names)
|
33
|
+
|
34
|
+
unless all_service_names.any?
|
30
35
|
ui.print_warning "ServiceDeployer", "No service found with given options, nothing will be deployed."
|
31
36
|
return false
|
32
37
|
end
|
33
38
|
|
34
|
-
services_list =
|
39
|
+
services_list = all_service_names.map(&:to_s).map(&:yellow).join(", ")
|
35
40
|
ui.print_info "ServiceDeployer", "The following services will be deployed: #{services_list}"
|
36
41
|
|
37
42
|
if require_confirmation
|
@@ -39,7 +44,7 @@ class KuberKit::Actions::ServiceDeployer
|
|
39
44
|
return false unless ["confirm".green, "confirm", "yes"].include?(result)
|
40
45
|
end
|
41
46
|
|
42
|
-
services =
|
47
|
+
services = all_service_names.map do |service_name|
|
43
48
|
service_store.get_service(service_name.to_sym)
|
44
49
|
end
|
45
50
|
|
@@ -50,9 +55,16 @@ class KuberKit::Actions::ServiceDeployer
|
|
50
55
|
return false unless compile_result
|
51
56
|
end
|
52
57
|
|
53
|
-
|
58
|
+
deployed_services = []
|
59
|
+
deployment_result = {}
|
60
|
+
service_dependency_resolver.each_with_deps(service_names) do |dep_service_names|
|
61
|
+
ui.print_debug("ServiceDeployer", "Scheduling to compile: #{dep_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
62
|
+
result = deploy_simultaneously(dep_service_names)
|
63
|
+
deployed_services += dep_service_names
|
64
|
+
deployment_result = deployment_result.merge(result)
|
65
|
+
end
|
54
66
|
|
55
|
-
{ services:
|
67
|
+
{ services: all_service_names, deployment: deployment_result }
|
56
68
|
rescue KuberKit::Error => e
|
57
69
|
ui.print_error("Error", e.message)
|
58
70
|
|
@@ -61,69 +73,73 @@ class KuberKit::Actions::ServiceDeployer
|
|
61
73
|
process_cleaner.clean
|
62
74
|
end
|
63
75
|
|
64
|
-
|
65
|
-
|
76
|
+
private
|
77
|
+
def deploy_simultaneously(service_names)
|
78
|
+
task_group = ui.create_task_group
|
66
79
|
|
67
|
-
|
80
|
+
deployer_result = {}
|
68
81
|
|
69
|
-
|
82
|
+
service_names.each do |service_name|
|
70
83
|
|
71
|
-
|
72
|
-
|
73
|
-
|
84
|
+
ui.print_debug("ServiceDeployer", "Started deploying: #{service_name.to_s.green}")
|
85
|
+
task_group.add("Deploying #{service_name.to_s.yellow}") do |task|
|
86
|
+
deployer_result[service_name] = service_deployer.call(local_shell, service_name.to_sym)
|
74
87
|
|
75
|
-
|
76
|
-
|
88
|
+
task.update_title("Deployed #{service_name.to_s.green}")
|
89
|
+
ui.print_debug("ServiceDeployer", "Finished deploying: #{service_name.to_s.green}")
|
90
|
+
end
|
77
91
|
end
|
78
|
-
end
|
79
92
|
|
80
|
-
|
93
|
+
task_group.wait
|
81
94
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
def compile_images(images_names)
|
86
|
-
return true if images_names.empty?
|
87
|
-
image_compiler.call(images_names, {})
|
88
|
-
end
|
95
|
+
deployer_result
|
96
|
+
end
|
89
97
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
tags = [specific_service_option]
|
94
|
-
tags += service_store
|
95
|
-
.all_definitions
|
96
|
-
.values
|
97
|
-
.map(&:to_service_attrs)
|
98
|
-
.map(&:tags)
|
99
|
-
.flatten
|
100
|
-
.uniq
|
101
|
-
.sort
|
102
|
-
.map(&:to_s)
|
103
|
-
|
104
|
-
selected_tag = ui.prompt("Please select which tag to deploy", tags)
|
105
|
-
|
106
|
-
if selected_tag == specific_service_option
|
107
|
-
show_service_selection
|
108
|
-
else
|
109
|
-
[[], [selected_tag]]
|
98
|
+
def compile_images(images_names)
|
99
|
+
return true if images_names.empty?
|
100
|
+
image_compiler.call(images_names, {})
|
110
101
|
end
|
111
|
-
end
|
112
102
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
103
|
+
def show_tags_selection()
|
104
|
+
specific_service_option = "deploy specific service"
|
105
|
+
all_services_option = "deploy all services"
|
106
|
+
|
107
|
+
tags = [specific_service_option, all_services_option]
|
108
|
+
tags += service_store
|
109
|
+
.all_definitions
|
110
|
+
.values
|
111
|
+
.map(&:to_service_attrs)
|
112
|
+
.map(&:tags)
|
113
|
+
.flatten
|
114
|
+
.uniq
|
115
|
+
.sort
|
116
|
+
.map(&:to_s)
|
117
|
+
|
118
|
+
selected_tag = ui.prompt("Please select which tag to deploy", tags)
|
119
|
+
|
120
|
+
if selected_tag == specific_service_option
|
121
|
+
show_service_selection
|
122
|
+
elsif selected_tag == all_services_option
|
123
|
+
[["*"], []]
|
124
|
+
else
|
125
|
+
[[], [selected_tag]]
|
126
|
+
end
|
124
127
|
end
|
125
128
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
+
def show_service_selection()
|
130
|
+
services = service_store
|
131
|
+
.all_definitions
|
132
|
+
.values
|
133
|
+
.map(&:service_name)
|
134
|
+
.uniq
|
135
|
+
.sort
|
136
|
+
.map(&:to_s)
|
137
|
+
|
138
|
+
if services.empty?
|
139
|
+
return [[], []]
|
140
|
+
end
|
141
|
+
|
142
|
+
selected_service = ui.prompt("Please select which service to deploy", services)
|
143
|
+
[[selected_service], []]
|
144
|
+
end
|
129
145
|
end
|
data/lib/kuber_kit/configs.rb
CHANGED
@@ -4,7 +4,7 @@ class KuberKit::Configs
|
|
4
4
|
AVAILABLE_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
|
-
:artifact_clone_dir, :service_config_dir, :deployer_strategy, :compile_simultaneous_limit,
|
7
|
+
:artifact_clone_dir, :service_config_dir, :deployer_strategy, :compile_simultaneous_limit, :deploy_simultaneous_limit,
|
8
8
|
:additional_images_paths, :deprecation_warnings_disabled, :log_file_path
|
9
9
|
]
|
10
10
|
DOCKER_IGNORE_LIST = [
|
@@ -49,6 +49,7 @@ class KuberKit::Configs
|
|
49
49
|
set :service_config_dir, "/tmp/kuber_kit/services"
|
50
50
|
set :deployer_strategy, :kubernetes
|
51
51
|
set :compile_simultaneous_limit, 5
|
52
|
+
set :deploy_simultaneous_limit, 5
|
52
53
|
set :additional_images_paths, []
|
53
54
|
set :deprecation_warnings_disabled, false
|
54
55
|
set :log_file_path, "/tmp/kuber_kit.log"
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -257,6 +257,10 @@ class KuberKit::Container
|
|
257
257
|
KuberKit::ServiceDeployer::ServiceListResolver.new
|
258
258
|
end
|
259
259
|
|
260
|
+
register "service_deployer.service_dependency_resolver" do
|
261
|
+
KuberKit::ServiceDeployer::ServiceDependencyResolver.new
|
262
|
+
end
|
263
|
+
|
260
264
|
register "service_deployer.strategies.kubernetes" do
|
261
265
|
KuberKit::ServiceDeployer::Strategies::Kubernetes.new
|
262
266
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
class KuberKit::Core::Dependencies::AbstractDependencyResolver
|
2
|
+
CircularDependencyError = Class.new(KuberKit::Error)
|
3
|
+
DependencyNotFoundError = Class.new(KuberKit::NotFoundError)
|
4
|
+
|
5
|
+
# Iterate over list of dependencies for items (including the items themself).
|
6
|
+
# Iteration will send the list to the callback block function
|
7
|
+
Contract Or[Symbol, ArrayOf[Symbol]], Proc => Any
|
8
|
+
def each_with_deps(item_names, &block)
|
9
|
+
resolved_dependencies = []
|
10
|
+
# Get first list of dependencies ready to resolve
|
11
|
+
next_dependencies = get_next(item_names, limit: dependency_batch_size)
|
12
|
+
|
13
|
+
# Call the block for each list of dependencies ready to resolve, then calculate the next list
|
14
|
+
while (next_dependencies - resolved_dependencies).any?
|
15
|
+
block.call(next_dependencies)
|
16
|
+
resolved_dependencies += next_dependencies
|
17
|
+
next_dependencies = get_next(item_names, resolved: resolved_dependencies, limit: dependency_batch_size)
|
18
|
+
end
|
19
|
+
|
20
|
+
(item_names - resolved_dependencies).each_slice(dependency_batch_size) do |group|
|
21
|
+
block.call(group)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns next list of dependencies ready to resolve.
|
26
|
+
# Item is not ready to resolve if it has personal dependency.
|
27
|
+
# E.g. if "A" depends on "B" and "C", "C" depends on "D", then only "B" and "D" will be returned.
|
28
|
+
Contract Or[Symbol, ArrayOf[Symbol]], KeywordArgs[
|
29
|
+
resolved: Optional[ArrayOf[Symbol]],
|
30
|
+
limit: Optional[Maybe[Num]]
|
31
|
+
] => Any
|
32
|
+
def get_next(item_names, resolved: [], limit: nil)
|
33
|
+
deps = Array(item_names).map { |i| get_recursive_deps(i) }.flatten.uniq
|
34
|
+
|
35
|
+
# Find out which dependencies are ready to resolve,
|
36
|
+
# they should not have unresolved personal dependencies
|
37
|
+
ready_to_resolve = deps.select do |dep_name|
|
38
|
+
unresolved_deps = get_deps(dep_name) - resolved
|
39
|
+
unresolved_deps.empty?
|
40
|
+
end
|
41
|
+
unresolved_deps = ready_to_resolve - resolved
|
42
|
+
unresolved_deps = unresolved_deps.take(limit) if limit
|
43
|
+
unresolved_deps
|
44
|
+
end
|
45
|
+
|
46
|
+
# Get all dependencies for items (including the items themself), without any limitations
|
47
|
+
Contract Or[Symbol, ArrayOf[Symbol]] => Any
|
48
|
+
def get_all(item_names)
|
49
|
+
deps = Array(item_names).map { |i| get_recursive_deps(i) }.flatten
|
50
|
+
(deps + item_names).uniq
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_recursive_deps(item_name, dependency_tree: [])
|
54
|
+
deps = get_deps(item_name)
|
55
|
+
|
56
|
+
if dependency_tree.include?(item_name)
|
57
|
+
raise CircularDependencyError, "Circular dependency found for #{item_name}. Dependency tree: #{dependency_tree.inspect}"
|
58
|
+
end
|
59
|
+
|
60
|
+
child_deps = []
|
61
|
+
deps.each do |i|
|
62
|
+
child_deps += get_recursive_deps(i, dependency_tree: dependency_tree + [item_name])
|
63
|
+
end
|
64
|
+
|
65
|
+
(deps + child_deps).uniq
|
66
|
+
end
|
67
|
+
|
68
|
+
def get_deps(item_name)
|
69
|
+
raise "This method should be overriden"
|
70
|
+
end
|
71
|
+
|
72
|
+
def dependency_batch_size
|
73
|
+
raise "This method should be overriden"
|
74
|
+
end
|
75
|
+
end
|
data/lib/kuber_kit/core/image.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
class KuberKit::Core::Image
|
2
|
-
attr_reader :name, :dependencies, :registry, :dockerfile_path, :build_vars, :build_context_dir, :tag,
|
2
|
+
attr_reader :name, :dependencies, :registry, :dockerfile_path, :build_vars, :build_context_dir, :tag,
|
3
|
+
:before_build_callback, :after_build_callback
|
3
4
|
|
4
5
|
Contract KeywordArgs[
|
5
6
|
name: Symbol,
|
@@ -1,18 +1,20 @@
|
|
1
1
|
class KuberKit::Core::Service
|
2
2
|
AttributeNotSet = Class.new(Indocker::Error)
|
3
3
|
|
4
|
-
attr_reader :name, :template_name, :tags, :images, :attributes, :deployer_strategy
|
4
|
+
attr_reader :name, :dependencies, :template_name, :tags, :images, :attributes, :deployer_strategy
|
5
5
|
|
6
6
|
Contract KeywordArgs[
|
7
7
|
name: Symbol,
|
8
|
+
dependencies: ArrayOf[Symbol],
|
8
9
|
template_name: Maybe[Symbol],
|
9
10
|
tags: ArrayOf[Symbol],
|
10
11
|
images: ArrayOf[Symbol],
|
11
12
|
attributes: HashOf[Symbol => Any],
|
12
13
|
deployer_strategy: Maybe[Symbol]
|
13
14
|
] => Any
|
14
|
-
def initialize(name:, template_name:, tags:, images:, attributes:, deployer_strategy:)
|
15
|
+
def initialize(name:, dependencies:, template_name:, tags:, images:, attributes:, deployer_strategy:)
|
15
16
|
@name = name
|
17
|
+
@dependencies = dependencies
|
16
18
|
@template_name = template_name
|
17
19
|
@tags = tags
|
18
20
|
@images = images
|
@@ -1,22 +1,29 @@
|
|
1
1
|
class KuberKit::Core::ServiceDefinition
|
2
|
-
attr_reader :service_name, :template_name
|
2
|
+
attr_reader :service_name, :template_name, :dependencies
|
3
3
|
|
4
4
|
Contract Or[Symbol, String] => Any
|
5
5
|
def initialize(service_name)
|
6
6
|
@service_name = service_name.to_sym
|
7
|
+
@dependencies = []
|
7
8
|
end
|
8
9
|
|
9
10
|
def to_service_attrs
|
10
11
|
OpenStruct.new(
|
11
|
-
name:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
name: @service_name,
|
13
|
+
dependencies: @dependencies,
|
14
|
+
template_name: get_value(@template_name),
|
15
|
+
tags: Array(get_value(@tags)).map(&:to_sym),
|
16
|
+
images: Array(get_value(@images)).map(&:to_sym),
|
17
|
+
attributes: get_value(@attributes),
|
16
18
|
deployer_strategy: get_value(@deployer_strategy),
|
17
19
|
)
|
18
20
|
end
|
19
21
|
|
22
|
+
def depends_on(*value, &block)
|
23
|
+
@dependencies = Array(value).flatten
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
20
27
|
def template(value = nil, &block)
|
21
28
|
@template_name = block_given? ? block : value
|
22
29
|
|
@@ -1,62 +1,14 @@
|
|
1
|
-
class KuberKit::ImageCompiler::ImageDependencyResolver
|
2
|
-
CircularDependencyError = Class.new(KuberKit::Error)
|
3
|
-
DependencyNotFoundError = Class.new(KuberKit::NotFoundError)
|
4
|
-
|
1
|
+
class KuberKit::ImageCompiler::ImageDependencyResolver < KuberKit::Core::Dependencies::AbstractDependencyResolver
|
5
2
|
include KuberKit::Import[
|
6
3
|
"core.image_store",
|
7
4
|
"configs"
|
8
5
|
]
|
9
|
-
|
10
|
-
Contract Or[Symbol, ArrayOf[Symbol]], Proc => Any
|
11
|
-
def each_with_deps(image_names, &block)
|
12
|
-
compile_limit = configs.compile_simultaneous_limit
|
13
|
-
|
14
|
-
resolved_dependencies = []
|
15
|
-
next_dependencies = get_next(image_names, limit: compile_limit)
|
16
|
-
|
17
|
-
while (next_dependencies - resolved_dependencies).any?
|
18
|
-
block.call(next_dependencies)
|
19
|
-
resolved_dependencies += next_dependencies
|
20
|
-
next_dependencies = get_next(image_names, resolved: resolved_dependencies, limit: compile_limit)
|
21
|
-
end
|
22
|
-
|
23
|
-
(image_names - resolved_dependencies).each_slice(compile_limit) do |group|
|
24
|
-
block.call(group)
|
25
|
-
end
|
26
|
-
end
|
27
6
|
|
28
|
-
Contract Or[Symbol, ArrayOf[Symbol]], KeywordArgs[
|
29
|
-
resolved: Optional[ArrayOf[Symbol]],
|
30
|
-
limit: Optional[Maybe[Num]]
|
31
|
-
] => Any
|
32
|
-
def get_next(image_names, resolved: [], limit: nil)
|
33
|
-
deps = Array(image_names).map { |i| get_recursive_deps(i) }.flatten.uniq
|
34
|
-
|
35
|
-
ready_to_resolve = deps.select do |dep_name|
|
36
|
-
unresolved_deps = get_deps(dep_name) - resolved
|
37
|
-
unresolved_deps.empty?
|
38
|
-
end
|
39
|
-
unresolved_deps = ready_to_resolve - resolved
|
40
|
-
unresolved_deps = unresolved_deps.take(limit) if limit
|
41
|
-
unresolved_deps
|
42
|
-
end
|
43
|
-
|
44
|
-
def get_recursive_deps(image_name, dependency_tree: [])
|
45
|
-
deps = get_deps(image_name)
|
46
|
-
|
47
|
-
if dependency_tree.include?(image_name)
|
48
|
-
raise CircularDependencyError, "Circular dependency found for #{image_name}. Dependency tree: #{dependency_tree.inspect}"
|
49
|
-
end
|
50
|
-
|
51
|
-
child_deps = []
|
52
|
-
deps.each do |i|
|
53
|
-
child_deps += get_recursive_deps(i, dependency_tree: dependency_tree + [image_name])
|
54
|
-
end
|
55
|
-
|
56
|
-
(deps + child_deps).uniq
|
57
|
-
end
|
58
|
-
|
59
7
|
def get_deps(image_name)
|
60
8
|
image_store.get_definition(image_name).dependencies
|
61
9
|
end
|
10
|
+
|
11
|
+
def dependency_batch_size
|
12
|
+
configs.compile_simultaneous_limit
|
13
|
+
end
|
62
14
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class KuberKit::ServiceDeployer::ServiceDependencyResolver < KuberKit::Core::Dependencies::AbstractDependencyResolver
|
2
|
+
include KuberKit::Import[
|
3
|
+
"core.service_store",
|
4
|
+
"configs"
|
5
|
+
]
|
6
|
+
|
7
|
+
def get_deps(service_name)
|
8
|
+
service_store.get_definition(service_name).dependencies
|
9
|
+
end
|
10
|
+
|
11
|
+
def dependency_batch_size
|
12
|
+
configs.deploy_simultaneous_limit
|
13
|
+
end
|
14
|
+
end
|
@@ -9,7 +9,8 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
|
|
9
9
|
:resource_type,
|
10
10
|
:resource_name,
|
11
11
|
:delete_if_exists,
|
12
|
-
:restart_if_exists
|
12
|
+
:restart_if_exists,
|
13
|
+
:wait_for_rollout
|
13
14
|
]
|
14
15
|
|
15
16
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
@@ -41,12 +42,18 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
|
|
41
42
|
|
42
43
|
apply_result = kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
43
44
|
|
44
|
-
restart_enabled
|
45
|
+
restart_enabled = strategy_options.fetch(:restart_if_exists, true)
|
46
|
+
wait_for_rollout = strategy_options.fetch(:wait_for_rollout, true)
|
45
47
|
if restart_enabled && resource_exists
|
46
48
|
kubectl_commands.rolling_restart(
|
47
49
|
shell, resource_type, resource_name,
|
48
50
|
kubeconfig_path: kubeconfig_path, namespace: namespace
|
49
51
|
)
|
52
|
+
|
53
|
+
kubectl_commands.rollout_status(
|
54
|
+
shell, resource_type, resource_name, wait: true,
|
55
|
+
kubeconfig_path: kubeconfig_path, namespace: namespace
|
56
|
+
) if wait_for_rollout
|
50
57
|
end
|
51
58
|
|
52
59
|
apply_result
|
@@ -102,4 +102,12 @@ class KuberKit::Shell::Commands::KubectlCommands
|
|
102
102
|
}
|
103
103
|
}, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
104
104
|
end
|
105
|
+
|
106
|
+
def rollout_status(shell, resource_type, resource_name, wait: true, kubeconfig_path: nil, namespace: nil)
|
107
|
+
command_parts = []
|
108
|
+
command_parts << %Q{rollout status #{resource_type} #{resource_name}}
|
109
|
+
command_parts << "-w" if wait
|
110
|
+
|
111
|
+
kubectl_run(shell, command_parts, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
112
|
+
end
|
105
113
|
end
|
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.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts-lite
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- ".ruby-gemset"
|
166
166
|
- ".ruby-version"
|
167
167
|
- ".travis.yml"
|
168
|
+
- CHANGELOG.md
|
168
169
|
- Gemfile
|
169
170
|
- Gemfile.lock
|
170
171
|
- LICENSE.txt
|
@@ -239,6 +240,7 @@ files:
|
|
239
240
|
- lib/kuber_kit/core/context_helper/context_vars.rb
|
240
241
|
- lib/kuber_kit/core/context_helper/image_helper.rb
|
241
242
|
- lib/kuber_kit/core/context_helper/service_helper.rb
|
243
|
+
- lib/kuber_kit/core/dependencies/abstract_dependency_resolver.rb
|
242
244
|
- lib/kuber_kit/core/env_files/abstract_env_file.rb
|
243
245
|
- lib/kuber_kit/core/env_files/artifact_file.rb
|
244
246
|
- lib/kuber_kit/core/env_files/env_file_store.rb
|
@@ -281,6 +283,7 @@ files:
|
|
281
283
|
- lib/kuber_kit/preprocessing/text_preprocessor.rb
|
282
284
|
- lib/kuber_kit/service_deployer/action_handler.rb
|
283
285
|
- lib/kuber_kit/service_deployer/deployer.rb
|
286
|
+
- lib/kuber_kit/service_deployer/service_dependency_resolver.rb
|
284
287
|
- lib/kuber_kit/service_deployer/service_list_resolver.rb
|
285
288
|
- lib/kuber_kit/service_deployer/strategies/abstract.rb
|
286
289
|
- lib/kuber_kit/service_deployer/strategies/docker.rb
|