kuber_kit 0.1.6 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -2
- data/README.md +16 -3
- data/TODO.md +4 -3
- data/example/configurations/review.rb +2 -1
- data/example/images/app_sources/Dockerfile +1 -1
- data/example/images/ruby_app/image.rb +4 -4
- data/example/infrastructure/build_servers.rb +8 -0
- data/example/services/env_file.rb +5 -1
- data/example/services/ruby_app.rb +2 -1
- data/kuber_kit.gemspec +1 -0
- data/lib/kuber_kit.rb +37 -19
- data/lib/kuber_kit/actions/configuration_loader.rb +11 -2
- data/lib/kuber_kit/actions/env_file_reader.rb +5 -0
- data/lib/kuber_kit/actions/image_compiler.rb +16 -10
- data/lib/kuber_kit/actions/kubectl_applier.rb +9 -3
- data/lib/kuber_kit/actions/kubectl_attacher.rb +26 -0
- data/lib/kuber_kit/actions/service_deployer.rb +38 -0
- data/lib/kuber_kit/actions/service_reader.rb +6 -0
- data/lib/kuber_kit/actions/template_reader.rb +5 -0
- data/lib/kuber_kit/cli.rb +54 -20
- data/lib/kuber_kit/configs.rb +24 -22
- data/lib/kuber_kit/container.rb +21 -13
- data/lib/kuber_kit/core/artifacts/artifact_store.rb +12 -23
- data/lib/kuber_kit/core/build_servers/abstract_build_server.rb +21 -0
- data/lib/kuber_kit/core/build_servers/build_server.rb +24 -0
- data/lib/kuber_kit/core/build_servers/build_server_store.rb +18 -0
- data/lib/kuber_kit/core/configuration.rb +10 -4
- data/lib/kuber_kit/core/configuration_definition.rb +18 -1
- data/lib/kuber_kit/core/configuration_factory.rb +11 -1
- data/lib/kuber_kit/core/configuration_store.rb +14 -24
- data/lib/kuber_kit/core/context_helper/service_helper.rb +2 -2
- data/lib/kuber_kit/core/env_files/env_file_store.rb +8 -23
- data/lib/kuber_kit/core/image_store.rb +8 -18
- data/lib/kuber_kit/core/registries/registry_store.rb +8 -23
- data/lib/kuber_kit/core/service.rb +6 -2
- data/lib/kuber_kit/core/service_store.rb +13 -23
- data/lib/kuber_kit/core/store.rb +48 -0
- data/lib/kuber_kit/core/templates/template_store.rb +12 -23
- data/lib/kuber_kit/image_compiler/action_handler.rb +4 -3
- data/lib/kuber_kit/image_compiler/build_server_pool.rb +30 -0
- data/lib/kuber_kit/image_compiler/build_server_pool_factory.rb +13 -0
- data/lib/kuber_kit/image_compiler/image_build_dir_creator.rb +13 -7
- data/lib/kuber_kit/image_compiler/image_dependency_resolver.rb +25 -5
- data/lib/kuber_kit/preprocessing/file_preprocessor.rb +5 -4
- data/lib/kuber_kit/service_deployer/action_handler.rb +1 -1
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +10 -3
- data/lib/kuber_kit/shell/abstract_shell.rb +4 -0
- data/lib/kuber_kit/shell/{bash_commands.rb → commands/bash_commands.rb} +1 -1
- data/lib/kuber_kit/shell/{docker_commands.rb → commands/docker_commands.rb} +1 -1
- data/lib/kuber_kit/shell/{git_commands.rb → commands/git_commands.rb} +1 -1
- data/lib/kuber_kit/shell/commands/kubectl_commands.rb +65 -0
- data/lib/kuber_kit/shell/commands/rsync_commands.rb +32 -0
- data/lib/kuber_kit/shell/local_shell.rb +24 -5
- data/lib/kuber_kit/shell/ssh_session.rb +60 -0
- data/lib/kuber_kit/shell/ssh_shell.rb +77 -0
- data/lib/kuber_kit/tools/file_presence_checker.rb +6 -2
- data/lib/kuber_kit/ui/interactive.rb +8 -0
- data/lib/kuber_kit/ui/simple.rb +6 -0
- data/lib/kuber_kit/version.rb +2 -2
- metadata +34 -12
- data/lib/kuber_kit/preprocessing/dir_preprocessor.rb +0 -19
- data/lib/kuber_kit/shell/kubectl_commands.rb +0 -42
- data/lib/kuber_kit/shell/rsync_commands.rb +0 -20
- data/lib/kuber_kit/tools/files_sync.rb +0 -10
@@ -1,6 +1,10 @@
|
|
1
1
|
class KuberKit::Tools::FilePresenceChecker
|
2
2
|
FileNotFound = Class.new(KuberKit::Error)
|
3
3
|
|
4
|
+
include KuberKit::Import[
|
5
|
+
"shell.local_shell"
|
6
|
+
]
|
7
|
+
|
4
8
|
def check_file!(file_path)
|
5
9
|
unless file_exists?(file_path)
|
6
10
|
raise FileNotFound, "File not found at path: #{file_path}"
|
@@ -9,7 +13,7 @@ class KuberKit::Tools::FilePresenceChecker
|
|
9
13
|
end
|
10
14
|
|
11
15
|
def file_exists?(file_path)
|
12
|
-
|
16
|
+
local_shell.file_exists?(file_path)
|
13
17
|
end
|
14
18
|
|
15
19
|
def check_dir!(dir_path)
|
@@ -20,6 +24,6 @@ class KuberKit::Tools::FilePresenceChecker
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def dir_exists?(dir_path)
|
23
|
-
|
27
|
+
local_shell.dir_exists?(dir_path)
|
24
28
|
end
|
25
29
|
end
|
@@ -26,6 +26,14 @@ class KuberKit::UI::Interactive
|
|
26
26
|
print_in_frame(title, text, color: :yellow)
|
27
27
|
end
|
28
28
|
|
29
|
+
def prompt(text, options, &callback)
|
30
|
+
CLI::UI::Prompt.ask(text) do |handler|
|
31
|
+
options.each do |option|
|
32
|
+
handler.option(option, &callback)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
29
37
|
private
|
30
38
|
def init
|
31
39
|
@initialized = true
|
data/lib/kuber_kit/ui/simple.rb
CHANGED
@@ -68,6 +68,12 @@ class KuberKit::UI::Simple
|
|
68
68
|
print_text(title, text, color: String::Colors::YELLOW)
|
69
69
|
end
|
70
70
|
|
71
|
+
def prompt(text, options, &callback)
|
72
|
+
print_info("Select", text)
|
73
|
+
result = $stdin.gets.chomp
|
74
|
+
callback.call(result)
|
75
|
+
end
|
76
|
+
|
71
77
|
private
|
72
78
|
def print_text(title, text, color:)
|
73
79
|
puts "#{title.colorize(color)}\r\n #{text.colorize(color)}"
|
data/lib/kuber_kit/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module KuberKit
|
2
|
-
VERSION = "0.1
|
3
|
-
end
|
2
|
+
VERSION = "0.2.1"
|
3
|
+
end
|
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.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts-lite
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: net-ssh
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: bundler
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -161,6 +175,7 @@ files:
|
|
161
175
|
- example/images/ruby_app2/build_context/example_file.txt
|
162
176
|
- example/images/ruby_app2/image.rb
|
163
177
|
- example/infrastructure/artifacts.rb
|
178
|
+
- example/infrastructure/build_servers.rb
|
164
179
|
- example/infrastructure/env_files.rb
|
165
180
|
- example/infrastructure/registries.rb
|
166
181
|
- example/infrastructure/templates.rb
|
@@ -172,6 +187,7 @@ files:
|
|
172
187
|
- lib/kuber_kit/actions/env_file_reader.rb
|
173
188
|
- lib/kuber_kit/actions/image_compiler.rb
|
174
189
|
- lib/kuber_kit/actions/kubectl_applier.rb
|
190
|
+
- lib/kuber_kit/actions/kubectl_attacher.rb
|
175
191
|
- lib/kuber_kit/actions/service_deployer.rb
|
176
192
|
- lib/kuber_kit/actions/service_reader.rb
|
177
193
|
- lib/kuber_kit/actions/template_reader.rb
|
@@ -186,6 +202,9 @@ files:
|
|
186
202
|
- lib/kuber_kit/core/artifacts/artifact_store.rb
|
187
203
|
- lib/kuber_kit/core/artifacts/git.rb
|
188
204
|
- lib/kuber_kit/core/artifacts/local.rb
|
205
|
+
- lib/kuber_kit/core/build_servers/abstract_build_server.rb
|
206
|
+
- lib/kuber_kit/core/build_servers/build_server.rb
|
207
|
+
- lib/kuber_kit/core/build_servers/build_server_store.rb
|
189
208
|
- lib/kuber_kit/core/configuration.rb
|
190
209
|
- lib/kuber_kit/core/configuration_definition.rb
|
191
210
|
- lib/kuber_kit/core/configuration_definition_factory.rb
|
@@ -211,6 +230,7 @@ files:
|
|
211
230
|
- lib/kuber_kit/core/service_definition_factory.rb
|
212
231
|
- lib/kuber_kit/core/service_factory.rb
|
213
232
|
- lib/kuber_kit/core/service_store.rb
|
233
|
+
- lib/kuber_kit/core/store.rb
|
214
234
|
- lib/kuber_kit/core/templates/abstract_template.rb
|
215
235
|
- lib/kuber_kit/core/templates/artifact_file.rb
|
216
236
|
- lib/kuber_kit/core/templates/template_store.rb
|
@@ -223,12 +243,13 @@ files:
|
|
223
243
|
- lib/kuber_kit/extensions/indocker_compat.rb
|
224
244
|
- lib/kuber_kit/extensions/inspectable.rb
|
225
245
|
- lib/kuber_kit/image_compiler/action_handler.rb
|
246
|
+
- lib/kuber_kit/image_compiler/build_server_pool.rb
|
247
|
+
- lib/kuber_kit/image_compiler/build_server_pool_factory.rb
|
226
248
|
- lib/kuber_kit/image_compiler/compiler.rb
|
227
249
|
- lib/kuber_kit/image_compiler/image_build_dir_creator.rb
|
228
250
|
- lib/kuber_kit/image_compiler/image_builder.rb
|
229
251
|
- lib/kuber_kit/image_compiler/image_dependency_resolver.rb
|
230
252
|
- lib/kuber_kit/image_compiler/version_tag_builder.rb
|
231
|
-
- lib/kuber_kit/preprocessing/dir_preprocessor.rb
|
232
253
|
- lib/kuber_kit/preprocessing/file_preprocessor.rb
|
233
254
|
- lib/kuber_kit/preprocessing/text_preprocessor.rb
|
234
255
|
- lib/kuber_kit/service_deployer/action_handler.rb
|
@@ -240,18 +261,19 @@ files:
|
|
240
261
|
- lib/kuber_kit/service_reader/action_handler.rb
|
241
262
|
- lib/kuber_kit/service_reader/reader.rb
|
242
263
|
- lib/kuber_kit/shell/abstract_shell.rb
|
243
|
-
- lib/kuber_kit/shell/bash_commands.rb
|
244
264
|
- lib/kuber_kit/shell/command_counter.rb
|
245
|
-
- lib/kuber_kit/shell/
|
246
|
-
- lib/kuber_kit/shell/
|
247
|
-
- lib/kuber_kit/shell/
|
265
|
+
- lib/kuber_kit/shell/commands/bash_commands.rb
|
266
|
+
- lib/kuber_kit/shell/commands/docker_commands.rb
|
267
|
+
- lib/kuber_kit/shell/commands/git_commands.rb
|
268
|
+
- lib/kuber_kit/shell/commands/kubectl_commands.rb
|
269
|
+
- lib/kuber_kit/shell/commands/rsync_commands.rb
|
248
270
|
- lib/kuber_kit/shell/local_shell.rb
|
249
|
-
- lib/kuber_kit/shell/
|
271
|
+
- lib/kuber_kit/shell/ssh_session.rb
|
272
|
+
- lib/kuber_kit/shell/ssh_shell.rb
|
250
273
|
- lib/kuber_kit/template_reader/abstract_template_reader.rb
|
251
274
|
- lib/kuber_kit/template_reader/artifact_file_reader.rb
|
252
275
|
- lib/kuber_kit/template_reader/reader.rb
|
253
276
|
- lib/kuber_kit/tools/file_presence_checker.rb
|
254
|
-
- lib/kuber_kit/tools/files_sync.rb
|
255
277
|
- lib/kuber_kit/tools/logger_factory.rb
|
256
278
|
- lib/kuber_kit/ui.rb
|
257
279
|
- lib/kuber_kit/ui/interactive.rb
|
@@ -261,7 +283,7 @@ homepage: https://github.com/ArtStation/kuber_kit
|
|
261
283
|
licenses:
|
262
284
|
- MIT
|
263
285
|
metadata: {}
|
264
|
-
post_install_message:
|
286
|
+
post_install_message:
|
265
287
|
rdoc_options: []
|
266
288
|
require_paths:
|
267
289
|
- lib
|
@@ -277,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
299
|
version: '0'
|
278
300
|
requirements: []
|
279
301
|
rubygems_version: 3.0.8
|
280
|
-
signing_key:
|
302
|
+
signing_key:
|
281
303
|
specification_version: 4
|
282
304
|
summary: Docker Containers Build & Deployment
|
283
305
|
test_files: []
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class KuberKit::Preprocessing::DirPreprocessor
|
2
|
-
include KuberKit::Import[
|
3
|
-
"preprocessing.file_preprocessor",
|
4
|
-
"shell.bash_commands"
|
5
|
-
]
|
6
|
-
|
7
|
-
def compile(shell, source_dir, destination_dir, context_helper: nil)
|
8
|
-
shell.recursive_list_files(source_dir).each do |source_file_path|
|
9
|
-
relative_path = source_file_path.sub(source_dir, '')
|
10
|
-
destination_file_path = File.join(destination_dir, relative_path)
|
11
|
-
|
12
|
-
file_preprocessor.compile(
|
13
|
-
shell, source_file_path,
|
14
|
-
destination_path: destination_file_path,
|
15
|
-
context_helper: context_helper
|
16
|
-
)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'shellwords'
|
3
|
-
|
4
|
-
class KuberKit::Shell::KubectlCommands
|
5
|
-
def apply_file(shell, file_path, kubeconfig_path: nil)
|
6
|
-
command_parts = []
|
7
|
-
if kubeconfig_path
|
8
|
-
command_parts << "KUBECONFIG=#{kubeconfig_path}"
|
9
|
-
end
|
10
|
-
|
11
|
-
command_parts << "kubectl apply -f #{file_path}"
|
12
|
-
|
13
|
-
shell.exec!(command_parts.join(" "))
|
14
|
-
end
|
15
|
-
|
16
|
-
def rolling_restart(shell, deployment_name, kubeconfig_path: nil)
|
17
|
-
patch_deployment(shell, deployment_name, {
|
18
|
-
spec: {
|
19
|
-
template: {
|
20
|
-
metadata: {
|
21
|
-
labels: {
|
22
|
-
redeploy: "$(date +%s)"
|
23
|
-
}
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}, kubeconfig_path: kubeconfig_path)
|
28
|
-
end
|
29
|
-
|
30
|
-
def patch_deployment(shell, deployment_name, specs, kubeconfig_path: nil)
|
31
|
-
command_parts = []
|
32
|
-
if kubeconfig_path
|
33
|
-
command_parts << "KUBECONFIG=#{kubeconfig_path}"
|
34
|
-
end
|
35
|
-
|
36
|
-
specs_json = JSON.dump(specs).gsub('"', '\"')
|
37
|
-
|
38
|
-
command_parts << %Q{kubectl patch deployment #{deployment_name} -p "#{specs_json}"}
|
39
|
-
|
40
|
-
shell.exec!(command_parts.join(" "))
|
41
|
-
end
|
42
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
class KuberKit::Shell::RsyncCommands
|
2
|
-
def rsync(shell, source_path, target_path, exclude: nil)
|
3
|
-
# Add a trailing slash to directory to have behavior similar to CP command
|
4
|
-
if path_is_directory?(source_path) && !source_path.end_with?("/")
|
5
|
-
source_path = "#{source_path}/"
|
6
|
-
end
|
7
|
-
|
8
|
-
args = [source_path, target_path]
|
9
|
-
if exclude
|
10
|
-
args << "--exclude=#{exclude}"
|
11
|
-
end
|
12
|
-
|
13
|
-
shell.exec!(%Q{rsync -a #{args.join(' ')}})
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
def path_is_directory?(path)
|
18
|
-
File.directory?(path)
|
19
|
-
end
|
20
|
-
end
|