kuber_kit 0.2.9 → 0.3.0

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: 050f5ef4e2ef34f21bd8d5d92593717770a82c54c40d929cdce949a9f2735171
4
- data.tar.gz: 250684c19fc240e0f243ad3c5688cd170912b26c49559569d12717a0bd1655fb
3
+ metadata.gz: 00f2e6ace047f0c5f5e5c4b8595cc0354d89846d2c752e6bd849bb44b1e60fb9
4
+ data.tar.gz: c2e9494de5dce8db6221300fc6a3e95e67d979e714edee1b5d72670b38c64c42
5
5
  SHA512:
6
- metadata.gz: 3b80414736ee18eb858e383dde9219468b20953d98bbc61439974683b0a0287758e6a039719783ee6c132b94fa999c1e3f4eb9c6c020939313d29d100dc365c3
7
- data.tar.gz: e7a7b01fea7a033bf14755dd597ca85079d51e235855c722c5ca8ddba1b25838d70469c2ae4089aca77b48394e5aca52dbcfdb9ef0706892a61437a3eaf8e7a9
6
+ metadata.gz: 2503111ae618310fe827d5622f988cd98ae06f4626e39fd1fcbeb8d1b2da8ace07ba3a358a05c048c62a0c463556e4e58c5ba32241a5e2a0ddcdb316b42bc349
7
+ data.tar.gz: 0e5eb0798fce0f39a4b777f80e5aeda939a5185e8da1fbd254b6d1e176f27708bd10787757a2c294c1469826c0bec6d20cbc36f73e5912b0a0d0e589d35900b6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kuber_kit (0.2.9)
4
+ kuber_kit (0.3.0)
5
5
  cli-ui
6
6
  contracts-lite
7
7
  dry-auto_inject
@@ -35,23 +35,25 @@ GEM
35
35
  coderay (~> 1.1)
36
36
  method_source (~> 1.0)
37
37
  rake (10.5.0)
38
- rspec (3.9.0)
39
- rspec-core (~> 3.9.0)
40
- rspec-expectations (~> 3.9.0)
41
- rspec-mocks (~> 3.9.0)
42
- rspec-core (3.9.3)
43
- rspec-support (~> 3.9.3)
44
- rspec-expectations (3.9.3)
38
+ rspec (3.10.0)
39
+ rspec-core (~> 3.10.0)
40
+ rspec-expectations (~> 3.10.0)
41
+ rspec-mocks (~> 3.10.0)
42
+ rspec-core (3.10.0)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-expectations (3.10.0)
45
45
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.9.0)
47
- rspec-mocks (3.9.1)
46
+ rspec-support (~> 3.10.0)
47
+ rspec-mocks (3.10.0)
48
48
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.9.0)
50
- rspec-support (3.9.4)
51
- simplecov (0.19.0)
49
+ rspec-support (~> 3.10.0)
50
+ rspec-support (3.10.0)
51
+ simplecov (0.20.0)
52
52
  docile (~> 1.1)
53
53
  simplecov-html (~> 0.11)
54
+ simplecov_json_formatter (~> 0.1)
54
55
  simplecov-html (0.12.3)
56
+ simplecov_json_formatter (0.1.2)
55
57
  thor (1.0.1)
56
58
 
57
59
  PLATFORMS
data/TODO.md CHANGED
@@ -3,7 +3,6 @@
3
3
  - add kit logs support, should work similar to kit attach
4
4
  - allow deploying only services enabled for specific configuration
5
5
  - find a way to always deploy some service, e.g. for migrations and env_files
6
- - allow setting default configuration for kuberkit using env variable
7
6
  - add ability to set container health checks
8
7
  - implement interactive shell.exec!
9
8
  - template should be able to set default attributes
@@ -88,6 +88,7 @@ module KuberKit
88
88
  module Commands
89
89
  autoload :BashCommands, 'shell/commands/bash_commands'
90
90
  autoload :DockerCommands, 'shell/commands/docker_commands'
91
+ autoload :DockerComposeCommands, 'shell/commands/docker_compose_commands'
91
92
  autoload :GitCommands, 'shell/commands/git_commands'
92
93
  autoload :RsyncCommands, 'shell/commands/rsync_commands'
93
94
  autoload :KubectlCommands, 'shell/commands/kubectl_commands'
@@ -145,6 +146,7 @@ module KuberKit
145
146
 
146
147
  module Strategies
147
148
  autoload :Abstract, 'service_deployer/strategies/abstract'
149
+ autoload :DockerCompose, 'service_deployer/strategies/docker_compose'
148
150
  autoload :Kubernetes, 'service_deployer/strategies/kubernetes'
149
151
  autoload :KubernetesRunner, 'service_deployer/strategies/kubernetes_runner'
150
152
  end
@@ -27,7 +27,7 @@ class KuberKit::Actions::ConfigurationLoader
27
27
  services_path = options[:services_path] || File.join(root_path, configs.services_dirname)
28
28
  infra_path = options[:infra_path] || File.join(root_path, configs.infra_dirname)
29
29
  configurations_path = options[:configurations_path] || File.join(root_path, configs.configurations_dirname)
30
- configuration_name = options[:configuration]
30
+ configuration_name = ENV["KUBER_KIT_CONFIGURATION"] || options[:configuration]
31
31
 
32
32
  logger.info "Launching kuber_kit with:"
33
33
  logger.info " Root path: #{root_path.to_s.yellow}"
@@ -117,6 +117,10 @@ class KuberKit::Container
117
117
  KuberKit::Shell::Commands::DockerCommands.new
118
118
  end
119
119
 
120
+ register "shell.docker_compose_commands" do
121
+ KuberKit::Shell::Commands::DockerComposeCommands.new
122
+ end
123
+
120
124
  register "shell.git_commands" do
121
125
  KuberKit::Shell::Commands::GitCommands.new
122
126
  end
@@ -233,6 +237,10 @@ class KuberKit::Container
233
237
  KuberKit::ServiceDeployer::Strategies::KubernetesRunner.new
234
238
  end
235
239
 
240
+ register "service_deployer.strategies.docker_compose" do
241
+ KuberKit::ServiceDeployer::Strategies::DockerCompose.new
242
+ end
243
+
236
244
  register "service_reader.action_handler" do
237
245
  KuberKit::ServiceReader::ActionHandler.new
238
246
  end
@@ -94,10 +94,23 @@ class KuberKit::Core::ConfigurationDefinition
94
94
  self
95
95
  end
96
96
 
97
- def enabled_services(services_hash)
98
- @enabled_services += services_hash.keys.map(&:to_sym)
99
- @services_attributes = @services_attributes.merge(services_hash)
97
+ def enabled_services(services)
98
+ if services.is_a?(Hash)
99
+ @enabled_services += services.keys.map(&:to_sym)
100
+ @services_attributes = @services_attributes.merge(services)
101
+ return self
102
+ end
103
+
104
+ if services.is_a?(Array)
105
+ @enabled_services += services.map(&:to_sym)
106
+ return self
107
+ end
108
+
109
+ raise KuberKit::Error, "#enabled_services method accepts only Array or Hash"
110
+ end
100
111
 
112
+ def service_attributes(services)
113
+ @services_attributes = @services_attributes.merge(services)
101
114
  self
102
115
  end
103
116
 
@@ -4,7 +4,8 @@ class KuberKit::ServiceDeployer::Deployer
4
4
  include KuberKit::Import[
5
5
  "core.service_store",
6
6
  "service_deployer.strategies.kubernetes",
7
- "service_deployer.strategies.kubernetes_runner"
7
+ "service_deployer.strategies.kubernetes_runner",
8
+ "service_deployer.strategies.docker_compose"
8
9
  ]
9
10
 
10
11
  def initialize(**injected_deps)
@@ -39,5 +40,6 @@ class KuberKit::ServiceDeployer::Deployer
39
40
  def add_default_strategies
40
41
  register_strategy(:kubernetes, kubernetes)
41
42
  register_strategy(:kubernetes_runner, kubernetes_runner)
43
+ register_strategy(:docker_compose, docker_compose)
42
44
  end
43
45
  end
@@ -0,0 +1,19 @@
1
+ class KuberKit::ServiceDeployer::Strategies::DockerCompose < KuberKit::ServiceDeployer::Strategies::Abstract
2
+ include KuberKit::Import[
3
+ "service_reader.reader",
4
+ "shell.docker_compose_commands",
5
+ "configs",
6
+ ]
7
+
8
+ Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Service => Any
9
+ def deploy(shell, service)
10
+ service_config = reader.read(shell, service)
11
+ config_path = "#{configs.service_config_dir}/#{service.name}.yml"
12
+ shell.write(config_path, service_config)
13
+
14
+ deployment_service_name = service.attribute(:deployment_service_name, default: service.name.to_s)
15
+ deployment_command_name = service.attribute(:deployment_command_name, default: "bash")
16
+
17
+ docker_compose_commands.run(shell, config_path, service: deployment_service_name, command: deployment_command_name)
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ class KuberKit::Shell::Commands::DockerComposeCommands
2
+ def run(shell, path, service:, command:)
3
+ shell.exec!(%Q{docker-compose -f #{path} run #{service} #{command}})
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module KuberKit
2
- VERSION = "0.2.9"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.9
4
+ version: 0.3.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: 2020-12-08 00:00:00.000000000 Z
11
+ date: 2020-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts-lite
@@ -258,6 +258,7 @@ files:
258
258
  - lib/kuber_kit/service_deployer/deployer.rb
259
259
  - lib/kuber_kit/service_deployer/service_list_resolver.rb
260
260
  - lib/kuber_kit/service_deployer/strategies/abstract.rb
261
+ - lib/kuber_kit/service_deployer/strategies/docker_compose.rb
261
262
  - lib/kuber_kit/service_deployer/strategies/kubernetes.rb
262
263
  - lib/kuber_kit/service_deployer/strategies/kubernetes_runner.rb
263
264
  - lib/kuber_kit/service_deployer/strategy_detector.rb
@@ -267,6 +268,7 @@ files:
267
268
  - lib/kuber_kit/shell/command_counter.rb
268
269
  - lib/kuber_kit/shell/commands/bash_commands.rb
269
270
  - lib/kuber_kit/shell/commands/docker_commands.rb
271
+ - lib/kuber_kit/shell/commands/docker_compose_commands.rb
270
272
  - lib/kuber_kit/shell/commands/git_commands.rb
271
273
  - lib/kuber_kit/shell/commands/kubectl_commands.rb
272
274
  - lib/kuber_kit/shell/commands/rsync_commands.rb