kuber_kit 0.7.1 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5384a7795eb49fdf9beeb9481fc03e871fb001cda72d365a646f2ca3885309e9
4
- data.tar.gz: 229512248e019960f5f178cdd4a5c7ca99ca808d70e7286884fc152570366e73
3
+ metadata.gz: c5429f626563faf0dae4a1eea1b4eab7497830b428854bbdd848c65ec628cb19
4
+ data.tar.gz: be07f4b3115b9466232ddf889bbbe747a6c9f8b77ea422e1ce39a2631c98dce0
5
5
  SHA512:
6
- metadata.gz: 8ab657438fc9c8463528fed4938518365abda3b944416600ad3032deff7deb8afbd2c90cca99b1fea97f9d148d2b8df77759b11a10c441fa7d7c1f672897641e
7
- data.tar.gz: 70824969dae53951c1ac194922dc76d3773d6f65e8c51ff3589c46de9ec702d027a55ad9516e9846b81cde969c2ebab7cdb84be5f5617b216854929fd56c6bdb
6
+ metadata.gz: 821a68b8717e7ae248406453c075bc1334a240bcfbed229ed3411a403e952e3b100e6b60ecbb2ec93fdf793f02818b390830f95b2f5d745c16833e09a26574fe
7
+ data.tar.gz: b0a0d0ad446ae16e0c7580a39eb5efbe3fd5e312d75c699d73ef99f94c5c99a524f90ad8f8a0c9d4b133f0bd20bcbf291623c55f7c821b32120c6767d021a82e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ **0.8.0**
2
+ - Allow deploying services without dependecies
3
+ - Default services should be first in the list
4
+ - KubeConfig should be able to take file from artifact
5
+
1
6
  **0.7.0**
2
7
  - Added Ruby 3.0 support
3
8
 
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
- all_service_names = service_dependency_resolver.get_all(service_names)
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
- service_dependency_resolver.each_with_deps(service_names) do |dep_service_names|
64
- ui.print_debug("ServiceDeployer", "Scheduling to compile: #{dep_service_names.inspect}. Limit: #{configs.deploy_simultaneous_limit}")
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
- if deployment_result.succeeded?
67
- deploy_simultaneously(dep_service_names, deployment_result)
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
- require_confirmation: require_confirmation
57
+ skip_dependencies: options[:skip_dependencies] || false
58
+ require_confirmation: require_confirmation,
57
59
  )
58
60
  end
59
61
 
@@ -61,6 +61,10 @@ class KuberKit::Container
61
61
  KuberKit::Configs.new
62
62
  end
63
63
 
64
+ register "core.artifact_path_resolver" do
65
+ KuberKit::Core::ArtifactPathResolver.new
66
+ end
67
+
64
68
  register "core.image_factory" do
65
69
  KuberKit::Core::ImageFactory.new
66
70
  end
@@ -0,0 +1,8 @@
1
+ class KuberKit::Core::ArtifactPath
2
+ attr_reader :artifact_name, :file_path
3
+
4
+ def initialize(artifact_name:, file_path:)
5
+ @artifact_name = artifact_name
6
+ @file_path = file_path
7
+ end
8
+ end
@@ -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
@@ -43,7 +43,7 @@ class KuberKit::ServiceDeployer::ServiceListResolver
43
43
  end
44
44
 
45
45
  if included_services.any?
46
- included_services += default_services
46
+ included_services = default_services + included_services
47
47
  end
48
48
 
49
49
  included_services
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.0"
3
3
  end
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.7.1
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: 2021-09-20 00:00:00.000000000 Z
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