kuber_kit 1.2.7 → 1.3.1

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: cd7d5abd9465de05ab9c906588764edf855660b2ce2866d41d36ee5bbcf222a0
4
- data.tar.gz: beb7e47b16c3076ade6b34de4e8c41806b832aad291db2b58a651407db53f768
3
+ metadata.gz: 31078802fb9b9050b29675dd4b364c667ea7dc0f554b395144166fa2b7e0ffce
4
+ data.tar.gz: 585c56af43570387ee0ceb0985d0ceb2cbac7a4d5627103be1471f6757d2eabd
5
5
  SHA512:
6
- metadata.gz: da1808570e50ca73338d5055c41405d7f950a6d329d5cbe4663afe6ff9381f000c3339205407be0ee5437be1e4aafcfa3da7fdb5abb97ae6405616be44a27932
7
- data.tar.gz: 3deccb2c4b267f3222b8bf1235c12406ef0df0100782c2f645deabeffd104da02be461079243a8d6aed607188a0086653815bcaca053a1b219d6c361ac756d91
6
+ metadata.gz: 50a194368b224a8b35a6b24a9a22897a9ed0c891eb6888fee5f9c3e788d4114618647b18a6cffe31772cff641b2ee37361bb02cc14838eb18ea1ecd5b1fab3dd
7
+ data.tar.gz: dc9c31daed2206895a685aec0737656f387d9d08726f5897a8fb5b89bcce254683231b809ccf75b5b4e4a88ca39cb65ec41b2a688513ac559dd842510f09e823
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.2.0
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ **1.3.1**
2
+ - Fix upgrade command for helm strategy
3
+
4
+ **1.3.0**
5
+ - Allow sending custom apply command for k8s deploy strategy
6
+ - Added initial support for helm deploy strategy
7
+
1
8
  **1.2.7**
2
9
  - Added an option to skip deployment and only build images for `deploy` command
3
10
 
@@ -181,6 +181,10 @@ class KuberKit::Container
181
181
  KuberKit::Shell::Commands::SystemCommands.new
182
182
  end
183
183
 
184
+ register "shell.helm_commands" do
185
+ KuberKit::Shell::Commands::HelmCommands.new
186
+ end
187
+
184
188
  register "shell.local_shell" do
185
189
  KuberKit::Shell::LocalShell.new
186
190
  end
@@ -39,6 +39,10 @@ class KuberKit::Defaults
39
39
  :docker_compose,
40
40
  KuberKit::ServiceDeployer::Strategies::DockerCompose.new
41
41
  )
42
+ container["service_deployer.deployer"].register_strategy(
43
+ :helm,
44
+ KuberKit::ServiceDeployer::Strategies::Helm.new
45
+ )
42
46
 
43
47
  container["shell_launcher.launcher"].register_strategy(
44
48
  :kubernetes,
@@ -0,0 +1,41 @@
1
+ class KuberKit::ServiceDeployer::Strategies::Helm < KuberKit::ServiceDeployer::Strategies::Abstract
2
+ include KuberKit::Import[
3
+ "service_reader.reader",
4
+ "shell.helm_commands",
5
+ "shell.bash_commands",
6
+ "configs",
7
+ ]
8
+
9
+ Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
10
+ def deploy(shell, service)
11
+ service_config = reader.read(shell, service)
12
+ chart_root_path = File.join(configs.service_config_dir, "#{service.name}_chart")
13
+ chart_templates_path = File.join(chart_root_path, "templates")
14
+ chart_config_path = File.join(chart_root_path, "Chart.yaml")
15
+ release_path = File.join(chart_templates_path, "release.yaml")
16
+
17
+ bash_commands.mkdir_p(shell, File.dirname(chart_root_path))
18
+ bash_commands.mkdir_p(shell, File.dirname(chart_templates_path))
19
+
20
+ shell.write(release_path, service_config)
21
+ shell.write(chart_config_path, chart_config_content(service.uri))
22
+
23
+ kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
24
+ namespace = KuberKit.current_configuration.deployer_namespace
25
+
26
+ upgrade_result = helm_commands.upgrade(shell, service.uri, chart_root_path, kubeconfig_path: kubeconfig_path, namespace: namespace)
27
+
28
+ upgrade_result
29
+ end
30
+
31
+ def chart_config_content(release_name)
32
+ query = <<-CHART
33
+ apiVersion: v2
34
+ name: #{release_name}
35
+ description: #{release_name}
36
+ type: application
37
+ version: 1.0.0
38
+ appVersion: "1.0.0"
39
+ CHART
40
+ end
41
+ end
@@ -10,7 +10,8 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
10
10
  :resource_name,
11
11
  :delete_if_exists,
12
12
  :restart_if_exists,
13
- :wait_for_rollout
13
+ :wait_for_rollout,
14
+ :apply_command
14
15
  ]
15
16
 
16
17
  Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
@@ -40,7 +41,12 @@ class KuberKit::ServiceDeployer::Strategies::Kubernetes < KuberKit::ServiceDeplo
40
41
  kubectl_commands.delete_resource(shell, resource_type, resource_name, kubeconfig_path: kubeconfig_path, namespace: namespace)
41
42
  end
42
43
 
43
- apply_result = kubectl_commands.apply_file(shell, config_path, kubeconfig_path: kubeconfig_path, namespace: namespace)
44
+ apply_result = kubectl_commands.apply_file(
45
+ shell, config_path,
46
+ kubeconfig_path: kubeconfig_path,
47
+ namespace: namespace,
48
+ apply_command: strategy_options.fetch(:apply_command, "apply")
49
+ )
44
50
 
45
51
  restart_enabled = strategy_options.fetch(:restart_if_exists, true)
46
52
  wait_for_rollout = strategy_options.fetch(:wait_for_rollout, true)
@@ -0,0 +1,42 @@
1
+ class KuberKit::Shell::Commands::HelmCommands
2
+ Contract KuberKit::Shell::AbstractShell, Or[String, ArrayOf[String]], KeywordArgs[
3
+ kubeconfig_path: Maybe[Or[
4
+ String, KuberKit::Core::ArtifactPath
5
+ ]],
6
+ namespace: Maybe[Or[Symbol, String]],
7
+ interactive: Optional[Bool],
8
+ ] => Any
9
+ def helm_run(shell, command_list, kubeconfig_path: nil, namespace: nil, interactive: false)
10
+ command_parts = []
11
+
12
+ if kubeconfig_path.is_a?(KuberKit::Core::ArtifactPath)
13
+ kubeconfig_path = artifact_path_resolver.call(kubeconfig_path)
14
+ end
15
+
16
+ if kubeconfig_path
17
+ command_parts << "KUBECONFIG=#{kubeconfig_path}"
18
+ end
19
+
20
+ command_parts << "helm"
21
+
22
+ if namespace
23
+ command_parts << "-n #{namespace}"
24
+ end
25
+
26
+ command_parts += Array(command_list).compact
27
+
28
+ if interactive
29
+ shell.interactive!(command_parts.join(" "))
30
+ else
31
+ shell.exec!(command_parts.join(" "))
32
+ end
33
+ end
34
+
35
+ def install(shell, release_name, chart_path, kubeconfig_path: nil, namespace: nil)
36
+ helm_run(shell, "install #{release_name} #{chart_path}", kubeconfig_path: kubeconfig_path, namespace: namespace)
37
+ end
38
+
39
+ def upgrade(shell, release_name, chart_path, kubeconfig_path: nil, namespace: nil)
40
+ helm_run(shell, "upgrade #{release_name} #{chart_path} --install", kubeconfig_path: kubeconfig_path, namespace: namespace)
41
+ end
42
+ end
@@ -39,8 +39,9 @@ class KuberKit::Shell::Commands::KubectlCommands
39
39
  end
40
40
  end
41
41
 
42
- def apply_file(shell, file_path, kubeconfig_path: nil, namespace: nil)
43
- kubectl_run(shell, "apply -f #{file_path}", kubeconfig_path: kubeconfig_path, namespace: namespace)
42
+ def apply_file(shell, file_path, kubeconfig_path: nil, namespace: nil, apply_command: nil)
43
+ apply_command ||= "apply"
44
+ kubectl_run(shell, "#{apply_command} -f #{file_path}", kubeconfig_path: kubeconfig_path, namespace: namespace)
44
45
  end
45
46
 
46
47
  def exec(shell, pod_name, command, args: nil, kubeconfig_path: nil, interactive: false, namespace: nil, entrypoint: nil)
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "1.2.7"
2
+ VERSION = "1.3.1"
3
3
  end
data/lib/kuber_kit.rb CHANGED
@@ -104,6 +104,7 @@ module KuberKit
104
104
  autoload :RsyncCommands, 'shell/commands/rsync_commands'
105
105
  autoload :KubectlCommands, 'shell/commands/kubectl_commands'
106
106
  autoload :SystemCommands, 'shell/commands/system_commands'
107
+ autoload :HelmCommands, 'shell/commands/helm_commands'
107
108
  end
108
109
  end
109
110
 
@@ -166,6 +167,7 @@ module KuberKit
166
167
  autoload :Docker, 'service_deployer/strategies/docker'
167
168
  autoload :DockerCompose, 'service_deployer/strategies/docker_compose'
168
169
  autoload :Kubernetes, 'service_deployer/strategies/kubernetes'
170
+ autoload :Helm, 'service_deployer/strategies/helm'
169
171
  end
170
172
  end
171
173
 
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: 1.2.7
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Khaziev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-17 00:00:00.000000000 Z
11
+ date: 2023-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts
@@ -343,6 +343,7 @@ files:
343
343
  - lib/kuber_kit/service_deployer/strategies/abstract.rb
344
344
  - lib/kuber_kit/service_deployer/strategies/docker.rb
345
345
  - lib/kuber_kit/service_deployer/strategies/docker_compose.rb
346
+ - lib/kuber_kit/service_deployer/strategies/helm.rb
346
347
  - lib/kuber_kit/service_deployer/strategies/kubernetes.rb
347
348
  - lib/kuber_kit/service_deployer/strategy_detector.rb
348
349
  - lib/kuber_kit/service_reader/action_handler.rb
@@ -353,6 +354,7 @@ files:
353
354
  - lib/kuber_kit/shell/commands/docker_commands.rb
354
355
  - lib/kuber_kit/shell/commands/docker_compose_commands.rb
355
356
  - lib/kuber_kit/shell/commands/git_commands.rb
357
+ - lib/kuber_kit/shell/commands/helm_commands.rb
356
358
  - lib/kuber_kit/shell/commands/kubectl_commands.rb
357
359
  - lib/kuber_kit/shell/commands/rsync_commands.rb
358
360
  - lib/kuber_kit/shell/commands/system_commands.rb
@@ -382,7 +384,7 @@ homepage: https://github.com/ArtStation/kuber_kit
382
384
  licenses:
383
385
  - MIT
384
386
  metadata: {}
385
- post_install_message:
387
+ post_install_message:
386
388
  rdoc_options: []
387
389
  require_paths:
388
390
  - lib
@@ -397,8 +399,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
397
399
  - !ruby/object:Gem::Version
398
400
  version: '0'
399
401
  requirements: []
400
- rubygems_version: 3.4.1
401
- signing_key:
402
+ rubygems_version: 3.4.10
403
+ signing_key:
402
404
  specification_version: 4
403
405
  summary: Docker Containers Build & Deployment
404
406
  test_files: []