kuber_kit 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +23 -0
- data/lib/kuber_kit/actions/service_deployer.rb +21 -7
- data/lib/kuber_kit/cli.rb +3 -1
- data/lib/kuber_kit/container.rb +4 -0
- data/lib/kuber_kit/core/artifact_path.rb +8 -0
- data/lib/kuber_kit/core/artifact_path_resolver.rb +13 -0
- data/lib/kuber_kit/service_deployer/service_list_resolver.rb +1 -1
- data/lib/kuber_kit/shell/commands/kubectl_commands.rb +17 -2
- data/lib/kuber_kit/version.rb +1 -1
- data/lib/kuber_kit.rb +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5429f626563faf0dae4a1eea1b4eab7497830b428854bbdd848c65ec628cb19
|
4
|
+
data.tar.gz: be07f4b3115b9466232ddf889bbbe747a6c9f8b77ea422e1ce39a2631c98dce0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 821a68b8717e7ae248406453c075bc1334a240bcfbed229ed3411a403e952e3b100e6b60ecbb2ec93fdf793f02818b390830f95b2f5d745c16833e09a26574fe
|
7
|
+
data.tar.gz: b0a0d0ad446ae16e0c7580a39eb5efbe3fd5e312d75c699d73ef99f94c5c99a524f90ad8f8a0c9d4b133f0bd20bcbf291623c55f7c821b32120c6767d021a82e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,6 +12,29 @@ Add this line to your application's Gemfile:
|
|
12
12
|
gem 'kuber_kit'
|
13
13
|
```
|
14
14
|
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
### Available commands
|
18
|
+
|
19
|
+
* `kit apply FILE_PATH` - Apply FILE_PATH with kubectl. Doesn't guarantee service restart. E.g. `kit apply -C community ~/.kuber_kit/services/main_app_sidekiq.yml`.
|
20
|
+
* `kit attach` - Attach to POD_NAME. E.g. `kit attach -C community main-app-sidekiq-797646db88-7s4g7`
|
21
|
+
* `kit compile IMAGE_NAMES` - Compile image with IMAGE_NAMES (comma-separated), and pushes to registry. Does not launch service. E.g. `kit compile -C community main_app_sidekiq`
|
22
|
+
* `kit console POD_NAME` - Attach to POD_NAME & launch bin/console. E.g. `kit console -C community main-app-sidekiq-797646db88-7s4g7`
|
23
|
+
* `kit deploy` - Deploy all services
|
24
|
+
* `kit env ENV_FILE_NAME` - Return content of Env File ENV_FILE_NAME, where ENV_FILE_NAME artifact added by `KuberKit.add_env_file` in config files. E.g. `kit env -C community env_rke_community`
|
25
|
+
* `kit help [COMMAND]` - Describe available commands or one specific command
|
26
|
+
* `kit logs POD_NAME` - Show logs for POD_NAME. E.g. `kit logs -C community main-app-sidekiq-797646db88-7s4g7`
|
27
|
+
* `kit service SERVICE_NAME` - Return content of Service. E.g. `kit service -C community main_app_sidekiq`
|
28
|
+
* `kit template TEMPLATE_NAME` - Return content of Template. E.g. `kit template -C community web_app`
|
29
|
+
* `kit version` - Print current version
|
30
|
+
|
31
|
+
### Deploy Specific services
|
32
|
+
|
33
|
+
* `kit deploy -t blogging` - Deploy all services with tag blogging
|
34
|
+
* `kit deploy -s blogging_app` - Deploy service with name blogging_app
|
35
|
+
* `kit deploy -s *_app` - Deploy all services with name ending `_app`
|
36
|
+
* `kit deploy -t blogging -s ^*_app` - Deploy all services with tag blogging, except ones ending with `_app`
|
37
|
+
|
15
38
|
## Development
|
16
39
|
|
17
40
|
### Launch compilation
|
@@ -17,9 +17,10 @@ class KuberKit::Actions::ServiceDeployer
|
|
17
17
|
tags: Maybe[ArrayOf[String]],
|
18
18
|
skip_services: Maybe[ArrayOf[String]],
|
19
19
|
skip_compile: Maybe[Bool],
|
20
|
+
skip_dependencies: Maybe[Bool],
|
20
21
|
require_confirmation: Maybe[Bool],
|
21
22
|
] => Any
|
22
|
-
def call(services:, tags:, skip_services: nil, skip_compile: false, require_confirmation: false)
|
23
|
+
def call(services:, tags:, skip_services: nil, skip_compile: false, skip_dependencies: false, require_confirmation: false)
|
23
24
|
deployment_result = KuberKit::Actions::ActionResult.new()
|
24
25
|
current_configuration = KuberKit.current_configuration
|
25
26
|
|
@@ -30,7 +31,6 @@ class KuberKit::Actions::ServiceDeployer
|
|
30
31
|
default_services = current_configuration.default_services.map(&:to_s)
|
31
32
|
disabled_services = current_configuration.disabled_services.map(&:to_s)
|
32
33
|
disabled_services += skip_services if skip_services
|
33
|
-
|
34
34
|
|
35
35
|
service_names = service_list_resolver.resolve(
|
36
36
|
services: services || [],
|
@@ -41,7 +41,11 @@ class KuberKit::Actions::ServiceDeployer
|
|
41
41
|
).map(&:to_sym)
|
42
42
|
|
43
43
|
# Return the list of services with all dependencies.
|
44
|
-
|
44
|
+
if skip_dependencies
|
45
|
+
all_service_names = service_names
|
46
|
+
else
|
47
|
+
all_service_names = service_dependency_resolver.get_all(service_names)
|
48
|
+
end
|
45
49
|
|
46
50
|
unless all_service_names.any?
|
47
51
|
ui.print_warning "ServiceDeployer", "No service found with given options, nothing will be deployed."
|
@@ -60,11 +64,21 @@ class KuberKit::Actions::ServiceDeployer
|
|
60
64
|
return false unless compilation_result && compilation_result.succeeded?
|
61
65
|
end
|
62
66
|
|
63
|
-
|
64
|
-
|
67
|
+
if skip_dependencies
|
68
|
+
service_names.each_slice(configs.deploy_simultaneous_limit) do |batch_service_names|
|
69
|
+
ui.print_debug("ServiceDeployer", "Scheduling to compile: #{batch_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
70
|
+
|
71
|
+
if deployment_result.succeeded?
|
72
|
+
deploy_simultaneously(batch_service_names, deployment_result)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
else
|
76
|
+
service_dependency_resolver.each_with_deps(service_names) do |dep_service_names|
|
77
|
+
ui.print_debug("ServiceDeployer", "Scheduling to compile: #{dep_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
|
65
78
|
|
66
|
-
|
67
|
-
|
79
|
+
if deployment_result.succeeded?
|
80
|
+
deploy_simultaneously(dep_service_names, deployment_result)
|
81
|
+
end
|
68
82
|
end
|
69
83
|
end
|
70
84
|
|
data/lib/kuber_kit/cli.rb
CHANGED
@@ -39,6 +39,7 @@ class KuberKit::CLI < Thor
|
|
39
39
|
method_option :tags, :type => :array, aliases: ["-t"], repeatable: true
|
40
40
|
method_option :skip_services, :type => :array, aliases: ["-S"], repeatable: true
|
41
41
|
method_option :skip_compile, :type => :boolean, aliases: ["-B"]
|
42
|
+
method_option :skip_dependencies, :type => :boolean, aliases: ["-D"]
|
42
43
|
method_option :require_confirmation, :type => :boolean, aliases: ["-r"]
|
43
44
|
def deploy
|
44
45
|
setup(options)
|
@@ -53,7 +54,8 @@ class KuberKit::CLI < Thor
|
|
53
54
|
tags: (options[:tags] || []).flatten.uniq,
|
54
55
|
skip_services: (options[:skip_services] || []).flatten.uniq,
|
55
56
|
skip_compile: options[:skip_compile] || false,
|
56
|
-
|
57
|
+
skip_dependencies: options[:skip_dependencies] || false
|
58
|
+
require_confirmation: require_confirmation,
|
57
59
|
)
|
58
60
|
end
|
59
61
|
|
data/lib/kuber_kit/container.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
class KuberKit::Core::ArtifactPathResolver < KuberKit::EnvFileReader::Strategies::Abstract
|
2
|
+
include KuberKit::Import[
|
3
|
+
"core.artifact_store"
|
4
|
+
]
|
5
|
+
|
6
|
+
Contract KuberKit::Core::ArtifactPath => String
|
7
|
+
def call(artifact_path)
|
8
|
+
artifact = artifact_store.get(artifact_path.artifact_name)
|
9
|
+
|
10
|
+
file_parts = [artifact.cloned_path, artifact_path.file_path].compact
|
11
|
+
File.join(*file_parts)
|
12
|
+
end
|
13
|
+
end
|
@@ -2,9 +2,24 @@ require 'json'
|
|
2
2
|
require 'shellwords'
|
3
3
|
|
4
4
|
class KuberKit::Shell::Commands::KubectlCommands
|
5
|
+
include KuberKit::Import[
|
6
|
+
"core.artifact_path_resolver"
|
7
|
+
]
|
8
|
+
|
9
|
+
Contract KuberKit::Shell::AbstractShell, Or[String, ArrayOf[String]], KeywordArgs[
|
10
|
+
kubeconfig_path: Maybe[Or[
|
11
|
+
String, KuberKit::Core::ArtifactPath
|
12
|
+
]],
|
13
|
+
namespace: Maybe[String],
|
14
|
+
interactive: Optional[Bool],
|
15
|
+
] => Any
|
5
16
|
def kubectl_run(shell, command_list, kubeconfig_path: nil, namespace: nil, interactive: false)
|
6
17
|
command_parts = []
|
18
|
+
|
7
19
|
if kubeconfig_path
|
20
|
+
if kubeconfig_path.is_a?(KuberKit::Core::ArtifactPath)
|
21
|
+
kubeconfig_path = artifact_path_resolver.call(kubeconfig_path)
|
22
|
+
end
|
8
23
|
command_parts << "KUBECONFIG=#{kubeconfig_path}"
|
9
24
|
end
|
10
25
|
|
@@ -41,11 +56,11 @@ class KuberKit::Shell::Commands::KubectlCommands
|
|
41
56
|
end
|
42
57
|
|
43
58
|
def logs(shell, pod_name, args: nil, kubeconfig_path: nil, namespace: nil)
|
44
|
-
kubectl_run(shell, ["logs", args, pod_name], kubeconfig_path: kubeconfig_path, interactive: true, namespace: namespace)
|
59
|
+
kubectl_run(shell, ["logs", args, pod_name].compact, kubeconfig_path: kubeconfig_path, interactive: true, namespace: namespace)
|
45
60
|
end
|
46
61
|
|
47
62
|
def describe(shell, resource_name, args: nil, kubeconfig_path: nil, namespace: nil)
|
48
|
-
kubectl_run(shell, ["describe", args, resource_name], kubeconfig_path: kubeconfig_path, interactive: true, namespace: namespace)
|
63
|
+
kubectl_run(shell, ["describe", args, resource_name].compact, kubeconfig_path: kubeconfig_path, interactive: true, namespace: namespace)
|
49
64
|
end
|
50
65
|
|
51
66
|
def get_resources(shell, resource_type, field_selector: nil, jsonpath: ".items[*].metadata.name", kubeconfig_path: nil, namespace: nil)
|
data/lib/kuber_kit/version.rb
CHANGED
data/lib/kuber_kit.rb
CHANGED
@@ -13,6 +13,9 @@ module KuberKit
|
|
13
13
|
NotFoundError = Class.new(Error)
|
14
14
|
|
15
15
|
module Core
|
16
|
+
autoload :ArtifactPath, 'core/artifact_path'
|
17
|
+
autoload :ArtifactPathResolver, 'core/artifact_path_resolver'
|
18
|
+
|
16
19
|
autoload :ImageDefinition, 'core/image_definition'
|
17
20
|
autoload :ImageDefinitionFactory, 'core/image_definition_factory'
|
18
21
|
autoload :ImageStore, 'core/image_store'
|
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.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Iskander Khaziev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: contracts
|
@@ -255,6 +255,8 @@ files:
|
|
255
255
|
- lib/kuber_kit/cli.rb
|
256
256
|
- lib/kuber_kit/configs.rb
|
257
257
|
- lib/kuber_kit/container.rb
|
258
|
+
- lib/kuber_kit/core/artifact_path.rb
|
259
|
+
- lib/kuber_kit/core/artifact_path_resolver.rb
|
258
260
|
- lib/kuber_kit/core/artifacts/abstract_artifact.rb
|
259
261
|
- lib/kuber_kit/core/artifacts/artifact_store.rb
|
260
262
|
- lib/kuber_kit/core/artifacts/git.rb
|