kuber_kit 1.1.4 → 1.1.6
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/CHANGELOG.md +32 -0
- data/README.md +2 -1
- data/kuber_kit.gemspec +3 -6
- data/lib/kuber_kit/actions/configuration_loader.rb +7 -1
- data/lib/kuber_kit/actions/kubectl_attacher.rb +7 -4
- data/lib/kuber_kit/actions/kubectl_logs.rb +7 -4
- data/lib/kuber_kit/actions/service_deployer.rb +33 -26
- data/lib/kuber_kit/actions/service_generator.rb +20 -0
- data/lib/kuber_kit/artifacts_sync/artifact_updater.rb +19 -9
- data/lib/kuber_kit/artifacts_sync/strategies/abstract.rb +9 -0
- data/lib/kuber_kit/artifacts_sync/strategies/git_updater.rb +46 -0
- data/lib/kuber_kit/artifacts_sync/strategies/null_updater.rb +12 -0
- data/lib/kuber_kit/cli.rb +29 -1
- data/lib/kuber_kit/configs.rb +3 -1
- data/lib/kuber_kit/container.rb +28 -4
- data/lib/kuber_kit/core/artifacts/abstract_artifact.rb +4 -0
- data/lib/kuber_kit/core/artifacts/git.rb +6 -1
- data/lib/kuber_kit/core/artifacts/local.rb +4 -0
- data/lib/kuber_kit/core/configuration.rb +10 -6
- data/lib/kuber_kit/core/configuration_definition.rb +30 -9
- data/lib/kuber_kit/core/configuration_factory.rb +3 -1
- data/lib/kuber_kit/core/context_helper/abstract_helper.rb +5 -0
- data/lib/kuber_kit/core/context_helper/base_helper.rb +1 -7
- data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +3 -1
- data/lib/kuber_kit/core/context_helper/context_vars.rb +20 -4
- data/lib/kuber_kit/core/context_helper/local_context_helper.rb +14 -0
- data/lib/kuber_kit/core/context_helper/service_helper.rb +15 -1
- data/lib/kuber_kit/core/dependencies/abstract_dependency_resolver.rb +7 -0
- data/lib/kuber_kit/core/service.rb +8 -5
- data/lib/kuber_kit/core/service_definition.rb +16 -4
- data/lib/kuber_kit/core/service_factory.rb +2 -1
- data/lib/kuber_kit/defaults.rb +13 -4
- data/lib/kuber_kit/image_compiler/image_builder.rb +1 -1
- data/lib/kuber_kit/service_deployer/service_dependency_resolver.rb +1 -1
- data/lib/kuber_kit/service_deployer/strategies/helm.rb +41 -0
- data/lib/kuber_kit/service_deployer/strategies/kubernetes.rb +8 -2
- data/lib/kuber_kit/service_generator/action_handler.rb +16 -0
- data/lib/kuber_kit/service_generator/generator.rb +26 -0
- data/lib/kuber_kit/service_generator/strategies/abstract.rb +5 -0
- data/lib/kuber_kit/service_generator/strategies/helm.rb +33 -0
- data/lib/kuber_kit/service_generator/strategy_detector.rb +6 -0
- data/lib/kuber_kit/service_reader/reader.rb +2 -10
- data/lib/kuber_kit/shell/commands/docker_commands.rb +1 -1
- data/lib/kuber_kit/shell/commands/git_commands.rb +10 -0
- data/lib/kuber_kit/shell/commands/helm_commands.rb +42 -0
- data/lib/kuber_kit/shell/commands/kubectl_commands.rb +3 -2
- data/lib/kuber_kit/shell/local_shell.rb +1 -1
- data/lib/kuber_kit/shell_launcher/strategies/kubernetes.rb +1 -1
- data/lib/kuber_kit/template_reader/reader.rb +1 -0
- data/lib/kuber_kit/template_reader/renderer.rb +17 -0
- data/lib/kuber_kit/template_reader/strategies/artifact_file.rb +1 -0
- data/lib/kuber_kit/tools/logger_factory.rb +1 -1
- data/lib/kuber_kit/version.rb +1 -1
- data/lib/kuber_kit.rb +23 -3
- metadata +35 -10
- data/lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb +0 -5
- data/lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb +0 -31
- data/lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fffaf809577e0796e0b18bcc8d61894276308e5792ba1e3c67b7d792dce32d0a
|
4
|
+
data.tar.gz: 73470e476a996467fe60b6e6966b9821e14f75492d0b53aee231db21995dfeb8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13a911f81ba63ff223073ffa2d4363827a5334b08bd8d99ea027b5de0d135a4b4323b87ddaf650dc1e63e7515022cd4ca119c968a12b1c7adb6a2a3ef897feff
|
7
|
+
data.tar.gz: b26560006e1c3c27cbf4a25363a8c4e3a5ebf673f55ffc549e9bf4d415023eec8e6b18cc8052859bde4efb24fe9d0d1a82ff55d9e0ead9284c68a4959b02f225
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
**1.3.3**
|
2
|
+
- Support "partials" in the templates with "render" method.
|
3
|
+
- Cleanup artifacts after deployment if cache_result: false
|
4
|
+
- Improve fetching git artifact when branch name has changed
|
5
|
+
|
6
|
+
**1.3.2**
|
7
|
+
- Added an ability to generate helm templates using `kit generate` command
|
8
|
+
|
9
|
+
**1.3.1**
|
10
|
+
- Fix upgrade command for helm strategy
|
11
|
+
|
12
|
+
**1.3.0**
|
13
|
+
- Allow sending custom apply command for k8s deploy strategy
|
14
|
+
- Added initial support for helm deploy strategy
|
15
|
+
|
16
|
+
**1.2.7**
|
17
|
+
- Added an option to skip deployment and only build images for `deploy` command
|
18
|
+
|
19
|
+
**1.2.6**
|
20
|
+
- Lock cli-ui version on 2.1.0 (2.2.x has some bugs)
|
21
|
+
|
22
|
+
**1.2.5**
|
23
|
+
- Improve handling ContextVars, ability to convert context var to OpenStruct
|
24
|
+
|
25
|
+
**1.2.4**
|
26
|
+
- Fix a mistake in setting env variables
|
27
|
+
- Added an option to set "use local deployment" variable
|
28
|
+
- Allow finding job resources in kit attach and kit log
|
29
|
+
|
30
|
+
**1.2.2**
|
31
|
+
- Support Ruby 3.2.0
|
32
|
+
|
1
33
|
**1.2.1**
|
2
34
|
- Update shell commands so that STDERR stream won't be merged for commands using the command result.
|
3
35
|
- kit sh would also set current default configuration
|
data/README.md
CHANGED
data/kuber_kit.gemspec
CHANGED
@@ -25,11 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
spec.required_ruby_version = ">= 2.7.0"
|
27
27
|
|
28
|
-
|
29
|
-
spec.add_dependency "contracts", '0.17.0'
|
30
|
-
else
|
31
|
-
spec.add_dependency "contracts", '0.16.0'
|
32
|
-
end
|
28
|
+
spec.add_dependency "contracts", '0.16.0'
|
33
29
|
|
34
30
|
spec.add_dependency "dry-auto_inject", "~> 0.9.0"
|
35
31
|
spec.add_dependency "dry-core", "~> 0.8.1"
|
@@ -37,9 +33,10 @@ Gem::Specification.new do |spec|
|
|
37
33
|
spec.add_dependency "dry-container", "~> 0.10.1"
|
38
34
|
|
39
35
|
spec.add_dependency "thor"
|
40
|
-
spec.add_dependency "cli-ui"
|
36
|
+
spec.add_dependency "cli-ui", '2.1.0'
|
41
37
|
spec.add_dependency "net-ssh"
|
42
38
|
spec.add_dependency "tty-prompt"
|
39
|
+
spec.add_dependency 'ed25519'
|
43
40
|
|
44
41
|
spec.add_development_dependency "bundler", "~> 2.2"
|
45
42
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -20,6 +20,7 @@ class KuberKit::Actions::ConfigurationLoader
|
|
20
20
|
configurations_path = options[:configurations_path] || File.join(root_path, configs.configurations_dirname)
|
21
21
|
configuration_name = options[:configuration] || ENV["KUBER_KIT_CONFIGURATION"]
|
22
22
|
load_inventory = options.fetch(:load_inventory, true)
|
23
|
+
use_local_deploy = options.fetch(:use_local_deploy, false)
|
23
24
|
|
24
25
|
ui.print_debug "ConfigurationLoader", "Launching kuber_kit with:"
|
25
26
|
ui.print_debug "ConfigurationLoader", " Root path: #{root_path.to_s.yellow}"
|
@@ -28,10 +29,11 @@ class KuberKit::Actions::ConfigurationLoader
|
|
28
29
|
ui.print_debug "ConfigurationLoader", " Infrastructure path: #{infra_path.to_s.yellow}"
|
29
30
|
ui.print_debug "ConfigurationLoader", " Configurations path: #{configurations_path.to_s.yellow}"
|
30
31
|
ui.print_debug "ConfigurationLoader", " Configuration name: #{configuration_name.to_s.yellow}"
|
32
|
+
ui.print_debug "ConfigurationLoader", " Use local deploy: #{use_local_deploy.to_s.yellow}"
|
31
33
|
|
32
34
|
ui.print_info("Logs", "See logs at: #{configs.log_file_path}")
|
33
35
|
|
34
|
-
unless File.
|
36
|
+
unless File.exist?(root_path)
|
35
37
|
ui.print_warning "ConfigurationLoader", "KuberKit root path #{root_path} doesn't exist. You may want to pass it --path parameter."
|
36
38
|
end
|
37
39
|
|
@@ -39,6 +41,10 @@ class KuberKit::Actions::ConfigurationLoader
|
|
39
41
|
raise KuberKit::Error, "The minimal required kuber_kit version is #{configs.kuber_kit_min_version}"
|
40
42
|
end
|
41
43
|
|
44
|
+
if use_local_deploy
|
45
|
+
ENV["KUBER_KIT_USE_LOCAL_DEPLOYMENT"] = "true"
|
46
|
+
end
|
47
|
+
|
42
48
|
load_configurations(configurations_path, configuration_name)
|
43
49
|
load_infrastructure(infra_path)
|
44
50
|
|
@@ -7,17 +7,20 @@ class KuberKit::Actions::KubectlAttacher
|
|
7
7
|
]
|
8
8
|
|
9
9
|
Contract Maybe[String], Hash => Any
|
10
|
-
def call(
|
10
|
+
def call(resource_name, options)
|
11
11
|
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
12
12
|
kubectl_entrypoint = KuberKit.current_configuration.kubectl_entrypoint
|
13
13
|
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
14
14
|
|
15
|
-
if !
|
16
|
-
|
15
|
+
if !resource_name
|
16
|
+
resource_name = resource_selector.call("attach", additional_resources: [
|
17
|
+
KuberKit::Kubernetes::Resources::POD,
|
18
|
+
KuberKit::Kubernetes::Resources::JOB
|
19
|
+
])
|
17
20
|
end
|
18
21
|
|
19
22
|
kubectl_commands.exec(
|
20
|
-
local_shell,
|
23
|
+
local_shell, resource_name, "bash", args: "-it",
|
21
24
|
kubeconfig_path: kubeconfig_path,
|
22
25
|
interactive: true,
|
23
26
|
namespace: deployer_namespace,
|
@@ -7,12 +7,15 @@ class KuberKit::Actions::KubectlLogs
|
|
7
7
|
]
|
8
8
|
|
9
9
|
Contract Maybe[String], Hash => Any
|
10
|
-
def call(
|
10
|
+
def call(resource_name, options)
|
11
11
|
kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
|
12
12
|
deployer_namespace = KuberKit.current_configuration.deployer_namespace
|
13
13
|
|
14
|
-
if !
|
15
|
-
|
14
|
+
if !resource_name
|
15
|
+
resource_name = resource_selector.call("attach", additional_resources: [
|
16
|
+
KuberKit::Kubernetes::Resources::POD,
|
17
|
+
KuberKit::Kubernetes::Resources::JOB
|
18
|
+
])
|
16
19
|
end
|
17
20
|
|
18
21
|
args = nil
|
@@ -21,7 +24,7 @@ class KuberKit::Actions::KubectlLogs
|
|
21
24
|
end
|
22
25
|
|
23
26
|
kubectl_commands.logs(
|
24
|
-
local_shell,
|
27
|
+
local_shell, resource_name,
|
25
28
|
args: args,
|
26
29
|
kubeconfig_path: kubeconfig_path,
|
27
30
|
namespace: deployer_namespace
|
@@ -29,11 +29,11 @@ class KuberKit::Actions::ServiceDeployer
|
|
29
29
|
services, tags = deployment_options_selector.call()
|
30
30
|
end
|
31
31
|
|
32
|
-
disabled_services
|
33
|
-
disabled_services
|
34
|
-
default_services
|
35
|
-
|
36
|
-
|
32
|
+
disabled_services = current_configuration.disabled_services.map(&:to_s)
|
33
|
+
disabled_services += skip_services if skip_services
|
34
|
+
default_services = current_configuration.default_services.map(&:to_s) - disabled_services
|
35
|
+
pre_deploy_services = current_configuration.pre_deploy_services.map(&:to_s) - disabled_services
|
36
|
+
post_deploy_services = current_configuration.post_deploy_services.map(&:to_s) - disabled_services
|
37
37
|
|
38
38
|
service_names = service_list_resolver.resolve(
|
39
39
|
services: services || [],
|
@@ -50,17 +50,19 @@ class KuberKit::Actions::ServiceDeployer
|
|
50
50
|
all_service_names = service_dependency_resolver.get_all(service_names)
|
51
51
|
end
|
52
52
|
|
53
|
+
all_service_names_with_hooks = (pre_deploy_services.map(&:to_sym) + all_service_names + post_deploy_services.map(&:to_sym)).uniq
|
54
|
+
|
53
55
|
unless all_service_names.any?
|
54
56
|
ui.print_warning "ServiceDeployer", "No service found with given options, nothing will be deployed."
|
55
57
|
return false
|
56
58
|
end
|
57
59
|
|
58
|
-
unless allow_deployment?(require_confirmation: require_confirmation, service_names:
|
60
|
+
unless allow_deployment?(require_confirmation: require_confirmation, service_names: all_service_names_with_hooks)
|
59
61
|
return false
|
60
62
|
end
|
61
63
|
|
62
64
|
# Compile images for all services and dependencies
|
63
|
-
images_names = get_image_names(service_names:
|
65
|
+
images_names = get_image_names(service_names: all_service_names_with_hooks.uniq)
|
64
66
|
unless skip_compile
|
65
67
|
compilation_result = compile_images(images_names)
|
66
68
|
|
@@ -72,33 +74,31 @@ class KuberKit::Actions::ServiceDeployer
|
|
72
74
|
return deployment_result
|
73
75
|
end
|
74
76
|
|
75
|
-
# First deploy
|
77
|
+
# First, deploy pre-deploy services.
|
76
78
|
# This feature is used to deploy some services, required for deployment of other services, e.g. env files
|
77
79
|
# Note: Initial services are deployed without dependencies
|
78
|
-
|
79
|
-
|
80
|
+
pre_deploy_services.map(&:to_sym).each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
81
|
+
deploy_simultaneously(batch_service_names, deployment_result)
|
82
|
+
end
|
80
83
|
|
81
|
-
|
84
|
+
# Next, deploy all initializers simultaneously.
|
85
|
+
# Note: In earlier versions, KuberKit would deploy all dependencies in the order defined by dependency tree.
|
86
|
+
# Now it would deploy all dependencies (initializers) at the same time, even if one initializer depends on another initializer.
|
87
|
+
unless skip_dependencies
|
88
|
+
initializers = service_dependency_resolver.get_all_deps(service_names)
|
89
|
+
initializers.map(&:to_sym).each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
82
90
|
deploy_simultaneously(batch_service_names, deployment_result)
|
83
91
|
end
|
84
92
|
end
|
85
93
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
if deployment_result.succeeded?
|
91
|
-
deploy_simultaneously(batch_service_names, deployment_result)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
else
|
95
|
-
service_dependency_resolver.each_with_deps(service_names) do |dep_service_names|
|
96
|
-
ui.print_debug("ServiceDeployer", "Scheduling to deploy: #{dep_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
94
|
+
# Next, deploy all requested services.
|
95
|
+
service_names.each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
96
|
+
deploy_simultaneously(batch_service_names, deployment_result)
|
97
|
+
end
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
99
|
+
# Last, deploy post-deploy services.
|
100
|
+
post_deploy_services.map(&:to_sym).each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
101
|
+
deploy_simultaneously(batch_service_names, deployment_result)
|
102
102
|
end
|
103
103
|
|
104
104
|
deployment_result
|
@@ -116,6 +116,13 @@ class KuberKit::Actions::ServiceDeployer
|
|
116
116
|
|
117
117
|
private
|
118
118
|
def deploy_simultaneously(service_names, deployment_result)
|
119
|
+
unless deployment_result.succeeded?
|
120
|
+
ui.print_debug("ServiceDeployer", "Deploymet already failed. Canceling: #{service_names.inspect}")
|
121
|
+
return
|
122
|
+
end
|
123
|
+
|
124
|
+
ui.print_debug("ServiceDeployer", "Scheduling to deploy: #{service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
125
|
+
|
119
126
|
task_group = ui.create_task_group
|
120
127
|
|
121
128
|
service_names.each do |service_name|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class KuberKit::Actions::ServiceGenerator
|
2
|
+
include KuberKit::Import[
|
3
|
+
"shell.local_shell",
|
4
|
+
"service_generator.action_handler",
|
5
|
+
"ui",
|
6
|
+
]
|
7
|
+
|
8
|
+
Contract Symbol, String => Any
|
9
|
+
def call(service_name, path)
|
10
|
+
expanded_path = File.expand_path(path)
|
11
|
+
puts expanded_path
|
12
|
+
action_handler.call(local_shell, service_name, expanded_path)
|
13
|
+
|
14
|
+
true
|
15
|
+
rescue KuberKit::Error => e
|
16
|
+
ui.print_error("Error", e.message)
|
17
|
+
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
@@ -1,27 +1,37 @@
|
|
1
1
|
class KuberKit::ArtifactsSync::ArtifactUpdater
|
2
|
-
|
2
|
+
StrategyNotFoundError = Class.new(KuberKit::NotFoundError)
|
3
3
|
|
4
4
|
include KuberKit::Import[
|
5
5
|
"ui"
|
6
6
|
]
|
7
7
|
|
8
|
-
def
|
9
|
-
@@
|
8
|
+
def use_strategy(strategy, artifact_class:)
|
9
|
+
@@strategies ||= {}
|
10
10
|
|
11
|
-
if !
|
12
|
-
raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::
|
11
|
+
if !strategy.is_a?(KuberKit::ArtifactsSync::Strategies::Abstract)
|
12
|
+
raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::Strategies::Abstract, got: #{strategy.inspect}")
|
13
13
|
end
|
14
14
|
|
15
|
-
@@
|
15
|
+
@@strategies[artifact_class] = strategy
|
16
16
|
end
|
17
17
|
|
18
18
|
def update(shell, artifact)
|
19
|
-
|
19
|
+
strategy = @@strategies[artifact.class]
|
20
20
|
|
21
21
|
ui.print_debug "ArtifactUpdater", "Updating artifact #{artifact.name.to_s.green}"
|
22
22
|
|
23
|
-
raise
|
23
|
+
raise StrategyNotFoundError, "Can't find strategy for artifact #{artifact}" if strategy.nil?
|
24
24
|
|
25
|
-
|
25
|
+
strategy.update(shell, artifact)
|
26
|
+
end
|
27
|
+
|
28
|
+
def cleanup(shell, artifact)
|
29
|
+
strategy = @@strategies[artifact.class]
|
30
|
+
|
31
|
+
ui.print_debug "ArtifactUpdater", "Cleaning artifact #{artifact.name.to_s.green}"
|
32
|
+
|
33
|
+
raise StrategyNotFoundError, "Can't find strategy for artifact #{artifact}" if strategy.nil?
|
34
|
+
|
35
|
+
strategy.cleanup(shell, artifact)
|
26
36
|
end
|
27
37
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class KuberKit::ArtifactsSync::Strategies::GitUpdater < KuberKit::ArtifactsSync::Strategies::Abstract
|
2
|
+
|
3
|
+
include KuberKit::Import[
|
4
|
+
"shell.git_commands",
|
5
|
+
"shell.bash_commands",
|
6
|
+
]
|
7
|
+
|
8
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
|
9
|
+
def update(shell, artifact)
|
10
|
+
already_cloned = artifact_already_cloned?(
|
11
|
+
shell: shell,
|
12
|
+
repo_path: artifact.cloned_path,
|
13
|
+
artifact: artifact
|
14
|
+
)
|
15
|
+
|
16
|
+
if already_cloned
|
17
|
+
git_commands.force_pull_repo(shell,
|
18
|
+
path: artifact.cloned_path, branch: artifact.branch
|
19
|
+
)
|
20
|
+
else
|
21
|
+
git_commands.download_repo(shell,
|
22
|
+
remote_url: artifact.remote_url, path: artifact.cloned_path, branch: artifact.branch
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
|
28
|
+
def cleanup(shell, artifact)
|
29
|
+
bash_commands.rm_rf(shell, artifact.cloned_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def artifact_already_cloned?(shell:, repo_path:, artifact:)
|
34
|
+
target_remote_url = git_commands.get_remote_url(shell, repo_path)
|
35
|
+
if target_remote_url != artifact.remote_url
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
|
39
|
+
target_branch = git_commands.get_branch_name(shell, repo_path)
|
40
|
+
if target_branch != artifact.branch
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class KuberKit::ArtifactsSync::Strategies::NullUpdater < KuberKit::ArtifactsSync::Strategies::Abstract
|
2
|
+
|
3
|
+
Contract KuberKit::Shell::AbstractShell, Any => Any
|
4
|
+
def update(shell, artifact)
|
5
|
+
return true
|
6
|
+
end
|
7
|
+
|
8
|
+
Contract KuberKit::Shell::AbstractShell, Any => Any
|
9
|
+
def cleanup(shell, artifact)
|
10
|
+
return true
|
11
|
+
end
|
12
|
+
end
|
data/lib/kuber_kit/cli.rb
CHANGED
@@ -11,6 +11,7 @@ class KuberKit::CLI < Thor
|
|
11
11
|
class_option :debug, :type => :boolean, aliases: ["-d"]
|
12
12
|
class_option :configuration, :type => :string, aliases: ["-C"]
|
13
13
|
class_option :user, :type => :string, aliases: ["-u"]
|
14
|
+
class_option :use_local_deploy, :type => :boolean, aliases: ["-l"]
|
14
15
|
|
15
16
|
desc "compile IMAGE_NAMES", "Compile image with IMAGE_NAMES (comma-separated)"
|
16
17
|
def compile(image_names_str)
|
@@ -23,6 +24,8 @@ class KuberKit::CLI < Thor
|
|
23
24
|
action_result = KuberKit::Container['actions.image_compiler'].call(image_names, options)
|
24
25
|
end
|
25
26
|
|
27
|
+
clean_artifacts(options)
|
28
|
+
|
26
29
|
if action_result && action_result.succeeded?
|
27
30
|
time = (Time.now.to_i - started_at)
|
28
31
|
print_result("Image compilation finished! (#{time}s)", result: {
|
@@ -63,6 +66,8 @@ class KuberKit::CLI < Thor
|
|
63
66
|
)
|
64
67
|
end
|
65
68
|
|
69
|
+
clean_artifacts(options)
|
70
|
+
|
66
71
|
if action_result && action_result.succeeded?
|
67
72
|
time = (Time.now.to_i - started_at)
|
68
73
|
print_result("Service deployment finished! (#{time}s)", result: {
|
@@ -110,6 +115,16 @@ class KuberKit::CLI < Thor
|
|
110
115
|
end
|
111
116
|
end
|
112
117
|
|
118
|
+
|
119
|
+
desc "generate SERVICE_NAME PATH_NAME", "Generates a template for a given service in a given path"
|
120
|
+
def generate(service_name, path)
|
121
|
+
setup(options)
|
122
|
+
|
123
|
+
if KuberKit::Container['actions.configuration_loader'].call(options)
|
124
|
+
KuberKit::Container['actions.service_generator'].call(service_name.to_sym, path)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
113
128
|
desc "apply FILE_PATH", "Apply FILE_PATH with kubectl"
|
114
129
|
def apply(file_path)
|
115
130
|
setup(options)
|
@@ -211,7 +226,7 @@ class KuberKit::CLI < Thor
|
|
211
226
|
# We should load config before loading any bean, to make sure that bean won't be built with default config
|
212
227
|
root_path = KuberKit::Container['tools.workdir_detector'].call(options)
|
213
228
|
config_file_path = File.join(root_path, APP_CONFIG_FILENAME)
|
214
|
-
if File.
|
229
|
+
if File.exist?(config_file_path)
|
215
230
|
require config_file_path
|
216
231
|
end
|
217
232
|
end
|
@@ -219,4 +234,17 @@ class KuberKit::CLI < Thor
|
|
219
234
|
def print_result(message, data = {})
|
220
235
|
KuberKit::Container['ui'].print_result(message, data)
|
221
236
|
end
|
237
|
+
|
238
|
+
def clean_artifacts(options)
|
239
|
+
artifacts = KuberKit.current_configuration.artifacts.values
|
240
|
+
artifacts_to_clean = artifacts.select(&:cleanup_needed?)
|
241
|
+
|
242
|
+
return unless artifacts_to_clean.any?
|
243
|
+
|
244
|
+
artifacts_to_clean.each do |artifact|
|
245
|
+
KuberKit::Container['artifacts_sync.artifact_updater'].cleanup(
|
246
|
+
KuberKit::Container['shell.local_shell'], artifact
|
247
|
+
)
|
248
|
+
end
|
249
|
+
end
|
222
250
|
end
|
data/lib/kuber_kit/configs.rb
CHANGED
@@ -5,7 +5,8 @@ class KuberKit::Configs
|
|
5
5
|
:image_dockerfile_name, :image_build_context_dir, :image_tag, :docker_ignore_list, :image_compile_dir, :remote_image_compile_dir,
|
6
6
|
:kuber_kit_dirname, :kuber_kit_min_version, :images_dirname, :services_dirname, :infra_dirname, :configurations_dirname,
|
7
7
|
:artifact_clone_dir, :service_config_dir, :deployer_strategy, :compile_simultaneous_limit, :deploy_simultaneous_limit,
|
8
|
-
:additional_images_paths, :deprecation_warnings_disabled, :log_file_path, :env_file_compile_dir, :shell_launcher_strategy,
|
8
|
+
:additional_images_paths, :deprecation_warnings_disabled, :log_file_path, :env_file_compile_dir, :shell_launcher_strategy,
|
9
|
+
:shell_launcher_sets_configration, :generator_strategy
|
9
10
|
]
|
10
11
|
DOCKER_IGNORE_LIST = [
|
11
12
|
'Dockerfile',
|
@@ -60,6 +61,7 @@ class KuberKit::Configs
|
|
60
61
|
set :log_file_path, File.join(absolute_kuber_kit_path, "deploy.log")
|
61
62
|
set :env_file_compile_dir, File.join(absolute_kuber_kit_path, "env_files")
|
62
63
|
set :shell_launcher_sets_configration, true
|
64
|
+
set :generator_strategy, :helm
|
63
65
|
end
|
64
66
|
|
65
67
|
def items
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -25,6 +25,10 @@ class KuberKit::Container
|
|
25
25
|
KuberKit::Actions::ServiceChecker.new
|
26
26
|
end
|
27
27
|
|
28
|
+
register "actions.service_generator" do
|
29
|
+
KuberKit::Actions::ServiceGenerator.new
|
30
|
+
end
|
31
|
+
|
28
32
|
register "actions.configuration_loader" do
|
29
33
|
KuberKit::Actions::ConfigurationLoader.new
|
30
34
|
end
|
@@ -181,6 +185,10 @@ class KuberKit::Container
|
|
181
185
|
KuberKit::Shell::Commands::SystemCommands.new
|
182
186
|
end
|
183
187
|
|
188
|
+
register "shell.helm_commands" do
|
189
|
+
KuberKit::Shell::Commands::HelmCommands.new
|
190
|
+
end
|
191
|
+
|
184
192
|
register "shell.local_shell" do
|
185
193
|
KuberKit::Shell::LocalShell.new
|
186
194
|
end
|
@@ -229,12 +237,12 @@ class KuberKit::Container
|
|
229
237
|
KuberKit::ArtifactsSync::ArtifactUpdater.new
|
230
238
|
end
|
231
239
|
|
232
|
-
register "artifacts_sync.
|
233
|
-
KuberKit::ArtifactsSync::
|
240
|
+
register "artifacts_sync.strategies.git_updater" do
|
241
|
+
KuberKit::ArtifactsSync::Strategies::GitUpdater.new
|
234
242
|
end
|
235
243
|
|
236
|
-
register "artifacts_sync.
|
237
|
-
KuberKit::ArtifactsSync::
|
244
|
+
register "artifacts_sync.strategies.null_updater" do
|
245
|
+
KuberKit::ArtifactsSync::Strategies::NullUpdater.new
|
238
246
|
end
|
239
247
|
|
240
248
|
register "env_file_reader.action_handler" do
|
@@ -269,6 +277,10 @@ class KuberKit::Container
|
|
269
277
|
KuberKit::TemplateReader::Reader.new
|
270
278
|
end
|
271
279
|
|
280
|
+
register "template_reader.renderer" do
|
281
|
+
KuberKit::TemplateReader::Renderer.new
|
282
|
+
end
|
283
|
+
|
272
284
|
register "template_reader.strategies.artifact_file" do
|
273
285
|
KuberKit::TemplateReader::Strategies::ArtifactFile.new
|
274
286
|
end
|
@@ -297,6 +309,18 @@ class KuberKit::Container
|
|
297
309
|
KuberKit::ServiceDeployer::ServiceDependencyResolver.new
|
298
310
|
end
|
299
311
|
|
312
|
+
register "service_generator.action_handler" do
|
313
|
+
KuberKit::ServiceGenerator::ActionHandler.new
|
314
|
+
end
|
315
|
+
|
316
|
+
register "service_generator.strategy_detector" do
|
317
|
+
KuberKit::ServiceGenerator::StrategyDetector.new
|
318
|
+
end
|
319
|
+
|
320
|
+
register "service_generator.generator" do
|
321
|
+
KuberKit::ServiceGenerator::Generator.new
|
322
|
+
end
|
323
|
+
|
300
324
|
register "service_reader.action_handler" do
|
301
325
|
KuberKit::ServiceReader::ActionHandler.new
|
302
326
|
end
|
@@ -5,12 +5,13 @@ class KuberKit::Core::Artifacts::Git < KuberKit::Core::Artifacts::AbstractArtifa
|
|
5
5
|
DEFAULT_REMOTE_NAME = "origin"
|
6
6
|
DEFAULT_BRANCH = "master"
|
7
7
|
|
8
|
-
def setup(remote_url:, remote_name: DEFAULT_REMOTE_NAME, branch: DEFAULT_BRANCH, clone_path: nil, ssh_key: DEFAULT_SSH_KEY)
|
8
|
+
def setup(remote_url:, remote_name: DEFAULT_REMOTE_NAME, branch: DEFAULT_BRANCH, clone_path: nil, ssh_key: DEFAULT_SSH_KEY, cache_result: true)
|
9
9
|
@remote_name = remote_name
|
10
10
|
@remote_url = remote_url
|
11
11
|
@branch = branch
|
12
12
|
@clone_path = clone_path
|
13
13
|
@ssh_key = ssh_key
|
14
|
+
@cache_result = cache_result
|
14
15
|
self
|
15
16
|
end
|
16
17
|
|
@@ -23,4 +24,8 @@ class KuberKit::Core::Artifacts::Git < KuberKit::Core::Artifacts::AbstractArtifa
|
|
23
24
|
def sync_description
|
24
25
|
"#{remote_url}:#{branch}"
|
25
26
|
end
|
27
|
+
|
28
|
+
def cleanup_needed?
|
29
|
+
!@cache_result
|
30
|
+
end
|
26
31
|
end
|