kuber_kit 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/TODO.md +4 -2
- data/example/app_data/env_file.yml +10 -0
- data/example/infrastructure/templates.rb +5 -0
- data/example/services/env_file.rb +3 -0
- data/lib/kuber_kit.rb +14 -4
- data/lib/kuber_kit/actions/env_file_reader.rb +3 -5
- data/lib/kuber_kit/actions/image_compiler.rb +3 -13
- data/lib/kuber_kit/actions/service_deployer.rb +3 -3
- data/lib/kuber_kit/actions/service_reader.rb +3 -6
- data/lib/kuber_kit/container.rb +24 -8
- data/lib/kuber_kit/core/configuration.rb +10 -4
- data/lib/kuber_kit/core/configuration_definition.rb +12 -1
- data/lib/kuber_kit/core/configuration_factory.rb +2 -1
- data/lib/kuber_kit/core/context_helper/base_helper.rb +12 -7
- data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +11 -8
- data/lib/kuber_kit/core/context_helper/service_helper.rb +5 -4
- data/lib/kuber_kit/core/service_factory.rb +4 -1
- data/lib/kuber_kit/env_file_reader/action_handler.rb +12 -0
- data/lib/kuber_kit/env_file_reader/reader.rb +4 -4
- data/lib/kuber_kit/env_file_reader/{abstract_env_file_reader.rb → strategies/abstract.rb} +1 -1
- data/lib/kuber_kit/env_file_reader/{artifact_file_reader.rb → strategies/artifact_file.rb} +1 -1
- data/lib/kuber_kit/image_compiler/action_handler.rb +20 -0
- data/lib/kuber_kit/image_compiler/compiler.rb +2 -5
- data/lib/kuber_kit/preprocessing/text_preprocessor.rb +1 -1
- data/lib/kuber_kit/service_deployer/action_handler.rb +16 -0
- data/lib/kuber_kit/service_deployer/deployer.rb +28 -6
- data/lib/kuber_kit/service_deployer/strategies/abstract.rb +1 -1
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +3 -3
- data/lib/kuber_kit/service_deployer/strategy_detector.rb +6 -0
- data/lib/kuber_kit/service_reader/action_handler.rb +13 -0
- data/lib/kuber_kit/{service_deployer/service_reader.rb → service_reader/reader.rb} +1 -1
- data/lib/kuber_kit/version.rb +1 -1
- metadata +12 -6
- data/lib/kuber_kit/service_deployer/service_restarter.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c345ef3a461e5dc43ff910b8fb2cf4e1b4e306407d24d177ff2d8c0b1c894bcb
|
4
|
+
data.tar.gz: 597d9d093ce85c209562104e50763b3711558437baa410fc0d44e491d53f6f4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 240963d8b9452926d6d761b5f47c1464894c2fd115a75905f99b6ceed8ea2f835a97aaa34fa96ddf2dfd5ea22774f3cd5d5df474d7f4f7d99636feebd886c73f
|
7
|
+
data.tar.gz: ef2018ef89bad80de6a11bf6d1682ed8f72d24e261a10cd79f018aea5c66930613a9373b2405757070d78017273c302c6a2cdc2f64b05790f032b58a69000a29
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kuber_kit (0.1.
|
4
|
+
kuber_kit (0.1.6)
|
5
5
|
cli-ui
|
6
6
|
contracts-lite
|
7
7
|
dry-auto_inject
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
cli-ui (1.
|
13
|
+
cli-ui (1.4.0)
|
14
14
|
coderay (1.1.3)
|
15
15
|
concurrent-ruby (1.1.7)
|
16
16
|
contracts-lite (0.15.0)
|
data/TODO.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
-
|
1
|
+
- limit amount of simultaneous image builds
|
2
|
+
- list services and require confirmation before deployment
|
2
3
|
- service factory should make sure that template exists
|
3
4
|
- add build servers support
|
4
|
-
- add build vars support (use images instead of containers)
|
5
|
+
- add build vars support (use images instead of containers)
|
6
|
+
- template should be able to depend on image?
|
@@ -1,4 +1,9 @@
|
|
1
1
|
KuberKit.add_template(
|
2
2
|
KuberKit::Core::Templates::ArtifactFile
|
3
3
|
.new(:service, artifact_name: :kuber_kit_example_data, file_path: "service.yml")
|
4
|
+
)
|
5
|
+
|
6
|
+
KuberKit.add_template(
|
7
|
+
KuberKit::Core::Templates::ArtifactFile
|
8
|
+
.new(:env_file, artifact_name: :kuber_kit_example_data, file_path: "env_file.yml")
|
4
9
|
)
|
data/lib/kuber_kit.rb
CHANGED
@@ -82,6 +82,7 @@ module KuberKit
|
|
82
82
|
end
|
83
83
|
|
84
84
|
module ImageCompiler
|
85
|
+
autoload :ActionHandler, 'image_compiler/action_handler'
|
85
86
|
autoload :Compiler, 'image_compiler/compiler'
|
86
87
|
autoload :ImageBuilder, 'image_compiler/image_builder'
|
87
88
|
autoload :ImageBuildDirCreator, 'image_compiler/image_build_dir_creator'
|
@@ -103,9 +104,13 @@ module KuberKit
|
|
103
104
|
end
|
104
105
|
|
105
106
|
module EnvFileReader
|
107
|
+
autoload :ActionHandler, 'env_file_reader/action_handler'
|
106
108
|
autoload :Reader, 'env_file_reader/reader'
|
107
|
-
|
108
|
-
|
109
|
+
|
110
|
+
module Strategies
|
111
|
+
autoload :Abstract, 'env_file_reader/strategies/abstract'
|
112
|
+
autoload :ArtifactFile, 'env_file_reader/strategies/artifact_file'
|
113
|
+
end
|
109
114
|
end
|
110
115
|
|
111
116
|
module TemplateReader
|
@@ -115,9 +120,9 @@ module KuberKit
|
|
115
120
|
end
|
116
121
|
|
117
122
|
module ServiceDeployer
|
123
|
+
autoload :ActionHandler, 'service_deployer/action_handler'
|
124
|
+
autoload :StrategyDetector, 'service_deployer/strategy_detector'
|
118
125
|
autoload :Deployer, 'service_deployer/deployer'
|
119
|
-
autoload :ServiceRestarter, 'service_deployer/service_restarter'
|
120
|
-
autoload :ServiceReader, 'service_deployer/service_reader'
|
121
126
|
autoload :ServiceListResolver, 'service_deployer/service_list_resolver'
|
122
127
|
|
123
128
|
module Strategies
|
@@ -126,6 +131,11 @@ module KuberKit
|
|
126
131
|
end
|
127
132
|
end
|
128
133
|
|
134
|
+
module ServiceReader
|
135
|
+
autoload :ActionHandler, 'service_reader/action_handler'
|
136
|
+
autoload :Reader, 'service_reader/reader'
|
137
|
+
end
|
138
|
+
|
129
139
|
module Actions
|
130
140
|
autoload :ImageCompiler, 'actions/image_compiler'
|
131
141
|
autoload :EnvFileReader, 'actions/env_file_reader'
|
@@ -2,16 +2,14 @@ require 'json'
|
|
2
2
|
|
3
3
|
class KuberKit::Actions::EnvFileReader
|
4
4
|
include KuberKit::Import[
|
5
|
-
"core.env_file_store",
|
6
|
-
"env_file_reader.reader",
|
7
5
|
"shell.local_shell",
|
8
|
-
"ui"
|
6
|
+
"ui",
|
7
|
+
env_file_reader: "env_file_reader.action_handler",
|
9
8
|
]
|
10
9
|
|
11
10
|
Contract Symbol, Hash => Any
|
12
11
|
def call(env_file_name, options)
|
13
|
-
|
14
|
-
result = reader.read(local_shell, env_file)
|
12
|
+
result = env_file_reader.call(local_shell, env_file_name)
|
15
13
|
ui.print_info(env_file_name.to_s, JSON.pretty_generate(result))
|
16
14
|
end
|
17
15
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
class KuberKit::Actions::ImageCompiler
|
2
2
|
include KuberKit::Import[
|
3
|
-
"image_compiler.compiler",
|
4
3
|
"image_compiler.image_dependency_resolver",
|
5
4
|
"shell.local_shell",
|
6
5
|
"tools.logger",
|
7
|
-
"
|
8
|
-
"
|
6
|
+
"ui",
|
7
|
+
image_compiler: "image_compiler.action_handler",
|
9
8
|
]
|
10
9
|
|
11
10
|
Contract ArrayOf[Symbol], Hash => Any
|
@@ -31,7 +30,7 @@ class KuberKit::Actions::ImageCompiler
|
|
31
30
|
|
32
31
|
logger.info("Started compiling: #{image_name.to_s.green}")
|
33
32
|
task_group.add("Compiling #{image_name.to_s.yellow}") do |task|
|
34
|
-
|
33
|
+
image_compiler.call(local_shell, image_name, build_id)
|
35
34
|
|
36
35
|
task.update_title("Compiled #{image_name.to_s.green}")
|
37
36
|
logger.info("Finished compiling: #{image_name.to_s.green}")
|
@@ -41,16 +40,7 @@ class KuberKit::Actions::ImageCompiler
|
|
41
40
|
task_group.wait
|
42
41
|
end
|
43
42
|
|
44
|
-
def compile_image(image_name, build_id)
|
45
|
-
compile_dir = generate_compile_dir(build_id: build_id)
|
46
|
-
compiler.compile(local_shell, image_name, compile_dir)
|
47
|
-
end
|
48
|
-
|
49
43
|
def generate_build_id
|
50
44
|
Time.now.strftime("%H%M%S")
|
51
45
|
end
|
52
|
-
|
53
|
-
def generate_compile_dir(build_id:)
|
54
|
-
File.join(configs.image_compile_dir, build_id)
|
55
|
-
end
|
56
46
|
end
|
@@ -2,11 +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.deployer",
|
6
5
|
"core.service_store",
|
7
6
|
"shell.local_shell",
|
8
7
|
"tools.logger",
|
9
|
-
"ui"
|
8
|
+
"ui",
|
9
|
+
service_deployer: "service_deployer.action_handler",
|
10
10
|
]
|
11
11
|
|
12
12
|
Contract KeywordArgs[
|
@@ -36,7 +36,7 @@ class KuberKit::Actions::ServiceDeployer
|
|
36
36
|
|
37
37
|
logger.info("Started deploying: #{service_name.to_s.green}")
|
38
38
|
task_group.add("Deploying #{service_name.to_s.yellow}") do |task|
|
39
|
-
|
39
|
+
service_deployer.call(local_shell, service_name.to_sym)
|
40
40
|
|
41
41
|
task.update_title("Deployed #{service_name.to_s.green}")
|
42
42
|
logger.info("Finished deploying: #{service_name.to_s.green}")
|
@@ -1,16 +1,13 @@
|
|
1
1
|
class KuberKit::Actions::ServiceReader
|
2
2
|
include KuberKit::Import[
|
3
|
-
"core.service_store",
|
4
|
-
"service_deployer.service_reader",
|
5
3
|
"shell.local_shell",
|
6
|
-
"ui"
|
4
|
+
"ui",
|
5
|
+
service_reader: "service_reader.action_handler",
|
7
6
|
]
|
8
7
|
|
9
8
|
Contract Symbol, Hash => Any
|
10
9
|
def call(service_name, options)
|
11
|
-
|
12
|
-
|
13
|
-
result = service_reader.read(local_shell, service)
|
10
|
+
result = service_reader.call(local_shell, service_name)
|
14
11
|
|
15
12
|
ui.print_info(service_name.to_s, result)
|
16
13
|
end
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -141,6 +141,10 @@ class KuberKit::Container
|
|
141
141
|
KuberKit::Preprocessing::DirPreprocessor.new
|
142
142
|
end
|
143
143
|
|
144
|
+
register "image_compiler.action_handler" do
|
145
|
+
KuberKit::ImageCompiler::ActionHandler.new
|
146
|
+
end
|
147
|
+
|
144
148
|
register "image_compiler.compiler" do
|
145
149
|
KuberKit::ImageCompiler::Compiler.new
|
146
150
|
end
|
@@ -173,12 +177,16 @@ class KuberKit::Container
|
|
173
177
|
KuberKit::ArtifactsSync::NullArtifactResolver.new
|
174
178
|
end
|
175
179
|
|
180
|
+
register "env_file_reader.action_handler" do
|
181
|
+
KuberKit::EnvFileReader::ActionHandler.new
|
182
|
+
end
|
183
|
+
|
176
184
|
register "env_file_reader.reader" do
|
177
185
|
KuberKit::EnvFileReader::Reader.new
|
178
186
|
end
|
179
187
|
|
180
|
-
register "env_file_reader.
|
181
|
-
KuberKit::EnvFileReader::
|
188
|
+
register "env_file_reader.strategies.artifact_file" do
|
189
|
+
KuberKit::EnvFileReader::Strategies::ArtifactFile.new
|
182
190
|
end
|
183
191
|
|
184
192
|
register "template_reader.reader" do
|
@@ -189,16 +197,16 @@ class KuberKit::Container
|
|
189
197
|
KuberKit::TemplateReader::ArtifactFileReader.new
|
190
198
|
end
|
191
199
|
|
192
|
-
register "service_deployer.
|
193
|
-
KuberKit::ServiceDeployer::
|
200
|
+
register "service_deployer.action_handler" do
|
201
|
+
KuberKit::ServiceDeployer::ActionHandler.new
|
194
202
|
end
|
195
203
|
|
196
|
-
register "service_deployer.
|
197
|
-
KuberKit::ServiceDeployer::
|
204
|
+
register "service_deployer.strategy_detector" do
|
205
|
+
KuberKit::ServiceDeployer::StrategyDetector.new
|
198
206
|
end
|
199
207
|
|
200
|
-
register "service_deployer.
|
201
|
-
KuberKit::ServiceDeployer::
|
208
|
+
register "service_deployer.deployer" do
|
209
|
+
KuberKit::ServiceDeployer::Deployer.new
|
202
210
|
end
|
203
211
|
|
204
212
|
register "service_deployer.service_list_resolver" do
|
@@ -209,6 +217,14 @@ class KuberKit::Container
|
|
209
217
|
KuberKit::ServiceDeployer::Strategies::Kubernetes.new
|
210
218
|
end
|
211
219
|
|
220
|
+
register "service_reader.action_handler" do
|
221
|
+
KuberKit::ServiceReader::ActionHandler.new
|
222
|
+
end
|
223
|
+
|
224
|
+
register "service_reader.reader" do
|
225
|
+
KuberKit::ServiceReader::Reader.new
|
226
|
+
end
|
227
|
+
|
212
228
|
register "ui" do
|
213
229
|
if KuberKit.debug_mode?
|
214
230
|
KuberKit::UI::Simple.new
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class KuberKit::Core::Configuration
|
2
|
-
attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path, :deploy_strategy
|
2
|
+
attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path, :deploy_strategy, :services_attributes
|
3
3
|
|
4
4
|
Contract KeywordArgs[
|
5
5
|
name: Symbol,
|
@@ -7,10 +7,11 @@ class KuberKit::Core::Configuration
|
|
7
7
|
registries: Hash,
|
8
8
|
env_files: Hash,
|
9
9
|
templates: Hash,
|
10
|
-
kubeconfig_path:
|
11
|
-
deploy_strategy: Symbol
|
10
|
+
kubeconfig_path: Maybe[String],
|
11
|
+
deploy_strategy: Symbol,
|
12
|
+
services_attributes: HashOf[Symbol => Hash]
|
12
13
|
] => Any
|
13
|
-
def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:, deploy_strategy:)
|
14
|
+
def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:, deploy_strategy:, services_attributes:)
|
14
15
|
@name = name
|
15
16
|
@artifacts = artifacts
|
16
17
|
@registries = registries
|
@@ -18,5 +19,10 @@ class KuberKit::Core::Configuration
|
|
18
19
|
@templates = templates
|
19
20
|
@kubeconfig_path = kubeconfig_path
|
20
21
|
@deploy_strategy = deploy_strategy
|
22
|
+
@services_attributes = services_attributes
|
23
|
+
end
|
24
|
+
|
25
|
+
def service_attributes(service_name)
|
26
|
+
services_attributes[service_name.to_sym] || {}
|
21
27
|
end
|
22
28
|
end
|
@@ -10,6 +10,8 @@ class KuberKit::Core::ConfigurationDefinition
|
|
10
10
|
@registries = {}
|
11
11
|
@env_files = {}
|
12
12
|
@templates = {}
|
13
|
+
@enabled_services = []
|
14
|
+
@services_attributes = {}
|
13
15
|
end
|
14
16
|
|
15
17
|
def to_attrs
|
@@ -20,7 +22,9 @@ class KuberKit::Core::ConfigurationDefinition
|
|
20
22
|
env_files: @env_files,
|
21
23
|
templates: @templates,
|
22
24
|
kubeconfig_path: @kubeconfig_path,
|
23
|
-
deploy_strategy: @deploy_strategy
|
25
|
+
deploy_strategy: @deploy_strategy,
|
26
|
+
enabled_services: @enabled_services,
|
27
|
+
services_attributes: @services_attributes
|
24
28
|
)
|
25
29
|
end
|
26
30
|
|
@@ -71,4 +75,11 @@ class KuberKit::Core::ConfigurationDefinition
|
|
71
75
|
|
72
76
|
self
|
73
77
|
end
|
78
|
+
|
79
|
+
def enabled_services(services_hash)
|
80
|
+
@enabled_services += services_hash.keys.map(&:to_sym)
|
81
|
+
@services_attributes = @services_attributes.merge(services_hash)
|
82
|
+
|
83
|
+
self
|
84
|
+
end
|
74
85
|
end
|
@@ -24,7 +24,8 @@ class KuberKit::Core::ConfigurationFactory
|
|
24
24
|
env_files: env_files,
|
25
25
|
templates: templates,
|
26
26
|
kubeconfig_path: configuration_attrs.kubeconfig_path,
|
27
|
-
deploy_strategy: configuration_attrs.deploy_strategy || configs.deploy_strategy
|
27
|
+
deploy_strategy: configuration_attrs.deploy_strategy || configs.deploy_strategy,
|
28
|
+
services_attributes: configuration_attrs.services_attributes
|
28
29
|
)
|
29
30
|
end
|
30
31
|
|
@@ -1,25 +1,30 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::BaseHelper
|
2
2
|
CONTRACT = RespondTo[:get_binding]
|
3
3
|
|
4
|
-
attr_reader :shell, :artifact_store, :image_store
|
4
|
+
attr_reader :shell, :artifact_store, :image_store, :env_file_reader
|
5
5
|
|
6
|
-
def initialize(image_store:, artifact_store:, shell:)
|
7
|
-
@image_store
|
8
|
-
@artifact_store
|
9
|
-
@shell
|
6
|
+
def initialize(image_store:, artifact_store:, shell:, env_file_reader:)
|
7
|
+
@image_store = image_store
|
8
|
+
@artifact_store = artifact_store
|
9
|
+
@shell = shell
|
10
|
+
@env_file_reader = env_file_reader
|
10
11
|
end
|
11
12
|
|
12
13
|
def image_url(image_name)
|
13
|
-
image = @image_store.get_image(image_name)
|
14
|
+
image = @image_store.get_image(image_name.to_sym)
|
14
15
|
|
15
16
|
image.remote_registry_url
|
16
17
|
end
|
17
18
|
|
18
19
|
def artifact_path(name, file_name = nil)
|
19
|
-
artifact = @artifact_store.get(name)
|
20
|
+
artifact = @artifact_store.get(name.to_sym)
|
20
21
|
[artifact.cloned_path, file_name].compact.join("/")
|
21
22
|
end
|
22
23
|
|
24
|
+
def env_file(env_file_name)
|
25
|
+
@env_file_reader.call(@shell, env_file_name)
|
26
|
+
end
|
27
|
+
|
23
28
|
def configuration_name
|
24
29
|
KuberKit.current_configuration.name
|
25
30
|
end
|
@@ -1,23 +1,26 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::ContextHelperFactory
|
2
2
|
include KuberKit::Import[
|
3
3
|
"core.image_store",
|
4
|
-
"core.artifact_store"
|
4
|
+
"core.artifact_store",
|
5
|
+
env_file_reader: "env_file_reader.action_handler"
|
5
6
|
]
|
6
7
|
|
7
8
|
def build_image_context(shell)
|
8
9
|
KuberKit::Core::ContextHelper::ImageHelper.new(
|
9
|
-
image_store:
|
10
|
-
artifact_store:
|
11
|
-
shell:
|
10
|
+
image_store: image_store,
|
11
|
+
artifact_store: artifact_store,
|
12
|
+
shell: shell,
|
13
|
+
env_file_reader: env_file_reader
|
12
14
|
)
|
13
15
|
end
|
14
16
|
|
15
17
|
def build_service_context(shell, service)
|
16
18
|
KuberKit::Core::ContextHelper::ServiceHelper.new(
|
17
|
-
image_store:
|
18
|
-
artifact_store:
|
19
|
-
shell:
|
20
|
-
|
19
|
+
image_store: image_store,
|
20
|
+
artifact_store: artifact_store,
|
21
|
+
shell: shell,
|
22
|
+
env_file_reader: env_file_reader,
|
23
|
+
service: service,
|
21
24
|
)
|
22
25
|
end
|
23
26
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
class KuberKit::Core::ContextHelper::ServiceHelper < KuberKit::Core::ContextHelper::BaseHelper
|
2
|
-
def initialize(image_store:, artifact_store:, shell:, service:)
|
2
|
+
def initialize(image_store:, artifact_store:, shell:, env_file_reader:, service:)
|
3
3
|
super(
|
4
|
-
image_store:
|
5
|
-
artifact_store:
|
6
|
-
shell:
|
4
|
+
image_store: image_store,
|
5
|
+
artifact_store: artifact_store,
|
6
|
+
shell: shell,
|
7
|
+
env_file_reader: env_file_reader
|
7
8
|
)
|
8
9
|
@service = service
|
9
10
|
end
|
@@ -8,12 +8,15 @@ class KuberKit::Core::ServiceFactory
|
|
8
8
|
raise AttributeNotSetError, "Please set template for service using #template method"
|
9
9
|
end
|
10
10
|
|
11
|
+
configuration_attributes = KuberKit.current_configuration.service_attributes(service_attrs.name)
|
12
|
+
attributes = (service_attrs.attributes || {}).merge(configuration_attributes)
|
13
|
+
|
11
14
|
KuberKit::Core::Service.new(
|
12
15
|
name: service_attrs.name,
|
13
16
|
template_name: service_attrs.template_name,
|
14
17
|
tags: service_attrs.tags,
|
15
18
|
images: service_attrs.images,
|
16
|
-
attributes:
|
19
|
+
attributes: attributes
|
17
20
|
)
|
18
21
|
end
|
19
22
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class KuberKit::EnvFileReader::ActionHandler
|
2
|
+
include KuberKit::Import[
|
3
|
+
"env_file_reader.reader",
|
4
|
+
"core.env_file_store",
|
5
|
+
]
|
6
|
+
|
7
|
+
Contract KuberKit::Shell::AbstractShell, Symbol => Any
|
8
|
+
def call(shell, env_file_name)
|
9
|
+
env_file = env_file_store.get(env_file_name)
|
10
|
+
reader.read(shell, env_file)
|
11
|
+
end
|
12
|
+
end
|
@@ -2,14 +2,14 @@ class KuberKit::EnvFileReader::Reader
|
|
2
2
|
ReaderNotFoundError = Class.new(KuberKit::NotFoundError)
|
3
3
|
|
4
4
|
include KuberKit::Import[
|
5
|
-
"env_file_reader.
|
5
|
+
"env_file_reader.strategies.artifact_file",
|
6
6
|
]
|
7
7
|
|
8
8
|
def use_reader(env_file_reader, env_file_class:)
|
9
9
|
@@readers ||= {}
|
10
10
|
|
11
|
-
if !env_file_reader.is_a?(KuberKit::EnvFileReader::
|
12
|
-
raise ArgumentError.new("should be an instance of KuberKit::EnvFileReader::
|
11
|
+
if !env_file_reader.is_a?(KuberKit::EnvFileReader::Strategies::Abstract)
|
12
|
+
raise ArgumentError.new("should be an instance of KuberKit::EnvFileReader::Strategies::Abstract, got: #{env_file_reader.inspect}")
|
13
13
|
end
|
14
14
|
|
15
15
|
@@readers[env_file_class] = env_file_reader
|
@@ -26,7 +26,7 @@ class KuberKit::EnvFileReader::Reader
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def add_default_readers
|
29
|
-
use_reader(
|
29
|
+
use_reader(artifact_file, env_file_class: KuberKit::Core::EnvFiles::ArtifactFile)
|
30
30
|
end
|
31
31
|
|
32
32
|
def reset!
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class KuberKit::ImageCompiler::ActionHandler
|
2
|
+
include KuberKit::Import[
|
3
|
+
"image_compiler.compiler",
|
4
|
+
"core.image_store",
|
5
|
+
"configs",
|
6
|
+
]
|
7
|
+
|
8
|
+
Contract KuberKit::Shell::AbstractShell, Symbol, String => Any
|
9
|
+
def call(shell, image_name, build_id)
|
10
|
+
image = image_store.get_image(image_name)
|
11
|
+
|
12
|
+
compile_dir = generate_compile_dir(build_id: build_id)
|
13
|
+
|
14
|
+
compiler.compile(shell, image, compile_dir)
|
15
|
+
end
|
16
|
+
|
17
|
+
def generate_compile_dir(build_id:)
|
18
|
+
File.join(configs.image_compile_dir, build_id)
|
19
|
+
end
|
20
|
+
end
|
@@ -3,13 +3,10 @@ class KuberKit::ImageCompiler::Compiler
|
|
3
3
|
"image_compiler.image_build_dir_creator",
|
4
4
|
"image_compiler.image_builder",
|
5
5
|
"core.context_helper_factory",
|
6
|
-
"core.image_store"
|
7
6
|
]
|
8
7
|
|
9
|
-
Contract KuberKit::Shell::AbstractShell,
|
10
|
-
def compile(shell,
|
11
|
-
image = image_store.get_image(image_name)
|
12
|
-
|
8
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Image, String => Any
|
9
|
+
def compile(shell, image, builds_dir)
|
13
10
|
image_build_dir = File.join(builds_dir, image.name.to_s)
|
14
11
|
|
15
12
|
context_helper = context_helper_factory.build_image_context(shell)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class KuberKit::ServiceDeployer::ActionHandler
|
2
|
+
include KuberKit::Import[
|
3
|
+
"service_deployer.deployer",
|
4
|
+
"service_deployer.strategy_detector",
|
5
|
+
"core.service_store",
|
6
|
+
]
|
7
|
+
|
8
|
+
Contract KuberKit::Shell::AbstractShell, Symbol => Any
|
9
|
+
def call(shell, service_name)
|
10
|
+
service = service_store.get_service(service_name)
|
11
|
+
|
12
|
+
strategy_name = strategy_detector.call(service)
|
13
|
+
|
14
|
+
deployer.restart(shell, service, strategy_name)
|
15
|
+
end
|
16
|
+
end
|
@@ -1,15 +1,37 @@
|
|
1
1
|
class KuberKit::ServiceDeployer::Deployer
|
2
|
+
StrategyNotFoundError = Class.new(KuberKit::NotFoundError)
|
3
|
+
|
2
4
|
include KuberKit::Import[
|
3
|
-
"service_deployer.service_restarter",
|
4
5
|
"core.service_store",
|
6
|
+
"service_deployer.strategies.kubernetes"
|
5
7
|
]
|
6
8
|
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
def register_strategy(strategy_name, strategy)
|
10
|
+
@@strategies ||= {}
|
11
|
+
|
12
|
+
if !strategy.is_a?(KuberKit::ServiceDeployer::Strategies::Abstract)
|
13
|
+
raise ArgumentError.new("should be an instance of KuberKit::ServiceDeployer::Strategies::Abstract, got: #{strategy.inspect}")
|
14
|
+
end
|
15
|
+
|
16
|
+
@@strategies[strategy_name] = strategy
|
17
|
+
end
|
18
|
+
|
19
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service, Symbol => Any
|
20
|
+
def deploy(shell, service, strategy_name)
|
21
|
+
add_default_strategies
|
10
22
|
|
11
|
-
|
23
|
+
deployer = @@strategies[strategy_name]
|
24
|
+
|
25
|
+
raise StrategyNotFoundError, "Can't find strategy with name #{strategy_name}" if deployer.nil?
|
26
|
+
|
27
|
+
deployer.deploy(shell, service)
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_default_strategies
|
31
|
+
register_strategy(:kubernetes, kubernetes)
|
32
|
+
end
|
12
33
|
|
13
|
-
|
34
|
+
def reset!
|
35
|
+
@@strategies = {}
|
14
36
|
end
|
15
37
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeployer::Strategies::Abstract
|
2
2
|
include KuberKit::Import[
|
3
|
-
"
|
3
|
+
"service_reader.reader",
|
4
4
|
"shell.kubectl_commands",
|
5
5
|
"configs",
|
6
6
|
]
|
7
7
|
|
8
8
|
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
|
9
|
-
def
|
10
|
-
service_config =
|
9
|
+
def deploy(shell, service)
|
10
|
+
service_config = reader.read(shell, service)
|
11
11
|
config_path = "#{configs.service_config_dir}/#{service.name}.yml"
|
12
12
|
shell.write(config_path, service_config)
|
13
13
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class KuberKit::ServiceReader::ActionHandler
|
2
|
+
include KuberKit::Import[
|
3
|
+
"service_reader.reader",
|
4
|
+
"core.service_store",
|
5
|
+
]
|
6
|
+
|
7
|
+
Contract KuberKit::Shell::AbstractShell, Symbol => Any
|
8
|
+
def call(shell, service_name)
|
9
|
+
service = service_store.get_service(service_name)
|
10
|
+
|
11
|
+
reader.read(shell, service)
|
12
|
+
end
|
13
|
+
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.1.
|
4
|
+
version: 0.1.6
|
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-11-
|
11
|
+
date: 2020-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts-lite
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- TODO.md
|
145
145
|
- bin/console
|
146
146
|
- bin/kit
|
147
|
+
- example/app_data/env_file.yml
|
147
148
|
- example/app_data/service.yml
|
148
149
|
- example/app_data/test.env
|
149
150
|
- example/app_data/test.txt
|
@@ -163,6 +164,7 @@ files:
|
|
163
164
|
- example/infrastructure/env_files.rb
|
164
165
|
- example/infrastructure/registries.rb
|
165
166
|
- example/infrastructure/templates.rb
|
167
|
+
- example/services/env_file.rb
|
166
168
|
- example/services/ruby_app.rb
|
167
169
|
- kuber_kit.gemspec
|
168
170
|
- lib/kuber_kit.rb
|
@@ -212,13 +214,15 @@ files:
|
|
212
214
|
- lib/kuber_kit/core/templates/abstract_template.rb
|
213
215
|
- lib/kuber_kit/core/templates/artifact_file.rb
|
214
216
|
- lib/kuber_kit/core/templates/template_store.rb
|
215
|
-
- lib/kuber_kit/env_file_reader/
|
216
|
-
- lib/kuber_kit/env_file_reader/artifact_file_reader.rb
|
217
|
+
- lib/kuber_kit/env_file_reader/action_handler.rb
|
217
218
|
- lib/kuber_kit/env_file_reader/reader.rb
|
219
|
+
- lib/kuber_kit/env_file_reader/strategies/abstract.rb
|
220
|
+
- lib/kuber_kit/env_file_reader/strategies/artifact_file.rb
|
218
221
|
- lib/kuber_kit/extensions/colored_string.rb
|
219
222
|
- lib/kuber_kit/extensions/contracts.rb
|
220
223
|
- lib/kuber_kit/extensions/indocker_compat.rb
|
221
224
|
- lib/kuber_kit/extensions/inspectable.rb
|
225
|
+
- lib/kuber_kit/image_compiler/action_handler.rb
|
222
226
|
- lib/kuber_kit/image_compiler/compiler.rb
|
223
227
|
- lib/kuber_kit/image_compiler/image_build_dir_creator.rb
|
224
228
|
- lib/kuber_kit/image_compiler/image_builder.rb
|
@@ -227,12 +231,14 @@ files:
|
|
227
231
|
- lib/kuber_kit/preprocessing/dir_preprocessor.rb
|
228
232
|
- lib/kuber_kit/preprocessing/file_preprocessor.rb
|
229
233
|
- lib/kuber_kit/preprocessing/text_preprocessor.rb
|
234
|
+
- lib/kuber_kit/service_deployer/action_handler.rb
|
230
235
|
- lib/kuber_kit/service_deployer/deployer.rb
|
231
236
|
- lib/kuber_kit/service_deployer/service_list_resolver.rb
|
232
|
-
- lib/kuber_kit/service_deployer/service_reader.rb
|
233
|
-
- lib/kuber_kit/service_deployer/service_restarter.rb
|
234
237
|
- lib/kuber_kit/service_deployer/strategies/abstract.rb
|
235
238
|
- lib/kuber_kit/service_deployer/strategies/kubernetes.rb
|
239
|
+
- lib/kuber_kit/service_deployer/strategy_detector.rb
|
240
|
+
- lib/kuber_kit/service_reader/action_handler.rb
|
241
|
+
- lib/kuber_kit/service_reader/reader.rb
|
236
242
|
- lib/kuber_kit/shell/abstract_shell.rb
|
237
243
|
- lib/kuber_kit/shell/bash_commands.rb
|
238
244
|
- lib/kuber_kit/shell/command_counter.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
class KuberKit::ServiceDeployer::ServiceRestarter
|
2
|
-
StrategyNotFoundError = Class.new(KuberKit::NotFoundError)
|
3
|
-
|
4
|
-
include KuberKit::Import[
|
5
|
-
"core.service_store",
|
6
|
-
"service_deployer.strategies.kubernetes"
|
7
|
-
]
|
8
|
-
|
9
|
-
def register_strategy(strategy_name, strategy)
|
10
|
-
@@strategies ||= {}
|
11
|
-
|
12
|
-
if !strategy.is_a?(KuberKit::ServiceDeployer::Strategies::Abstract)
|
13
|
-
raise ArgumentError.new("should be an instance of KuberKit::ServiceDeployer::Strategies::Abstract, got: #{strategy.inspect}")
|
14
|
-
end
|
15
|
-
|
16
|
-
@@strategies[strategy_name] = strategy
|
17
|
-
end
|
18
|
-
|
19
|
-
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service, Symbol => Any
|
20
|
-
def restart(shell, service, strategy_name)
|
21
|
-
add_default_strategies
|
22
|
-
|
23
|
-
restarter = @@strategies[strategy_name]
|
24
|
-
|
25
|
-
raise StrategyNotFoundError, "Can't find strategy with name #{strategy_name}" if restarter.nil?
|
26
|
-
|
27
|
-
restarter.restart(shell, service)
|
28
|
-
end
|
29
|
-
|
30
|
-
def add_default_strategies
|
31
|
-
register_strategy(:kubernetes, kubernetes)
|
32
|
-
end
|
33
|
-
|
34
|
-
def reset!
|
35
|
-
@@strategies = {}
|
36
|
-
end
|
37
|
-
end
|