kuber_kit 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/example/services/ruby_app.rb +2 -1
- data/lib/kuber_kit/actions/kubectl_applier.rb +2 -2
- data/lib/kuber_kit/actions/service_deployer.rb +17 -0
- data/lib/kuber_kit/core/configuration.rb +10 -10
- data/lib/kuber_kit/core/configuration_definition.rb +3 -3
- data/lib/kuber_kit/core/configuration_factory.rb +1 -1
- data/lib/kuber_kit/core/configuration_store.rb +2 -0
- data/lib/kuber_kit/core/image_store.rb +2 -0
- data/lib/kuber_kit/core/service.rb +4 -2
- data/lib/kuber_kit/core/service_definition.rb +8 -1
- data/lib/kuber_kit/core/service_factory.rb +2 -1
- data/lib/kuber_kit/core/service_store.rb +2 -0
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +3 -3
- data/lib/kuber_kit/shell/kubectl_commands.rb +8 -8
- data/lib/kuber_kit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d85e9b30ebb43f4fe0a056823e3eeda6f878784555fa909df004e46522d750ec
|
4
|
+
data.tar.gz: 441270e1f147862ff75f999606bfafa7e467efde71765d27490e8f6afdd74740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d112105c8b7e268a528b59097028f9c483ac921d3b584bb372ba33f23595d3d8614f4a7251b75498934c1f0d365e5eed3d9c2b237a9f30d5a235cbd290150c8
|
7
|
+
data.tar.gz: '068e6d864886eb38d6ebd9f8ac10358bb3f220cabe0c38a67df9b6a886b07b224083586be4ddd7320691b05b0420af8f053f9f2d1ed6c2a7c81accd4dce6f4a0'
|
data/Gemfile.lock
CHANGED
@@ -7,9 +7,9 @@ class KuberKit::Actions::KubectlApplier
|
|
7
7
|
|
8
8
|
Contract String, Hash => Any
|
9
9
|
def call(file_path, options)
|
10
|
-
|
10
|
+
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
11
11
|
ui.create_task("Applying file: #{file_path}") do |task|
|
12
|
-
kubectl_commands.apply_file(local_shell, file_path,
|
12
|
+
kubectl_commands.apply_file(local_shell, file_path, kubeconfig_path: kubeconfig_path)
|
13
13
|
task.update_title("Applied file: #{file_path}")
|
14
14
|
end
|
15
15
|
nil
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class KuberKit::Actions::ServiceDeployer
|
2
2
|
include KuberKit::Import[
|
3
|
+
"actions.image_compiler",
|
3
4
|
"service_deployer.service_list_resolver",
|
4
5
|
"service_deployer.deployer",
|
6
|
+
"core.service_store",
|
5
7
|
"shell.local_shell",
|
6
8
|
"tools.logger",
|
7
9
|
"ui"
|
@@ -17,6 +19,17 @@ class KuberKit::Actions::ServiceDeployer
|
|
17
19
|
tags: tags || []
|
18
20
|
)
|
19
21
|
|
22
|
+
services = service_names.map do |service_name|
|
23
|
+
service_store.get_service(service_name.to_sym)
|
24
|
+
end
|
25
|
+
|
26
|
+
images_names = services.map(&:images).flatten.uniq
|
27
|
+
|
28
|
+
compile_images(images_names)
|
29
|
+
deploy_services(service_names)
|
30
|
+
end
|
31
|
+
|
32
|
+
def deploy_services(service_names)
|
20
33
|
task_group = ui.create_task_group
|
21
34
|
|
22
35
|
service_names.each do |service_name|
|
@@ -32,4 +45,8 @@ class KuberKit::Actions::ServiceDeployer
|
|
32
45
|
|
33
46
|
task_group.wait
|
34
47
|
end
|
48
|
+
|
49
|
+
def compile_images(images_names)
|
50
|
+
image_compiler.call(images_names, {}) if images_names.any?
|
51
|
+
end
|
35
52
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class KuberKit::Core::Configuration
|
2
|
-
attr_reader :name, :artifacts, :registries, :env_files, :templates, :
|
2
|
+
attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path, :deploy_strategy
|
3
3
|
|
4
4
|
Contract KeywordArgs[
|
5
5
|
name: Symbol,
|
@@ -7,16 +7,16 @@ class KuberKit::Core::Configuration
|
|
7
7
|
registries: Hash,
|
8
8
|
env_files: Hash,
|
9
9
|
templates: Hash,
|
10
|
-
|
10
|
+
kubeconfig_path: Maybe[String],
|
11
11
|
deploy_strategy: Symbol
|
12
12
|
] => Any
|
13
|
-
def initialize(name:, artifacts:, registries:, env_files:, templates:,
|
14
|
-
@name
|
15
|
-
@artifacts
|
16
|
-
@registries
|
17
|
-
@env_files
|
18
|
-
@templates
|
19
|
-
@
|
20
|
-
@deploy_strategy
|
13
|
+
def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:, deploy_strategy:)
|
14
|
+
@name = name
|
15
|
+
@artifacts = artifacts
|
16
|
+
@registries = registries
|
17
|
+
@env_files = env_files
|
18
|
+
@templates = templates
|
19
|
+
@kubeconfig_path = kubeconfig_path
|
20
|
+
@deploy_strategy = deploy_strategy
|
21
21
|
end
|
22
22
|
end
|
@@ -19,7 +19,7 @@ class KuberKit::Core::ConfigurationDefinition
|
|
19
19
|
registries: @registries,
|
20
20
|
env_files: @env_files,
|
21
21
|
templates: @templates,
|
22
|
-
|
22
|
+
kubeconfig_path: @kubeconfig_path,
|
23
23
|
deploy_strategy: @deploy_strategy
|
24
24
|
)
|
25
25
|
end
|
@@ -60,8 +60,8 @@ class KuberKit::Core::ConfigurationDefinition
|
|
60
60
|
self
|
61
61
|
end
|
62
62
|
|
63
|
-
def
|
64
|
-
@
|
63
|
+
def kubeconfig_path(path)
|
64
|
+
@kubeconfig_path = path
|
65
65
|
|
66
66
|
self
|
67
67
|
end
|
@@ -23,7 +23,7 @@ class KuberKit::Core::ConfigurationFactory
|
|
23
23
|
registries: registries,
|
24
24
|
env_files: env_files,
|
25
25
|
templates: templates,
|
26
|
-
|
26
|
+
kubeconfig_path: configuration_attrs.kubeconfig_path,
|
27
27
|
deploy_strategy: configuration_attrs.deploy_strategy || configs.deploy_strategy
|
28
28
|
)
|
29
29
|
end
|
@@ -25,6 +25,7 @@ class KuberKit::Core::ConfigurationStore
|
|
25
25
|
@@configuration_definitions[configuration_definition.configuration_name] = configuration_definition
|
26
26
|
end
|
27
27
|
|
28
|
+
Contract Symbol => Any
|
28
29
|
def get_definition(configuration_name)
|
29
30
|
@@configuration_definitions ||= {}
|
30
31
|
|
@@ -35,6 +36,7 @@ class KuberKit::Core::ConfigurationStore
|
|
35
36
|
@@configuration_definitions[configuration_name]
|
36
37
|
end
|
37
38
|
|
39
|
+
Contract Symbol => Any
|
38
40
|
def get_configuration(configuration_name)
|
39
41
|
definition = get_definition(configuration_name)
|
40
42
|
|
@@ -25,6 +25,7 @@ class KuberKit::Core::ImageStore
|
|
25
25
|
@@image_definitions[image_definition.image_name] = image_definition
|
26
26
|
end
|
27
27
|
|
28
|
+
Contract Symbol => Any
|
28
29
|
def get_definition(image_name)
|
29
30
|
@@image_definitions ||= {}
|
30
31
|
|
@@ -35,6 +36,7 @@ class KuberKit::Core::ImageStore
|
|
35
36
|
@@image_definitions[image_name]
|
36
37
|
end
|
37
38
|
|
39
|
+
Contract Symbol => Any
|
38
40
|
def get_image(image_name)
|
39
41
|
definition = get_definition(image_name)
|
40
42
|
|
@@ -1,15 +1,17 @@
|
|
1
1
|
class KuberKit::Core::Service
|
2
|
-
attr_reader :name, :template_name, :tags
|
2
|
+
attr_reader :name, :template_name, :tags, :images
|
3
3
|
|
4
4
|
Contract KeywordArgs[
|
5
5
|
name: Symbol,
|
6
6
|
template_name: Symbol,
|
7
7
|
tags: ArrayOf[Symbol],
|
8
|
+
images: ArrayOf[Symbol],
|
8
9
|
] => Any
|
9
|
-
def initialize(name:, template_name:, tags:)
|
10
|
+
def initialize(name:, template_name:, tags:, images:)
|
10
11
|
@name = name
|
11
12
|
@template_name = template_name
|
12
13
|
@tags = tags
|
14
|
+
@images = images
|
13
15
|
end
|
14
16
|
|
15
17
|
def uri
|
@@ -10,7 +10,8 @@ class KuberKit::Core::ServiceDefinition
|
|
10
10
|
OpenStruct.new(
|
11
11
|
name: @service_name,
|
12
12
|
template_name: get_value(@template_name),
|
13
|
-
tags: Array(get_value(@tags)).map(&:to_sym)
|
13
|
+
tags: Array(get_value(@tags)).map(&:to_sym),
|
14
|
+
images: Array(get_value(@images)).map(&:to_sym),
|
14
15
|
)
|
15
16
|
end
|
16
17
|
|
@@ -26,6 +27,12 @@ class KuberKit::Core::ServiceDefinition
|
|
26
27
|
self
|
27
28
|
end
|
28
29
|
|
30
|
+
def images(*value, &block)
|
31
|
+
@images = block_given? ? block : Array(value).flatten
|
32
|
+
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
29
36
|
private
|
30
37
|
def get_value(variable)
|
31
38
|
variable.is_a?(Proc) ? variable.call : variable
|
@@ -25,6 +25,7 @@ class KuberKit::Core::ServiceStore
|
|
25
25
|
@@service_definitions[service_definition.service_name] = service_definition
|
26
26
|
end
|
27
27
|
|
28
|
+
Contract Symbol => Any
|
28
29
|
def get_definition(service_name)
|
29
30
|
@@service_definitions ||= {}
|
30
31
|
|
@@ -35,6 +36,7 @@ class KuberKit::Core::ServiceStore
|
|
35
36
|
@@service_definitions[service_name]
|
36
37
|
end
|
37
38
|
|
39
|
+
Contract Symbol => Any
|
38
40
|
def get_service(service_name)
|
39
41
|
definition = get_definition(service_name)
|
40
42
|
|
@@ -11,8 +11,8 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
|
|
11
11
|
config_path = "#{configs.service_config_dir}/#{service.name}.yml"
|
12
12
|
shell.write(config_path, service_config)
|
13
13
|
|
14
|
-
|
15
|
-
kubectl_commands.apply_file(shell, config_path,
|
16
|
-
kubectl_commands.rolling_restart(shell, service.uri,
|
14
|
+
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
15
|
+
kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path)
|
16
|
+
kubectl_commands.rolling_restart(shell, service.uri, kubeconfig_path: kubeconfig_path)
|
17
17
|
end
|
18
18
|
end
|
@@ -2,10 +2,10 @@ require 'json'
|
|
2
2
|
require 'shellwords'
|
3
3
|
|
4
4
|
class KuberKit::Shell::KubectlCommands
|
5
|
-
def apply_file(shell, file_path,
|
5
|
+
def apply_file(shell, file_path, kubeconfig_path: nil)
|
6
6
|
command_parts = []
|
7
|
-
if
|
8
|
-
command_parts << "
|
7
|
+
if kubeconfig_path
|
8
|
+
command_parts << "KUBECONFIG=#{kubeconfig_path}"
|
9
9
|
end
|
10
10
|
|
11
11
|
command_parts << "kubectl apply -f #{file_path}"
|
@@ -13,7 +13,7 @@ class KuberKit::Shell::KubectlCommands
|
|
13
13
|
shell.exec!(command_parts.join(" "))
|
14
14
|
end
|
15
15
|
|
16
|
-
def rolling_restart(shell, deployment_name,
|
16
|
+
def rolling_restart(shell, deployment_name, kubeconfig_path: nil)
|
17
17
|
patch_deployment(shell, deployment_name, {
|
18
18
|
spec: {
|
19
19
|
template: {
|
@@ -24,13 +24,13 @@ class KuberKit::Shell::KubectlCommands
|
|
24
24
|
}
|
25
25
|
}
|
26
26
|
}
|
27
|
-
},
|
27
|
+
}, kubeconfig_path: kubeconfig_path)
|
28
28
|
end
|
29
29
|
|
30
|
-
def patch_deployment(shell, deployment_name, specs,
|
30
|
+
def patch_deployment(shell, deployment_name, specs, kubeconfig_path: nil)
|
31
31
|
command_parts = []
|
32
|
-
if
|
33
|
-
command_parts << "
|
32
|
+
if kubeconfig_path
|
33
|
+
command_parts << "KUBECONFIG=#{kubeconfig_path}"
|
34
34
|
end
|
35
35
|
|
36
36
|
specs_json = JSON.dump(specs).gsub('"', '\"')
|
data/lib/kuber_kit/version.rb
CHANGED