kuber_kit 0.2.8 → 0.3.3
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/Gemfile.lock +15 -13
- data/TODO.md +5 -6
- data/bin/{console → kit_console} +0 -0
- data/example/app_data/docker_compose.yml +6 -0
- data/example/configurations/review.rb +1 -1
- data/example/images/ruby_app/Dockerfile +1 -1
- data/example/images/ruby_app/image.rb +3 -0
- data/example/infrastructure/build_servers.rb +5 -5
- data/example/infrastructure/templates.rb +5 -0
- data/example/services/compose_app.rb +10 -0
- data/example/services/env_file.rb +1 -1
- data/lib/kuber_kit.rb +9 -3
- data/lib/kuber_kit/actions/configuration_loader.rb +6 -1
- data/lib/kuber_kit/actions/kubectl_applier.rb +2 -2
- data/lib/kuber_kit/actions/kubectl_attacher.rb +2 -2
- data/lib/kuber_kit/configs.rb +5 -2
- data/lib/kuber_kit/container.rb +10 -2
- data/lib/kuber_kit/core/configuration.rb +13 -6
- data/lib/kuber_kit/core/configuration_definition.rb +22 -9
- data/lib/kuber_kit/core/configuration_factory.rb +9 -9
- data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +3 -2
- data/lib/kuber_kit/core/context_helper/{context_args.rb → context_vars.rb} +5 -5
- data/lib/kuber_kit/core/context_helper/image_helper.rb +17 -0
- data/lib/kuber_kit/core/image.rb +3 -1
- data/lib/kuber_kit/core/image_definition.rb +7 -5
- data/lib/kuber_kit/core/service.rb +4 -4
- data/lib/kuber_kit/core/service_definition.rb +3 -3
- data/lib/kuber_kit/core/service_factory.rb +6 -6
- data/lib/kuber_kit/extensions/indocker_compat.rb +4 -0
- data/lib/kuber_kit/image_compiler/compiler.rb +1 -1
- data/lib/kuber_kit/service_deployer/deployer.rb +4 -2
- data/lib/kuber_kit/service_deployer/strategies/docker.rb +41 -0
- data/lib/kuber_kit/service_deployer/strategies/docker_compose.rb +33 -0
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +34 -7
- data/lib/kuber_kit/service_deployer/strategy_detector.rb +1 -1
- data/lib/kuber_kit/shell/abstract_shell.rb +4 -0
- data/lib/kuber_kit/shell/commands/docker_commands.rb +33 -0
- data/lib/kuber_kit/shell/commands/docker_compose_commands.rb +17 -0
- data/lib/kuber_kit/shell/commands/kubectl_commands.rb +11 -12
- data/lib/kuber_kit/shell/local_shell.rb +14 -0
- data/lib/kuber_kit/shell/ssh_shell.rb +4 -0
- data/lib/kuber_kit/version.rb +1 -1
- metadata +10 -6
- data/lib/kuber_kit/service_deployer/strategies/kubernetes_runner.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae284766e125c54579032cd54c29d602848f95a9a91e07c357ab1b985632a9d1
|
4
|
+
data.tar.gz: 9a9c7a194893cdc39c7629fbda8e03bb7da6b77583899995c14a511f3b152943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cbef254939ce54ff789fcde11ca3db500bfc552f75768bb9424dbdef682830eceed216b046f5930b95e45c8985c2b77e6ce2947e277951e718b1f38df62af29
|
7
|
+
data.tar.gz: bb571f10d8f4e41612c31e1616138e45a54134b92b4b8f9a9577083fc175982e3e5f1a77f1ec564a160ce88f46f76d57d143a8968b8282c92d66f4cb2e2f4220
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kuber_kit (0.
|
4
|
+
kuber_kit (0.3.3)
|
5
5
|
cli-ui
|
6
6
|
contracts-lite
|
7
7
|
dry-auto_inject
|
@@ -35,23 +35,25 @@ GEM
|
|
35
35
|
coderay (~> 1.1)
|
36
36
|
method_source (~> 1.0)
|
37
37
|
rake (10.5.0)
|
38
|
-
rspec (3.
|
39
|
-
rspec-core (~> 3.
|
40
|
-
rspec-expectations (~> 3.
|
41
|
-
rspec-mocks (~> 3.
|
42
|
-
rspec-core (3.
|
43
|
-
rspec-support (~> 3.
|
44
|
-
rspec-expectations (3.
|
38
|
+
rspec (3.10.0)
|
39
|
+
rspec-core (~> 3.10.0)
|
40
|
+
rspec-expectations (~> 3.10.0)
|
41
|
+
rspec-mocks (~> 3.10.0)
|
42
|
+
rspec-core (3.10.0)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-expectations (3.10.0)
|
45
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
-
rspec-support (~> 3.
|
47
|
-
rspec-mocks (3.
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-mocks (3.10.0)
|
48
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
-
rspec-support (~> 3.
|
50
|
-
rspec-support (3.
|
51
|
-
simplecov (0.
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-support (3.10.0)
|
51
|
+
simplecov (0.20.0)
|
52
52
|
docile (~> 1.1)
|
53
53
|
simplecov-html (~> 0.11)
|
54
|
+
simplecov_json_formatter (~> 0.1)
|
54
55
|
simplecov-html (0.12.3)
|
56
|
+
simplecov_json_formatter (0.1.2)
|
55
57
|
thor (1.0.1)
|
56
58
|
|
57
59
|
PLATFORMS
|
data/TODO.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
- find a way to always deploy some service, e.g. for migrations and env_files
|
2
|
-
- allow setting default configuration for kuberkit using env variable
|
3
|
-
- add ability to set container health checks
|
4
|
-
- implement interactive shell.exec!
|
5
|
-
- allow deploying only services enabled for specific configuration
|
6
1
|
- list services and require confirmation before deployment
|
7
|
-
-
|
2
|
+
- kit attach should list available deployments/pods, and ask for specific container if it has multiple containers
|
3
|
+
- add kit logs support, should work similar to kit attach
|
4
|
+
- allow deploying only services enabled for specific configuration
|
5
|
+
- find a way to always deploy some service, e.g. for migrations and env_files
|
6
|
+
- add ability to set container health checks
|
8
7
|
- template should be able to set default attributes
|
9
8
|
- template should be able to depend on image?
|
data/bin/{console → kit_console}
RENAMED
File without changes
|
@@ -2,6 +2,9 @@ KuberKit
|
|
2
2
|
.define_image(:ruby_app)
|
3
3
|
.registry(:default)
|
4
4
|
.depends_on(:ruby, :app_sources)
|
5
|
+
.build_vars({
|
6
|
+
example_file_name: "example.txt"
|
7
|
+
})
|
5
8
|
.before_build do |context_helper, build_dir|
|
6
9
|
# copy file: local artifact
|
7
10
|
source_path = context_helper.artifact_path(:kuber_kit_example_data, "test.txt")
|
@@ -1,8 +1,8 @@
|
|
1
1
|
ENV['SSH_TEST_HOST'] ||= "indocker.artstn.ninja"
|
2
2
|
ENV['SSH_TEST_USER'] ||= "kuber_kit"
|
3
3
|
|
4
|
-
KuberKit.add_build_server(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
)
|
4
|
+
# KuberKit.add_build_server(
|
5
|
+
# KuberKit::Core::BuildServers::BuildServer
|
6
|
+
# .new(:remote_bs)
|
7
|
+
# .setup(host: ENV['SSH_TEST_HOST'], user: ENV['SSH_TEST_USER'], port: 22)
|
8
|
+
# )
|
@@ -6,4 +6,9 @@ KuberKit.add_template(
|
|
6
6
|
KuberKit.add_template(
|
7
7
|
KuberKit::Core::Templates::ArtifactFile
|
8
8
|
.new(:env_file, artifact_name: :kuber_kit_example_data, file_path: "env_file.yml")
|
9
|
+
)
|
10
|
+
|
11
|
+
KuberKit.add_template(
|
12
|
+
KuberKit::Core::Templates::ArtifactFile
|
13
|
+
.new(:docker_compose, artifact_name: :kuber_kit_example_data, file_path: "docker_compose.yml")
|
9
14
|
)
|
data/lib/kuber_kit.rb
CHANGED
@@ -57,7 +57,7 @@ module KuberKit
|
|
57
57
|
autoload :ImageHelper, 'core/context_helper/image_helper'
|
58
58
|
autoload :ServiceHelper, 'core/context_helper/service_helper'
|
59
59
|
autoload :ContextHelperFactory, 'core/context_helper/context_helper_factory'
|
60
|
-
autoload :
|
60
|
+
autoload :ContextVars, 'core/context_helper/context_vars'
|
61
61
|
end
|
62
62
|
|
63
63
|
module Registries
|
@@ -88,6 +88,7 @@ module KuberKit
|
|
88
88
|
module Commands
|
89
89
|
autoload :BashCommands, 'shell/commands/bash_commands'
|
90
90
|
autoload :DockerCommands, 'shell/commands/docker_commands'
|
91
|
+
autoload :DockerComposeCommands, 'shell/commands/docker_compose_commands'
|
91
92
|
autoload :GitCommands, 'shell/commands/git_commands'
|
92
93
|
autoload :RsyncCommands, 'shell/commands/rsync_commands'
|
93
94
|
autoload :KubectlCommands, 'shell/commands/kubectl_commands'
|
@@ -145,8 +146,9 @@ module KuberKit
|
|
145
146
|
|
146
147
|
module Strategies
|
147
148
|
autoload :Abstract, 'service_deployer/strategies/abstract'
|
149
|
+
autoload :Docker, 'service_deployer/strategies/docker'
|
150
|
+
autoload :DockerCompose, 'service_deployer/strategies/docker_compose'
|
148
151
|
autoload :Kubernetes, 'service_deployer/strategies/kubernetes'
|
149
|
-
autoload :KubernetesRunner, 'service_deployer/strategies/kubernetes_runner'
|
150
152
|
end
|
151
153
|
end
|
152
154
|
|
@@ -209,6 +211,10 @@ module KuberKit
|
|
209
211
|
!!@debug_mode
|
210
212
|
end
|
211
213
|
|
214
|
+
def deprecation_warnings_disabled?
|
215
|
+
Container["configs"].deprecation_warnings_disabled
|
216
|
+
end
|
217
|
+
|
212
218
|
def current_configuration
|
213
219
|
if @configuration_name.nil?
|
214
220
|
raise "Please set configuration name before calling current_configuration"
|
@@ -217,7 +223,7 @@ module KuberKit
|
|
217
223
|
end
|
218
224
|
|
219
225
|
def global_build_vars
|
220
|
-
KuberKit::Core::ContextHelper::
|
226
|
+
KuberKit::Core::ContextHelper::ContextVars.new(current_configuration.global_build_vars)
|
221
227
|
end
|
222
228
|
|
223
229
|
def add_registry(registry)
|
@@ -27,7 +27,7 @@ class KuberKit::Actions::ConfigurationLoader
|
|
27
27
|
services_path = options[:services_path] || File.join(root_path, configs.services_dirname)
|
28
28
|
infra_path = options[:infra_path] || File.join(root_path, configs.infra_dirname)
|
29
29
|
configurations_path = options[:configurations_path] || File.join(root_path, configs.configurations_dirname)
|
30
|
-
configuration_name = options[:configuration]
|
30
|
+
configuration_name = ENV["KUBER_KIT_CONFIGURATION"] || options[:configuration]
|
31
31
|
|
32
32
|
logger.info "Launching kuber_kit with:"
|
33
33
|
logger.info " Root path: #{root_path.to_s.yellow}"
|
@@ -56,6 +56,11 @@ class KuberKit::Actions::ConfigurationLoader
|
|
56
56
|
|
57
57
|
ui.create_task("Loading image definitions") do |task|
|
58
58
|
files = image_store.load_definitions(images_path)
|
59
|
+
|
60
|
+
configs.additional_images_paths.each do |path|
|
61
|
+
files += image_store.load_definitions(path)
|
62
|
+
end
|
63
|
+
|
59
64
|
task.update_title("Loaded #{files.count} image definitions")
|
60
65
|
end
|
61
66
|
|
@@ -8,9 +8,9 @@ class KuberKit::Actions::KubectlApplier
|
|
8
8
|
Contract String, Hash => Any
|
9
9
|
def call(file_path, options)
|
10
10
|
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
11
|
-
|
11
|
+
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
12
12
|
ui.create_task("Applying file: #{file_path}") do |task|
|
13
|
-
kubectl_commands.apply_file(local_shell, file_path, kubeconfig_path: kubeconfig_path, namespace:
|
13
|
+
kubectl_commands.apply_file(local_shell, file_path, kubeconfig_path: kubeconfig_path, namespace: deployer_namespace)
|
14
14
|
task.update_title("Applied file: #{file_path}")
|
15
15
|
end
|
16
16
|
|
@@ -8,13 +8,13 @@ class KuberKit::Actions::KubectlAttacher
|
|
8
8
|
Contract 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
13
|
kubectl_commands.exec(
|
14
14
|
local_shell, pod_name, "bash", args: "-it",
|
15
15
|
kubeconfig_path: kubeconfig_path,
|
16
16
|
interactive: true,
|
17
|
-
namespace:
|
17
|
+
namespace: deployer_namespace
|
18
18
|
)
|
19
19
|
|
20
20
|
true
|
data/lib/kuber_kit/configs.rb
CHANGED
@@ -4,7 +4,8 @@ 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, :
|
7
|
+
:artifact_clone_dir, :service_config_dir, :deployer_strategy, :compile_simultaneous_limit,
|
8
|
+
:additional_images_paths, :deprecation_warnings_disabled
|
8
9
|
]
|
9
10
|
DOCKER_IGNORE_LIST = [
|
10
11
|
'Dockerfile',
|
@@ -46,8 +47,10 @@ class KuberKit::Configs
|
|
46
47
|
set :configurations_dirname, "configurations"
|
47
48
|
set :artifact_clone_dir, "/tmp/kuber_kit/artifacts"
|
48
49
|
set :service_config_dir, "/tmp/kuber_kit/services"
|
49
|
-
set :
|
50
|
+
set :deployer_strategy, :kubernetes
|
50
51
|
set :compile_simultaneous_limit, 5
|
52
|
+
set :additional_images_paths, []
|
53
|
+
set :deprecation_warnings_disabled, false
|
51
54
|
end
|
52
55
|
|
53
56
|
def items
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -117,6 +117,10 @@ class KuberKit::Container
|
|
117
117
|
KuberKit::Shell::Commands::DockerCommands.new
|
118
118
|
end
|
119
119
|
|
120
|
+
register "shell.docker_compose_commands" do
|
121
|
+
KuberKit::Shell::Commands::DockerComposeCommands.new
|
122
|
+
end
|
123
|
+
|
120
124
|
register "shell.git_commands" do
|
121
125
|
KuberKit::Shell::Commands::GitCommands.new
|
122
126
|
end
|
@@ -229,8 +233,12 @@ class KuberKit::Container
|
|
229
233
|
KuberKit::ServiceDeployer::Strategies::Kubernetes.new
|
230
234
|
end
|
231
235
|
|
232
|
-
register "service_deployer.strategies.
|
233
|
-
KuberKit::ServiceDeployer::Strategies::
|
236
|
+
register "service_deployer.strategies.docker" do
|
237
|
+
KuberKit::ServiceDeployer::Strategies::Docker.new
|
238
|
+
end
|
239
|
+
|
240
|
+
register "service_deployer.strategies.docker_compose" do
|
241
|
+
KuberKit::ServiceDeployer::Strategies::DockerCompose.new
|
234
242
|
end
|
235
243
|
|
236
244
|
register "service_reader.action_handler" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class KuberKit::Core::Configuration
|
2
2
|
attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path,
|
3
|
-
:
|
3
|
+
:deployer_strategy, :deployer_namespace, :services_attributes, :build_servers,
|
4
4
|
:global_build_vars
|
5
5
|
|
6
6
|
Contract KeywordArgs[
|
@@ -10,14 +10,14 @@ class KuberKit::Core::Configuration
|
|
10
10
|
env_files: Hash,
|
11
11
|
templates: Hash,
|
12
12
|
kubeconfig_path: Maybe[String],
|
13
|
-
|
14
|
-
|
13
|
+
deployer_strategy: Symbol,
|
14
|
+
deployer_namespace: Maybe[Symbol],
|
15
15
|
services_attributes: HashOf[Symbol => Hash],
|
16
16
|
build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer],
|
17
17
|
global_build_vars: HashOf[Symbol => Any],
|
18
18
|
] => Any
|
19
19
|
def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:,
|
20
|
-
|
20
|
+
deployer_strategy:, deployer_namespace:, services_attributes:, build_servers:,
|
21
21
|
global_build_vars:)
|
22
22
|
@name = name
|
23
23
|
@artifacts = artifacts
|
@@ -25,8 +25,8 @@ class KuberKit::Core::Configuration
|
|
25
25
|
@env_files = env_files
|
26
26
|
@templates = templates
|
27
27
|
@kubeconfig_path = kubeconfig_path
|
28
|
-
@
|
29
|
-
@
|
28
|
+
@deployer_strategy = deployer_strategy
|
29
|
+
@deployer_namespace = deployer_namespace
|
30
30
|
@build_servers = build_servers
|
31
31
|
@services_attributes = services_attributes
|
32
32
|
@global_build_vars = global_build_vars
|
@@ -35,4 +35,11 @@ class KuberKit::Core::Configuration
|
|
35
35
|
def service_attributes(service_name)
|
36
36
|
services_attributes[service_name.to_sym] || {}
|
37
37
|
end
|
38
|
+
|
39
|
+
def global_build_args
|
40
|
+
unless KuberKit.deprecation_warnings_disabled?
|
41
|
+
puts "DEPRECATION: global_build_args is deprecated, please use global_build_vars instead"
|
42
|
+
end
|
43
|
+
global_build_vars
|
44
|
+
end
|
38
45
|
end
|
@@ -23,8 +23,8 @@ class KuberKit::Core::ConfigurationDefinition
|
|
23
23
|
env_files: @env_files,
|
24
24
|
templates: @templates,
|
25
25
|
kubeconfig_path: @kubeconfig_path,
|
26
|
-
|
27
|
-
|
26
|
+
deployer_strategy: @deployer_strategy,
|
27
|
+
deployer_namespace: @deployer_namespace,
|
28
28
|
enabled_services: @enabled_services,
|
29
29
|
build_servers: @build_servers,
|
30
30
|
services_attributes: @services_attributes,
|
@@ -82,22 +82,35 @@ class KuberKit::Core::ConfigurationDefinition
|
|
82
82
|
self
|
83
83
|
end
|
84
84
|
|
85
|
-
def
|
86
|
-
@
|
85
|
+
def deployer_namespace(namespace)
|
86
|
+
@deployer_namespace = namespace
|
87
87
|
|
88
88
|
self
|
89
89
|
end
|
90
90
|
|
91
|
-
def
|
92
|
-
@
|
91
|
+
def deployer_strategy(path)
|
92
|
+
@deployer_strategy = path
|
93
93
|
|
94
94
|
self
|
95
95
|
end
|
96
96
|
|
97
|
-
def enabled_services(
|
98
|
-
|
99
|
-
|
97
|
+
def enabled_services(services)
|
98
|
+
if services.is_a?(Hash)
|
99
|
+
@enabled_services += services.keys.map(&:to_sym)
|
100
|
+
@services_attributes = @services_attributes.merge(services)
|
101
|
+
return self
|
102
|
+
end
|
103
|
+
|
104
|
+
if services.is_a?(Array)
|
105
|
+
@enabled_services += services.map(&:to_sym)
|
106
|
+
return self
|
107
|
+
end
|
108
|
+
|
109
|
+
raise KuberKit::Error, "#enabled_services method accepts only Array or Hash"
|
110
|
+
end
|
100
111
|
|
112
|
+
def service_attributes(services)
|
113
|
+
@services_attributes = @services_attributes.merge(services)
|
101
114
|
self
|
102
115
|
end
|
103
116
|
|
@@ -20,15 +20,15 @@ class KuberKit::Core::ConfigurationFactory
|
|
20
20
|
build_servers = fetch_build_servers(configuration_attrs.build_servers)
|
21
21
|
|
22
22
|
KuberKit::Core::Configuration.new(
|
23
|
-
name:
|
24
|
-
artifacts:
|
25
|
-
registries:
|
26
|
-
env_files:
|
27
|
-
templates:
|
28
|
-
kubeconfig_path:
|
29
|
-
|
30
|
-
|
31
|
-
build_servers:
|
23
|
+
name: configuration_attrs.name,
|
24
|
+
artifacts: artifacts,
|
25
|
+
registries: registries,
|
26
|
+
env_files: env_files,
|
27
|
+
templates: templates,
|
28
|
+
kubeconfig_path: configuration_attrs.kubeconfig_path,
|
29
|
+
deployer_strategy: configuration_attrs.deployer_strategy || configs.deployer_strategy,
|
30
|
+
deployer_namespace: configuration_attrs.deployer_namespace,
|
31
|
+
build_servers: build_servers,
|
32
32
|
services_attributes: configuration_attrs.services_attributes,
|
33
33
|
global_build_vars: configuration_attrs.global_build_vars || {},
|
34
34
|
)
|
@@ -5,12 +5,13 @@ class KuberKit::Core::ContextHelper::ContextHelperFactory
|
|
5
5
|
env_file_reader: "env_file_reader.action_handler"
|
6
6
|
]
|
7
7
|
|
8
|
-
def build_image_context(shell)
|
8
|
+
def build_image_context(shell, image)
|
9
9
|
KuberKit::Core::ContextHelper::ImageHelper.new(
|
10
10
|
image_store: image_store,
|
11
11
|
artifact_store: artifact_store,
|
12
12
|
shell: shell,
|
13
|
-
env_file_reader: env_file_reader
|
13
|
+
env_file_reader: env_file_reader,
|
14
|
+
image: image
|
14
15
|
)
|
15
16
|
end
|
16
17
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class KuberKit::Core::ContextHelper::
|
1
|
+
class KuberKit::Core::ContextHelper::ContextVars
|
2
2
|
attr_reader :parent, :parent_name
|
3
3
|
|
4
|
-
def initialize(
|
5
|
-
@
|
4
|
+
def initialize(context_vars, parent_name = nil, parent = nil)
|
5
|
+
@context_vars = context_vars
|
6
6
|
@parent_name = parent_name
|
7
7
|
@parent = parent
|
8
8
|
end
|
@@ -12,8 +12,8 @@ class KuberKit::Core::ContextHelper::ContextArgs
|
|
12
12
|
raise ArgumentError.new("context args does not accept any arguments")
|
13
13
|
end
|
14
14
|
|
15
|
-
value = @
|
16
|
-
raise(KuberKit::Error, "build arg '#{format_arg(name)}' is not defined, available args: #{@
|
15
|
+
value = @context_vars.fetch(name) do
|
16
|
+
raise(KuberKit::Error, "build arg '#{format_arg(name)}' is not defined, available args: #{@context_vars.inspect}")
|
17
17
|
end
|
18
18
|
|
19
19
|
if value.is_a?(Hash)
|
@@ -1,2 +1,19 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::ImageHelper < KuberKit::Core::ContextHelper::BaseHelper
|
2
|
+
def initialize(image_store:, artifact_store:, shell:, env_file_reader:, image:)
|
3
|
+
super(
|
4
|
+
image_store: image_store,
|
5
|
+
artifact_store: artifact_store,
|
6
|
+
shell: shell,
|
7
|
+
env_file_reader: env_file_reader
|
8
|
+
)
|
9
|
+
@image = image
|
10
|
+
end
|
11
|
+
|
12
|
+
def image_name
|
13
|
+
@image.name.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
def build_vars
|
17
|
+
KuberKit::Core::ContextHelper::ContextVars.new(@image.build_vars)
|
18
|
+
end
|
2
19
|
end
|
data/lib/kuber_kit/core/image.rb
CHANGED
@@ -33,7 +33,9 @@ class KuberKit::Core::Image
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def build_args
|
36
|
-
|
36
|
+
unless KuberKit.deprecation_warnings_disabled?
|
37
|
+
puts "WARNING: build_args is deprecated, please use build_vars instead"
|
38
|
+
end
|
37
39
|
build_vars
|
38
40
|
end
|
39
41
|
end
|
@@ -44,7 +44,9 @@ class KuberKit::Core::ImageDefinition
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def build_args(value = nil, &block)
|
47
|
-
|
47
|
+
unless KuberKit.deprecation_warnings_disabled?
|
48
|
+
puts "WARNING: build_args is deprecated, please use build_vars instead"
|
49
|
+
end
|
48
50
|
build_vars(value, *block)
|
49
51
|
end
|
50
52
|
|
@@ -66,14 +68,14 @@ class KuberKit::Core::ImageDefinition
|
|
66
68
|
self
|
67
69
|
end
|
68
70
|
|
69
|
-
def before_build(&block)
|
70
|
-
@before_build_callback = block
|
71
|
+
def before_build(lambda_arg = nil, &block)
|
72
|
+
@before_build_callback = lambda_arg || block
|
71
73
|
|
72
74
|
self
|
73
75
|
end
|
74
76
|
|
75
|
-
def after_build(&block)
|
76
|
-
@after_build_callback = block
|
77
|
+
def after_build(lambda_arg = nil, &block)
|
78
|
+
@after_build_callback = lambda_arg || block
|
77
79
|
|
78
80
|
self
|
79
81
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class KuberKit::Core::Service
|
2
2
|
AttributeNotSet = Class.new(Indocker::Error)
|
3
3
|
|
4
|
-
attr_reader :name, :template_name, :tags, :images, :attributes, :
|
4
|
+
attr_reader :name, :template_name, :tags, :images, :attributes, :deployer_strategy
|
5
5
|
|
6
6
|
Contract KeywordArgs[
|
7
7
|
name: Symbol,
|
@@ -9,15 +9,15 @@ class KuberKit::Core::Service
|
|
9
9
|
tags: ArrayOf[Symbol],
|
10
10
|
images: ArrayOf[Symbol],
|
11
11
|
attributes: HashOf[Symbol => Any],
|
12
|
-
|
12
|
+
deployer_strategy: Maybe[Symbol]
|
13
13
|
] => Any
|
14
|
-
def initialize(name:, template_name:, tags:, images:, attributes:,
|
14
|
+
def initialize(name:, template_name:, tags:, images:, attributes:, deployer_strategy:)
|
15
15
|
@name = name
|
16
16
|
@template_name = template_name
|
17
17
|
@tags = tags
|
18
18
|
@images = images
|
19
19
|
@attributes = attributes
|
20
|
-
@
|
20
|
+
@deployer_strategy = deployer_strategy
|
21
21
|
end
|
22
22
|
|
23
23
|
def uri
|
@@ -13,7 +13,7 @@ class KuberKit::Core::ServiceDefinition
|
|
13
13
|
tags: Array(get_value(@tags)).map(&:to_sym),
|
14
14
|
images: Array(get_value(@images)).map(&:to_sym),
|
15
15
|
attributes: get_value(@attributes),
|
16
|
-
|
16
|
+
deployer_strategy: get_value(@deployer_strategy),
|
17
17
|
)
|
18
18
|
end
|
19
19
|
|
@@ -41,8 +41,8 @@ class KuberKit::Core::ServiceDefinition
|
|
41
41
|
self
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
@
|
44
|
+
def deployer_strategy(value = nil, &block)
|
45
|
+
@deployer_strategy = block_given? ? block : value
|
46
46
|
|
47
47
|
self
|
48
48
|
end
|
@@ -12,12 +12,12 @@ class KuberKit::Core::ServiceFactory
|
|
12
12
|
attributes = (service_attrs.attributes || {}).merge(configuration_attributes)
|
13
13
|
|
14
14
|
KuberKit::Core::Service.new(
|
15
|
-
name:
|
16
|
-
template_name:
|
17
|
-
tags:
|
18
|
-
images:
|
19
|
-
attributes:
|
20
|
-
|
15
|
+
name: service_attrs.name,
|
16
|
+
template_name: service_attrs.template_name,
|
17
|
+
tags: service_attrs.tags,
|
18
|
+
images: service_attrs.images,
|
19
|
+
attributes: attributes,
|
20
|
+
deployer_strategy: service_attrs.deployer_strategy,
|
21
21
|
)
|
22
22
|
end
|
23
23
|
end
|
@@ -9,7 +9,7 @@ class KuberKit::ImageCompiler::Compiler
|
|
9
9
|
def compile(shell, image, builds_dir)
|
10
10
|
image_build_dir = File.join(builds_dir, image.name.to_s)
|
11
11
|
|
12
|
-
context_helper = context_helper_factory.build_image_context(shell)
|
12
|
+
context_helper = context_helper_factory.build_image_context(shell, image)
|
13
13
|
image_build_dir_creator.create(shell, image, image_build_dir, context_helper: context_helper)
|
14
14
|
|
15
15
|
image_builder.build(shell, image, image_build_dir, context_helper: context_helper)
|
@@ -4,7 +4,8 @@ class KuberKit::ServiceDeployer::Deployer
|
|
4
4
|
include KuberKit::Import[
|
5
5
|
"core.service_store",
|
6
6
|
"service_deployer.strategies.kubernetes",
|
7
|
-
"service_deployer.strategies.
|
7
|
+
"service_deployer.strategies.docker",
|
8
|
+
"service_deployer.strategies.docker_compose"
|
8
9
|
]
|
9
10
|
|
10
11
|
def initialize(**injected_deps)
|
@@ -38,6 +39,7 @@ class KuberKit::ServiceDeployer::Deployer
|
|
38
39
|
private
|
39
40
|
def add_default_strategies
|
40
41
|
register_strategy(:kubernetes, kubernetes)
|
41
|
-
register_strategy(:
|
42
|
+
register_strategy(:docker, docker)
|
43
|
+
register_strategy(:docker_compose, docker_compose)
|
42
44
|
end
|
43
45
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer::Strategies::Abstract
|
2
|
+
include KuberKit::Import[
|
3
|
+
"shell.docker_commands",
|
4
|
+
"core.image_store",
|
5
|
+
"configs",
|
6
|
+
]
|
7
|
+
|
8
|
+
STRATEGY_OPTIONS = [
|
9
|
+
:container_name,
|
10
|
+
:image_name,
|
11
|
+
:docker_run_args,
|
12
|
+
:docker_run_command,
|
13
|
+
:delete_if_exists
|
14
|
+
]
|
15
|
+
|
16
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
17
|
+
def deploy(shell, service)
|
18
|
+
strategy_options = service.attribute(:deployer, default: {})
|
19
|
+
unknown_options = strategy_options.keys.map(&:to_sym) - STRATEGY_OPTIONS
|
20
|
+
if unknown_options.any?
|
21
|
+
raise KuberKit::Error, "Unknow options for deploy strategy: #{unknown_options}. Available options: #{STRATEGY_OPTIONS}"
|
22
|
+
end
|
23
|
+
|
24
|
+
container_name = strategy_options.fetch(:container_name, service.uri)
|
25
|
+
docker_run_args = strategy_options.fetch(:docker_run_args, nil)
|
26
|
+
docker_run_command = strategy_options.fetch(:docker_run_command, nil)
|
27
|
+
|
28
|
+
image_name = strategy_options.fetch(:image_name, nil)
|
29
|
+
if image_name.nil?
|
30
|
+
raise KuberKit::Error, "image_name is mandatory attribute for this deploy strategy"
|
31
|
+
end
|
32
|
+
image = image_store.get_image(image_name.to_sym)
|
33
|
+
|
34
|
+
delete_enabled = strategy_options.fetch(:delete_if_exists, false)
|
35
|
+
if delete_enabled && docker_commands.container_exists?(shell, container_name)
|
36
|
+
docker_commands.delete_container(shell, container_name)
|
37
|
+
end
|
38
|
+
|
39
|
+
docker_commands.run(shell, image.remote_registry_url, run_args: docker_run_args, run_command: docker_run_command)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDeployer::Strategies::Abstract
|
2
|
+
include KuberKit::Import[
|
3
|
+
"service_reader.reader",
|
4
|
+
"shell.docker_compose_commands",
|
5
|
+
"configs",
|
6
|
+
]
|
7
|
+
|
8
|
+
STRATEGY_OPTIONS = [
|
9
|
+
:service_name,
|
10
|
+
:command_name
|
11
|
+
]
|
12
|
+
|
13
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
14
|
+
def deploy(shell, service)
|
15
|
+
service_config = reader.read(shell, service)
|
16
|
+
config_path = "#{configs.service_config_dir}/#{service.name}.yml"
|
17
|
+
shell.write(config_path, service_config)
|
18
|
+
|
19
|
+
strategy_options = service.attribute(:deployer, default: {})
|
20
|
+
unknown_options = strategy_options.keys.map(&:to_sym) - STRATEGY_OPTIONS
|
21
|
+
if unknown_options.any?
|
22
|
+
raise KuberKit::Error, "Unknow options for deploy strategy: #{unknown_options}. Available options: #{STRATEGY_OPTIONS}"
|
23
|
+
end
|
24
|
+
|
25
|
+
service_name = strategy_options.fetch(:service_name, service.name.to_s)
|
26
|
+
command_name = strategy_options.fetch(:command_name, "bash")
|
27
|
+
|
28
|
+
docker_compose_commands.run(shell, config_path,
|
29
|
+
service: service_name,
|
30
|
+
command: command_name,
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
@@ -5,21 +5,48 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
|
|
5
5
|
"configs",
|
6
6
|
]
|
7
7
|
|
8
|
+
STRATEGY_OPTIONS = [
|
9
|
+
:resource_type,
|
10
|
+
:resource_name,
|
11
|
+
:delete_if_exists,
|
12
|
+
:restart_if_exists
|
13
|
+
]
|
14
|
+
|
8
15
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
9
16
|
def deploy(shell, service)
|
10
17
|
service_config = reader.read(shell, service)
|
11
18
|
config_path = "#{configs.service_config_dir}/#{service.name}.yml"
|
12
19
|
shell.write(config_path, service_config)
|
13
20
|
|
14
|
-
kubeconfig_path
|
15
|
-
|
21
|
+
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
22
|
+
namespace = KuberKit.current_configuration.deployer_namespace
|
23
|
+
|
24
|
+
strategy_options = service.attribute(:deployer, default: {})
|
25
|
+
unknown_options = strategy_options.keys.map(&:to_sym) - STRATEGY_OPTIONS
|
26
|
+
if unknown_options.any?
|
27
|
+
raise KuberKit::Error, "Unknow options for deploy strategy: #{unknown_options}. Available options: #{STRATEGY_OPTIONS}"
|
28
|
+
end
|
29
|
+
|
30
|
+
resource_type = strategy_options.fetch(:resource_type, "deployment")
|
31
|
+
resource_name = strategy_options.fetch(:resource_name, service.uri)
|
32
|
+
|
33
|
+
resource_exists = kubectl_commands.resource_exists?(
|
34
|
+
shell, resource_type, resource_name, kubeconfig_path: kubeconfig_path, namespace: namespace
|
35
|
+
)
|
36
|
+
|
37
|
+
delete_enabled = strategy_options.fetch(:delete_if_exists, false)
|
38
|
+
if delete_enabled && resource_exists
|
39
|
+
kubectl_commands.delete_resource(shell, resource_type, resource_name, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
40
|
+
end
|
16
41
|
|
17
|
-
kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path, namespace:
|
42
|
+
kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
18
43
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
44
|
+
restart_enabled = strategy_options.fetch(:restart_if_exists, true)
|
45
|
+
if restart_enabled && resource_exists
|
46
|
+
kubectl_commands.rolling_restart(
|
47
|
+
shell, resource_type, resource_name,
|
48
|
+
kubeconfig_path: kubeconfig_path, namespace: namespace
|
49
|
+
)
|
23
50
|
end
|
24
51
|
end
|
25
52
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class KuberKit::ServiceDeployer::StrategyDetector
|
2
2
|
Contract KuberKit::Core::Service => Symbol
|
3
3
|
def call(service)
|
4
|
-
service.
|
4
|
+
service.deployer_strategy || KuberKit.current_configuration.deployer_strategy
|
5
5
|
end
|
6
6
|
end
|
@@ -6,6 +6,10 @@ class KuberKit::Shell::AbstractShell
|
|
6
6
|
raise KuberKit::NotImplementedError, "must be implemented"
|
7
7
|
end
|
8
8
|
|
9
|
+
def interactive!(command)
|
10
|
+
raise KuberKit::NotImplementedError, "must be implemented"
|
11
|
+
end
|
12
|
+
|
9
13
|
def read(file_path)
|
10
14
|
raise KuberKit::NotImplementedError, "must be implemented"
|
11
15
|
end
|
@@ -13,4 +13,37 @@ class KuberKit::Shell::Commands::DockerCommands
|
|
13
13
|
def push(shell, tag_name)
|
14
14
|
shell.exec!(%Q{docker push #{tag_name}})
|
15
15
|
end
|
16
|
+
|
17
|
+
def run(shell, image_name, run_args: nil, run_command: nil)
|
18
|
+
command_parts = []
|
19
|
+
command_parts << "docker run"
|
20
|
+
command_parts << run_args if run_args
|
21
|
+
command_parts << image_name
|
22
|
+
command_parts << run_command if run_command
|
23
|
+
|
24
|
+
shell.exec!(command_parts.join(" "))
|
25
|
+
end
|
26
|
+
|
27
|
+
def container_exists?(shell, container_name)
|
28
|
+
result = get_container_id(shell, container_name)
|
29
|
+
result && result != ""
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete_container(shell, container_name)
|
33
|
+
shell.exec!(%Q{docker rm -f #{container_name}})
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_container_id(shell, container_name, only_healthy: false, status: "running")
|
37
|
+
command_parts = []
|
38
|
+
command_parts << "docker ps -a -q"
|
39
|
+
|
40
|
+
if only_healthy
|
41
|
+
command_parts << "--filter=\"health=healthy\""
|
42
|
+
end
|
43
|
+
|
44
|
+
command_parts << "--filter=\"status=#{status}\""
|
45
|
+
command_parts << "--filter=\"name=#{container_name}\""
|
46
|
+
|
47
|
+
shell.exec!(command_parts.join(" "))
|
48
|
+
end
|
16
49
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class KuberKit::Shell::Commands::DockerComposeCommands
|
2
|
+
def run(shell, path, service:, command:, interactive: false)
|
3
|
+
command_parts = [
|
4
|
+
"docker-compose",
|
5
|
+
"-f #{path}",
|
6
|
+
"run",
|
7
|
+
service,
|
8
|
+
command
|
9
|
+
]
|
10
|
+
|
11
|
+
if interactive
|
12
|
+
shell.interactive!(command_parts.join(" "))
|
13
|
+
else
|
14
|
+
shell.exec!(command_parts.join(" "))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -16,9 +16,8 @@ class KuberKit::Shell::Commands::KubectlCommands
|
|
16
16
|
|
17
17
|
command_parts += Array(command_list)
|
18
18
|
|
19
|
-
# TODO: investigate how to do it with shell.
|
20
19
|
if interactive
|
21
|
-
|
20
|
+
shell.interactive!(command_parts.join(" "))
|
22
21
|
else
|
23
22
|
shell.exec!(command_parts.join(" "))
|
24
23
|
end
|
@@ -58,8 +57,16 @@ class KuberKit::Shell::Commands::KubectlCommands
|
|
58
57
|
kubectl_run(shell, command, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
59
58
|
end
|
60
59
|
|
61
|
-
def
|
62
|
-
|
60
|
+
def patch_resource(shell, resource_type, resource_name, specs, kubeconfig_path: nil, namespace: nil)
|
61
|
+
specs_json = JSON.dump(specs).gsub('"', '\"')
|
62
|
+
|
63
|
+
command = %Q{patch #{resource_type} #{resource_name} -p "#{specs_json}"}
|
64
|
+
|
65
|
+
kubectl_run(shell, command, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
66
|
+
end
|
67
|
+
|
68
|
+
def rolling_restart(shell, resource_type, resource_name, kubeconfig_path: nil, namespace: nil)
|
69
|
+
patch_resource(shell, resource_type, resource_name, {
|
63
70
|
spec: {
|
64
71
|
template: {
|
65
72
|
metadata: {
|
@@ -71,12 +78,4 @@ class KuberKit::Shell::Commands::KubectlCommands
|
|
71
78
|
}
|
72
79
|
}, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
73
80
|
end
|
74
|
-
|
75
|
-
def patch_deployment(shell, deployment_name, specs, kubeconfig_path: nil, namespace: nil)
|
76
|
-
specs_json = JSON.dump(specs).gsub('"', '\"')
|
77
|
-
|
78
|
-
command = %Q{patch deployment #{deployment_name} -p "#{specs_json}"}
|
79
|
-
|
80
|
-
kubectl_run(shell, command, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
81
|
-
end
|
82
81
|
end
|
@@ -30,6 +30,20 @@ class KuberKit::Shell::LocalShell < KuberKit::Shell::AbstractShell
|
|
30
30
|
result
|
31
31
|
end
|
32
32
|
|
33
|
+
def interactive!(command, log_command: true)
|
34
|
+
command_number = command_counter.get_number.to_s.rjust(2, "0")
|
35
|
+
|
36
|
+
if log_command
|
37
|
+
logger.info("Interactive: [#{command_number}]: #{command.to_s.cyan}")
|
38
|
+
end
|
39
|
+
|
40
|
+
result = system(command)
|
41
|
+
|
42
|
+
if !$?.success?
|
43
|
+
raise ShellError, "Shell command failed: #{command}\r\n#{result}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
33
47
|
def sync(local_path, remote_path, exclude: nil, delete: true)
|
34
48
|
rsync_commands.rsync(self, local_path, remote_path, exclude: exclude, delete: delete)
|
35
49
|
end
|
@@ -38,6 +38,10 @@ class KuberKit::Shell::SshShell < KuberKit::Shell::LocalShell
|
|
38
38
|
raise ShellError.new(e.message)
|
39
39
|
end
|
40
40
|
|
41
|
+
def interactive!(command, log_command: true)
|
42
|
+
raise "Currently interactive run is not supported for ssh shell."
|
43
|
+
end
|
44
|
+
|
41
45
|
def sync(local_path, remote_path, exclude: nil, delete: true)
|
42
46
|
rsync_commands.rsync(
|
43
47
|
local_shell, local_path, remote_path,
|
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.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts-lite
|
@@ -140,8 +140,8 @@ description: Docker Containers Build & Deployment
|
|
140
140
|
email:
|
141
141
|
- gvalmon@gmail.com
|
142
142
|
executables:
|
143
|
-
- console
|
144
143
|
- kit
|
144
|
+
- kit_console
|
145
145
|
extensions: []
|
146
146
|
extra_rdoc_files: []
|
147
147
|
files:
|
@@ -156,8 +156,9 @@ files:
|
|
156
156
|
- README.md
|
157
157
|
- Rakefile
|
158
158
|
- TODO.md
|
159
|
-
- bin/console
|
160
159
|
- bin/kit
|
160
|
+
- bin/kit_console
|
161
|
+
- example/app_data/docker_compose.yml
|
161
162
|
- example/app_data/env_file.yml
|
162
163
|
- example/app_data/service.yml
|
163
164
|
- example/app_data/test.env
|
@@ -180,6 +181,7 @@ files:
|
|
180
181
|
- example/infrastructure/env_files.rb
|
181
182
|
- example/infrastructure/registries.rb
|
182
183
|
- example/infrastructure/templates.rb
|
184
|
+
- example/services/compose_app.rb
|
183
185
|
- example/services/env_file.rb
|
184
186
|
- example/services/ruby_app.rb
|
185
187
|
- kuber_kit.gemspec
|
@@ -212,8 +214,8 @@ files:
|
|
212
214
|
- lib/kuber_kit/core/configuration_factory.rb
|
213
215
|
- lib/kuber_kit/core/configuration_store.rb
|
214
216
|
- lib/kuber_kit/core/context_helper/base_helper.rb
|
215
|
-
- lib/kuber_kit/core/context_helper/context_args.rb
|
216
217
|
- lib/kuber_kit/core/context_helper/context_helper_factory.rb
|
218
|
+
- lib/kuber_kit/core/context_helper/context_vars.rb
|
217
219
|
- lib/kuber_kit/core/context_helper/image_helper.rb
|
218
220
|
- lib/kuber_kit/core/context_helper/service_helper.rb
|
219
221
|
- lib/kuber_kit/core/env_files/abstract_env_file.rb
|
@@ -258,8 +260,9 @@ files:
|
|
258
260
|
- lib/kuber_kit/service_deployer/deployer.rb
|
259
261
|
- lib/kuber_kit/service_deployer/service_list_resolver.rb
|
260
262
|
- lib/kuber_kit/service_deployer/strategies/abstract.rb
|
263
|
+
- lib/kuber_kit/service_deployer/strategies/docker.rb
|
264
|
+
- lib/kuber_kit/service_deployer/strategies/docker_compose.rb
|
261
265
|
- lib/kuber_kit/service_deployer/strategies/kubernetes.rb
|
262
|
-
- lib/kuber_kit/service_deployer/strategies/kubernetes_runner.rb
|
263
266
|
- lib/kuber_kit/service_deployer/strategy_detector.rb
|
264
267
|
- lib/kuber_kit/service_reader/action_handler.rb
|
265
268
|
- lib/kuber_kit/service_reader/reader.rb
|
@@ -267,6 +270,7 @@ files:
|
|
267
270
|
- lib/kuber_kit/shell/command_counter.rb
|
268
271
|
- lib/kuber_kit/shell/commands/bash_commands.rb
|
269
272
|
- lib/kuber_kit/shell/commands/docker_commands.rb
|
273
|
+
- lib/kuber_kit/shell/commands/docker_compose_commands.rb
|
270
274
|
- lib/kuber_kit/shell/commands/git_commands.rb
|
271
275
|
- lib/kuber_kit/shell/commands/kubectl_commands.rb
|
272
276
|
- lib/kuber_kit/shell/commands/rsync_commands.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class KuberKit::ServiceDeployer::Strategies::KubernetesRunner < KuberKit::ServiceDeployer::Strategies::Abstract
|
2
|
-
include KuberKit::Import[
|
3
|
-
"service_reader.reader",
|
4
|
-
"shell.kubectl_commands",
|
5
|
-
"configs",
|
6
|
-
]
|
7
|
-
|
8
|
-
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
9
|
-
def deploy(shell, service)
|
10
|
-
service_config = reader.read(shell, service)
|
11
|
-
config_path = "#{configs.service_config_dir}/#{service.name}.yml"
|
12
|
-
shell.write(config_path, service_config)
|
13
|
-
|
14
|
-
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
15
|
-
deploy_namespace = KuberKit.current_configuration.deploy_namespace
|
16
|
-
|
17
|
-
deployment_resource_name = service.attribute(:deployment_resource_name, default: service.uri)
|
18
|
-
deployment_resource_type = service.attribute(:deployment_resource_type, default: "job")
|
19
|
-
|
20
|
-
deployment_delete_enabled = service.attribute(:deployment_delete_enabled, default: true)
|
21
|
-
if deployment_delete_enabled
|
22
|
-
delete_resource_if_exists(shell, deployment_resource_type, deployment_resource_name, kubeconfig_path: kubeconfig_path, namespace: deploy_namespace)
|
23
|
-
end
|
24
|
-
|
25
|
-
kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path, namespace: deploy_namespace)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
def delete_resource_if_exists(shell, resource_type, resource_name, kubeconfig_path:, namespace: )
|
30
|
-
unless kubectl_commands.resource_exists?(shell, resource_type, resource_name, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
31
|
-
return false
|
32
|
-
end
|
33
|
-
kubectl_commands.delete_resource(shell, resource_type, resource_name, kubeconfig_path: kubeconfig_path, namespace: namespace)
|
34
|
-
end
|
35
|
-
end
|