kubert 0.0.1.pre.dev5 → 0.0.1.pre.dev6
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 +4 -4
- data/kubert.gemspec +1 -1
- data/lib/kubert/cli.rb +15 -3
- data/lib/kubert/deployment.rb +45 -6
- data/lib/kubert/version.rb +1 -1
- data/lib/kubert.rb +13 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df48773e44f09c65f555a75fe4303e33ad1c597c
|
4
|
+
data.tar.gz: ba0e595e8f60e62f6b6f0340d7c9629430157108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e861857520e53524f27dfd461e5d058e4ba4e7f011bc9945f1f3ef9a995f8e3493e2713a5a692480b6d4afdc4db6fb57b855cf20cfb6ec61fd5bf7cd527a26
|
7
|
+
data.tar.gz: 969626a019d04a92f3a70f168f07ba8328cd565da3489afbdc7fea797ac5212a06d8b8e1c3e7b68e0ce7fc430d1b8147f1f9c9ac58e940623a6103f5776d92a1
|
data/kubert.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.require_paths = ["lib"]
|
31
31
|
spec.add_runtime_dependency 'thor', '~> 0.19'
|
32
32
|
spec.add_runtime_dependency 'kubeclient', '~> 2'
|
33
|
-
spec.add_runtime_dependency 'ky', '~> 0.5'
|
33
|
+
spec.add_runtime_dependency 'ky', '~> 0.5.2.pre1'
|
34
34
|
spec.add_development_dependency 'pry', '~> 0.10'
|
35
35
|
spec.add_development_dependency "bundler", "~> 1.13"
|
36
36
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/kubert/cli.rb
CHANGED
@@ -11,7 +11,7 @@ module Kubert
|
|
11
11
|
|
12
12
|
desc "context", "Print current kubectl current context"
|
13
13
|
def context
|
14
|
-
puts Kubert.
|
14
|
+
puts Kubert.context
|
15
15
|
end
|
16
16
|
|
17
17
|
desc "sandbox", "Connect to a Rails console in sandbox that will wrap session in DB transaction and rollback when done"
|
@@ -30,13 +30,25 @@ module Kubert
|
|
30
30
|
end
|
31
31
|
|
32
32
|
desc "deploy", "Perform a deployment"
|
33
|
+
method_option :namespace, type: :string, aliases: "-n"
|
34
|
+
method_option :environment, type: :string, aliases: "-e"
|
35
|
+
method_option :image_tag, type: :string, aliases: "-t"
|
36
|
+
method_option :configmap_path, type: :string, aliases: "-c"
|
37
|
+
method_option :secrets_path, type: :string, aliases: "-s"
|
38
|
+
method_option :output_dir, type: :string, aliases: "-o"
|
33
39
|
def deploy
|
34
|
-
Deployment.perform
|
40
|
+
Deployment.perform(options)
|
35
41
|
end
|
36
42
|
|
37
43
|
desc "rollback", "Connect to a pod run the specified command (with bundle exec prefix)"
|
44
|
+
method_option :namespace, type: :string, aliases: "-n"
|
45
|
+
method_option :environment, type: :string, aliases: "-e"
|
46
|
+
method_option :image_tag, type: :string, aliases: "-t"
|
47
|
+
method_option :configmap_path, type: :string, aliases: "-c"
|
48
|
+
method_option :secrets_path, type: :string, aliases: "-s"
|
49
|
+
method_option :output_dir, type: :string, aliases: "-o"
|
38
50
|
def rollback
|
39
|
-
Deployment.rollback
|
51
|
+
Deployment.rollback(options)
|
40
52
|
end
|
41
53
|
|
42
54
|
Kubert.contexts.each do |context_name, context_endpoint|
|
data/lib/kubert/deployment.rb
CHANGED
@@ -1,23 +1,62 @@
|
|
1
1
|
module Kubert
|
2
2
|
class Deployment
|
3
|
-
def self.perform
|
4
|
-
new.perform
|
3
|
+
def self.perform(options)
|
4
|
+
new(options).perform
|
5
5
|
end
|
6
6
|
|
7
|
-
def self.rollback
|
8
|
-
new.rollback
|
7
|
+
def self.rollback(options)
|
8
|
+
new(options).rollback
|
9
9
|
end
|
10
10
|
|
11
|
-
attr_reader :project_name, :deployments
|
12
|
-
def initialize(project_name= Kubert.configuration[:project_name])
|
11
|
+
attr_reader :project_name, :deployments, :options
|
12
|
+
def initialize(options, project_name= Kubert.configuration[:project_name])
|
13
13
|
@project_name = project_name
|
14
14
|
@deployments = []
|
15
|
+
@options = options
|
15
16
|
end
|
16
17
|
|
17
18
|
def rollback
|
19
|
+
confirm "rollback" do
|
20
|
+
compilation.deploy_generation.proc_commands.keys.each do |deployment_name|
|
21
|
+
`kubectl rollout status deployment/#{deployment_name} #{namespace_flag}` unless excluded?(deployment_name)
|
22
|
+
end
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
def perform
|
27
|
+
confirm "deploy" do
|
28
|
+
compilation.deploy_generation.to_h.each do |deployment_file, _template_hash|
|
29
|
+
`kubectl apply -f #{deployment_file}` unless excluded?(deployment_file)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def compilation
|
35
|
+
@compilation ||= KY::API.compile(options[:configmap_path], options[:secrets_path], options[:output_dir], options_with_defaults)
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def confirm(action)
|
41
|
+
unless ENV['SKIP_CONFIRMATION']
|
42
|
+
puts "Press any key to confirm, ctl-c to abort: #{action.upcase} on #{Kubert.context}"
|
43
|
+
confirmation = $stdin.gets
|
44
|
+
end
|
45
|
+
yield
|
46
|
+
end
|
47
|
+
|
48
|
+
def options_with_defaults
|
49
|
+
(options[:environment] ? options : options.merge(environment: Kubert.default_environment)).with_indifferent_access
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
def namespace_flag
|
54
|
+
return unless compilation.configuration[:environment]
|
55
|
+
"-n #{compilation.configuration[:environment]} "
|
56
|
+
end
|
57
|
+
|
58
|
+
def excluded?(deployment_info)
|
59
|
+
Kubert.excluded_deployments.any? {|deploy| deployment_info.match(deploy) }
|
21
60
|
end
|
22
61
|
end
|
23
62
|
end
|
data/lib/kubert/version.rb
CHANGED
data/lib/kubert.rb
CHANGED
@@ -2,6 +2,7 @@ require 'kubeclient'
|
|
2
2
|
require 'ky'
|
3
3
|
require 'open3'
|
4
4
|
require_relative "kubert/pods"
|
5
|
+
require_relative "kubert/deployment"
|
5
6
|
|
6
7
|
module Kubert
|
7
8
|
def self.kube_config
|
@@ -12,6 +13,18 @@ module Kubert
|
|
12
13
|
configuration[:contexts] || []
|
13
14
|
end
|
14
15
|
|
16
|
+
def self.default_environment
|
17
|
+
configuration[:default_environment]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.context
|
21
|
+
kube_config.contexts.select {|c| kube_config.context.api_endpoint.match(c) }
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.excluded_deployments
|
25
|
+
configuration[:excluded_deployments] || []
|
26
|
+
end
|
27
|
+
|
15
28
|
def self.configuration
|
16
29
|
@config ||= begin
|
17
30
|
config = KY::Configuration.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubert
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.pre.
|
4
|
+
version: 0.0.1.pre.dev6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Glusman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.5.2.pre1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.5.2.pre1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|