kuber_kit 0.7.1 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5384a7795eb49fdf9beeb9481fc03e871fb001cda72d365a646f2ca3885309e9
4
- data.tar.gz: 229512248e019960f5f178cdd4a5c7ca99ca808d70e7286884fc152570366e73
3
+ metadata.gz: b69eac4e6129cfa8a312b6066fc9d1a8164885928880add9c170ebb1a8914519
4
+ data.tar.gz: a38ea5783826d7366cf03eb6722132a9a1167b6a418d94d8be2442571f760d1a
5
5
  SHA512:
6
- metadata.gz: 8ab657438fc9c8463528fed4938518365abda3b944416600ad3032deff7deb8afbd2c90cca99b1fea97f9d148d2b8df77759b11a10c441fa7d7c1f672897641e
7
- data.tar.gz: 70824969dae53951c1ac194922dc76d3773d6f65e8c51ff3589c46de9ec702d027a55ad9516e9846b81cde969c2ebab7cdb84be5f5617b216854929fd56c6bdb
6
+ metadata.gz: bdb45aac937ba742197e8d5686ea18253fc0cb6093291bc34bc026b3a60f212cd347b9b54c16640561f33dc8e687e96f234b581402833604d26883ac852b3889
7
+ data.tar.gz: 337c593fd7826908f5b388829844ee0220e3851fb8117313afcd83f4ebd54b5cfac7747a4da497b6873eb995bc8d3d80a88776e845c5c45398b24ac4fc16b642
data/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
- **0.7.0**
1
+ **0.8.3**
2
+ - Always load artifacts, if kubeconfig is an artifact
3
+
4
+ **0.8.2**
5
+ - Update Kit Env command to support kubeconfig path as artifact
6
+
7
+ **0.8.1**
8
+ - Allow deploying services without dependecies
9
+ - Default services should be first in the list
10
+ - KubeConfig should be able to take file from artifact
11
+
12
+ **0.7.1**
2
13
  - Added Ruby 3.0 support
3
14
 
4
15
  **0.6.4**
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
@@ -42,9 +42,11 @@ class KuberKit::Actions::ConfigurationLoader
42
42
  load_configurations(configurations_path, configuration_name)
43
43
  load_infrastructure(infra_path)
44
44
 
45
- if load_inventory
45
+ if load_inventory || KuberKit.current_configuration.kubeconfig_path.is_a?(KuberKit::Core::ArtifactPath)
46
46
  update_artifacts(KuberKit.current_configuration.artifacts.values)
47
+ end
47
48
 
49
+ if load_inventory
48
50
  ui.create_task("Loading image definitions") do |task|
49
51
  files = image_store.load_definitions(images_path)
50
52
 
@@ -1,5 +1,6 @@
1
1
  class KuberKit::Actions::KubectlEnv
2
2
  include KuberKit::Import[
3
+ "core.artifact_path_resolver",
3
4
  "shell.local_shell",
4
5
  "ui"
5
6
  ]
@@ -8,6 +9,11 @@ class KuberKit::Actions::KubectlEnv
8
9
  def call(options)
9
10
  configuration = KuberKit.current_configuration
10
11
  kubeconfig_path = configuration.kubeconfig_path
12
+
13
+ if kubeconfig_path.is_a?(KuberKit::Core::ArtifactPath)
14
+ kubeconfig_path = artifact_path_resolver.call(kubeconfig_path)
15
+ end
16
+
11
17
  ui.print_info("ENV", "export KUBECONFIG=#{kubeconfig_path}")
12
18
 
13
19
  true
@@ -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,6 +54,7 @@ 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,
57
+ skip_dependencies: options[:skip_dependencies] || false,
56
58
  require_confirmation: require_confirmation
57
59
  )
58
60
  end
@@ -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
@@ -10,7 +10,7 @@ class KuberKit::Core::Configuration
10
10
  registries: Hash,
11
11
  env_files: Hash,
12
12
  templates: Hash,
13
- kubeconfig_path: Maybe[String],
13
+ kubeconfig_path: Maybe[Or[String, KuberKit::Core::ArtifactPath]],
14
14
  services_attributes: HashOf[Symbol => Hash],
15
15
  enabled_services: ArrayOf[Symbol],
16
16
  disabled_services: ArrayOf[Symbol],
@@ -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,8 +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
+
19
+ if kubeconfig_path.is_a?(KuberKit::Core::ArtifactPath)
20
+ kubeconfig_path = artifact_path_resolver.call(kubeconfig_path)
21
+ end
22
+
7
23
  if kubeconfig_path
8
24
  command_parts << "KUBECONFIG=#{kubeconfig_path}"
9
25
  end
@@ -41,11 +57,11 @@ class KuberKit::Shell::Commands::KubectlCommands
41
57
  end
42
58
 
43
59
  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)
60
+ kubectl_run(shell, ["logs", args, pod_name].compact, kubeconfig_path: kubeconfig_path, interactive: true, namespace: namespace)
45
61
  end
46
62
 
47
63
  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)
64
+ kubectl_run(shell, ["describe", args, resource_name].compact, kubeconfig_path: kubeconfig_path, interactive: true, namespace: namespace)
49
65
  end
50
66
 
51
67
  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.3"
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.3
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