kuber_kit 0.4.1 → 0.4.2
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 +1 -1
- data/TODO.md +0 -2
- data/example/configurations/review.rb +1 -0
- data/lib/kuber_kit/actions/service_deployer.rb +14 -4
- data/lib/kuber_kit/cli.rb +11 -6
- data/lib/kuber_kit/core/configuration.rb +26 -24
- data/lib/kuber_kit/core/configuration_definition.rb +17 -10
- data/lib/kuber_kit/core/configuration_factory.rb +10 -9
- data/lib/kuber_kit/service_deployer/strategies/docker.rb +4 -3
- data/lib/kuber_kit/service_deployer/strategies/docker_compose.rb +2 -2
- 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: b6b58c988d13591ad950347cc3c2af370ab1604006d1ad0d04cf9cf43093ca36
|
4
|
+
data.tar.gz: 9b821db9a6f199ba10d9c8e509ba8f20eba2f91ecf400254f179d8e8099e2a82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 911c9304545c3182c42d8dab5dcdb52208b59479318cf8324d8b0654a3315865c73fa10f430fbe16618a1deae5fabeb45a783fa6e3430e2da86777d06689987e
|
7
|
+
data.tar.gz: bf884a9e9f0cbbc35b88069d532baa021e973ad425c0bd9b2236aac12736448c53d99798da8abbcab1bf284484de5ac850bbee5e2cf0d7d8004326ceb836271c
|
data/Gemfile.lock
CHANGED
data/TODO.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
- https://ttytoolkit.org/
|
2
2
|
- kit status should show the list of services and their status, with ability to select & view logs
|
3
|
-
- list services and require confirmation before deployment
|
4
|
-
- add kit logs support, should work similar to kit attach
|
5
3
|
- allow deploying only services enabled for specific configuration
|
6
4
|
- find a way to always deploy some service, e.g. for migrations and env_files
|
7
5
|
- template should be able to set default attributes
|
@@ -9,11 +9,12 @@ class KuberKit::Actions::ServiceDeployer
|
|
9
9
|
]
|
10
10
|
|
11
11
|
Contract KeywordArgs[
|
12
|
-
services:
|
13
|
-
tags:
|
14
|
-
skip_compile:
|
12
|
+
services: Maybe[ArrayOf[String]],
|
13
|
+
tags: Maybe[ArrayOf[String]],
|
14
|
+
skip_compile: Maybe[Bool],
|
15
|
+
require_confirmation: Maybe[Bool],
|
15
16
|
] => Any
|
16
|
-
def call(services:, tags:, skip_compile: false)
|
17
|
+
def call(services:, tags:, skip_compile: false, require_confirmation: false)
|
17
18
|
if services.empty? && tags.empty?
|
18
19
|
services, tags = show_tags_selection
|
19
20
|
end
|
@@ -25,6 +26,15 @@ class KuberKit::Actions::ServiceDeployer
|
|
25
26
|
|
26
27
|
unless service_names.any?
|
27
28
|
ui.print_warning "ServiceDeployer", "No service found with given options, nothing will be deployed."
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
|
32
|
+
services_list = service_names.map(&:to_s).map(&:yellow).join(", ")
|
33
|
+
ui.print_info "ServiceDeployer", "The following services will be deployed: #{services_list}"
|
34
|
+
|
35
|
+
if require_confirmation
|
36
|
+
result = ui.prompt("Please confirm to continue deployment", ["confirm".green, "cancel".red])
|
37
|
+
return false unless result == "confirm".green
|
28
38
|
end
|
29
39
|
|
30
40
|
services = service_names.map do |service_name|
|
data/lib/kuber_kit/cli.rb
CHANGED
@@ -29,17 +29,22 @@ class KuberKit::CLI < Thor
|
|
29
29
|
end
|
30
30
|
|
31
31
|
desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
|
32
|
-
method_option :services,
|
33
|
-
method_option :tags,
|
34
|
-
method_option :skip_compile,
|
32
|
+
method_option :services, :type => :array, aliases: ["-s"]
|
33
|
+
method_option :tags, :type => :array, aliases: ["-t"]
|
34
|
+
method_option :skip_compile, :type => :boolean, aliases: ["-B"]
|
35
|
+
method_option :require_confirmation, :type => :boolean, aliases: ["-r"]
|
35
36
|
def deploy
|
36
37
|
setup(options)
|
37
38
|
|
38
39
|
if KuberKit::Container['actions.configuration_loader'].call(options)
|
40
|
+
require_confirmation = options[:require_confirmation] ||
|
41
|
+
KuberKit.current_configuration.deployer_require_confirimation ||
|
42
|
+
false
|
39
43
|
result = KuberKit::Container['actions.service_deployer'].call(
|
40
|
-
services:
|
41
|
-
tags:
|
42
|
-
skip_compile:
|
44
|
+
services: options[:services] || [],
|
45
|
+
tags: options[:tags] || [],
|
46
|
+
skip_compile: options[:skip_compile] || false,
|
47
|
+
require_confirmation: require_confirmation
|
43
48
|
)
|
44
49
|
end
|
45
50
|
|
@@ -1,35 +1,37 @@
|
|
1
1
|
class KuberKit::Core::Configuration
|
2
2
|
attr_reader :name, :artifacts, :registries, :env_files, :templates, :kubeconfig_path,
|
3
|
-
:
|
4
|
-
:
|
3
|
+
:services_attributes, :build_servers, :global_build_vars,
|
4
|
+
:deployer_strategy, :deployer_namespace, :deployer_require_confirimation
|
5
5
|
|
6
6
|
Contract KeywordArgs[
|
7
|
-
name:
|
8
|
-
artifacts:
|
9
|
-
registries:
|
10
|
-
env_files:
|
11
|
-
templates:
|
12
|
-
kubeconfig_path:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
name: Symbol,
|
8
|
+
artifacts: Hash,
|
9
|
+
registries: Hash,
|
10
|
+
env_files: Hash,
|
11
|
+
templates: Hash,
|
12
|
+
kubeconfig_path: Maybe[String],
|
13
|
+
services_attributes: HashOf[Symbol => Hash],
|
14
|
+
build_servers: ArrayOf[KuberKit::Core::BuildServers::AbstractBuildServer],
|
15
|
+
global_build_vars: HashOf[Symbol => Any],
|
16
|
+
deployer_strategy: Symbol,
|
17
|
+
deployer_namespace: Maybe[Symbol],
|
18
|
+
deployer_require_confirimation: Bool,
|
18
19
|
] => Any
|
19
20
|
def initialize(name:, artifacts:, registries:, env_files:, templates:, kubeconfig_path:,
|
20
|
-
|
21
|
-
|
22
|
-
@name
|
23
|
-
@artifacts
|
24
|
-
@registries
|
25
|
-
@env_files
|
26
|
-
@templates
|
27
|
-
@kubeconfig_path
|
28
|
-
@
|
29
|
-
@deployer_namespace = deployer_namespace
|
30
|
-
@build_servers = build_servers
|
21
|
+
services_attributes:, build_servers:, global_build_vars:,
|
22
|
+
deployer_strategy:, deployer_namespace:, deployer_require_confirimation:)
|
23
|
+
@name = name
|
24
|
+
@artifacts = artifacts
|
25
|
+
@registries = registries
|
26
|
+
@env_files = env_files
|
27
|
+
@templates = templates
|
28
|
+
@kubeconfig_path = kubeconfig_path
|
29
|
+
@build_servers = build_servers
|
31
30
|
@services_attributes = services_attributes
|
32
31
|
@global_build_vars = global_build_vars
|
32
|
+
@deployer_strategy = deployer_strategy
|
33
|
+
@deployer_namespace = deployer_namespace
|
34
|
+
@deployer_require_confirimation = deployer_require_confirimation
|
33
35
|
end
|
34
36
|
|
35
37
|
def service_attributes(service_name)
|
@@ -17,18 +17,19 @@ class KuberKit::Core::ConfigurationDefinition
|
|
17
17
|
|
18
18
|
def to_attrs
|
19
19
|
OpenStruct.new(
|
20
|
-
name:
|
21
|
-
artifacts:
|
22
|
-
registries:
|
23
|
-
env_files:
|
24
|
-
templates:
|
25
|
-
kubeconfig_path:
|
26
|
-
|
27
|
-
|
28
|
-
enabled_services: @enabled_services,
|
29
|
-
build_servers: @build_servers,
|
20
|
+
name: @configuration_name,
|
21
|
+
artifacts: @artifacts,
|
22
|
+
registries: @registries,
|
23
|
+
env_files: @env_files,
|
24
|
+
templates: @templates,
|
25
|
+
kubeconfig_path: @kubeconfig_path,
|
26
|
+
enabled_services: @enabled_services,
|
27
|
+
build_servers: @build_servers,
|
30
28
|
services_attributes: @services_attributes,
|
31
29
|
global_build_vars: @global_build_vars,
|
30
|
+
deployer_strategy: @deployer_strategy,
|
31
|
+
deployer_namespace: @deployer_namespace,
|
32
|
+
deployer_require_confirimation: @deployer_require_confirimation || false,
|
32
33
|
)
|
33
34
|
end
|
34
35
|
|
@@ -94,6 +95,12 @@ class KuberKit::Core::ConfigurationDefinition
|
|
94
95
|
self
|
95
96
|
end
|
96
97
|
|
98
|
+
def deployer_require_confirimation
|
99
|
+
@deployer_require_confirimation = true
|
100
|
+
|
101
|
+
self
|
102
|
+
end
|
103
|
+
|
97
104
|
def enabled_services(services)
|
98
105
|
if services.is_a?(Hash)
|
99
106
|
@enabled_services += services.keys.map(&:to_sym)
|
@@ -20,17 +20,18 @@ 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
|
-
deployer_namespace: configuration_attrs.deployer_namespace,
|
31
|
-
build_servers: 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
|
+
build_servers: build_servers,
|
32
30
|
services_attributes: configuration_attrs.services_attributes,
|
33
31
|
global_build_vars: configuration_attrs.global_build_vars || {},
|
32
|
+
deployer_strategy: configuration_attrs.deployer_strategy || configs.deployer_strategy,
|
33
|
+
deployer_namespace: configuration_attrs.deployer_namespace,
|
34
|
+
deployer_require_confirimation: configuration_attrs.deployer_require_confirimation,
|
34
35
|
)
|
35
36
|
end
|
36
37
|
|
@@ -25,8 +25,8 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
25
25
|
end
|
26
26
|
|
27
27
|
container_name = strategy_options.fetch(:container_name, service.uri)
|
28
|
-
command_name = strategy_options.fetch(:command_name,
|
29
|
-
custom_args
|
28
|
+
command_name = strategy_options.fetch(:command_name, nil)
|
29
|
+
custom_args = strategy_options.fetch(:custom_args, nil)
|
30
30
|
networks = strategy_options.fetch(:networks, [])
|
31
31
|
volumes = strategy_options.fetch(:volumes, [])
|
32
32
|
|
@@ -50,7 +50,8 @@ class KuberKit::ServiceDeployer::Strategies::Docker < KuberKit::ServiceDeployer:
|
|
50
50
|
custom_args << "--network #{network}"
|
51
51
|
end
|
52
52
|
volumes.each do |volume|
|
53
|
-
|
53
|
+
volume_name, _ = volume.split(":")
|
54
|
+
docker_commands.create_volume(shell, volume_name) unless volume_name.start_with?("/")
|
54
55
|
custom_args << "--volume #{volume}"
|
55
56
|
end
|
56
57
|
|
@@ -25,8 +25,8 @@ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDe
|
|
25
25
|
end
|
26
26
|
|
27
27
|
service_name = strategy_options.fetch(:service_name, service.name.to_s)
|
28
|
-
command_name = strategy_options.fetch(:command_name,
|
29
|
-
custom_args
|
28
|
+
command_name = strategy_options.fetch(:command_name, nil)
|
29
|
+
custom_args = strategy_options.fetch(:custom_args, nil)
|
30
30
|
|
31
31
|
docker_compose_commands.run(shell, config_path,
|
32
32
|
service: service_name,
|
data/lib/kuber_kit/version.rb
CHANGED