k8s_kit 0.0.1 → 0.0.6

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: d6536da6860c0b0bcfa14bae28fbee59110c028b589bab71deb2437f1cd28d2d
4
- data.tar.gz: 4317a20be3364cfb36851c81105d9f59df3aa0ad718350e33ed12a1396e3e27a
3
+ metadata.gz: 199d7b5fa00b608549b485ba60121a8bfe8f6a3934f11abb7c8fa6354ccca95f
4
+ data.tar.gz: 02e5681d3e64df7b8092a85f0ad995b1c5e382bc61eb4828ced0bca90db19c1f
5
5
  SHA512:
6
- metadata.gz: 8ecfb4eba9a6ee5832aea993271160d052fd404c9eef4bef58ebb455eb661a1c627fe021dfed1921d5dc39eb33a20091894b6a8db5142ed673a865567c2924bf
7
- data.tar.gz: b9e70468631580c5000831ee0d382580ef9d59a403b3fc78b2eea616bd2096f552b1289b6a127967a9a0ba5c28e5ceb3a9aba95dc70b7f8b0406b01250bbadfc
6
+ metadata.gz: 9609c38d8b3f6f11bf7b72d6c4638e8d80e923dad3bfa6a8956aa75cc7d7a45d7ad77714eb7e91e7a639d0294fe23ef5f6e2b1c5e44ef2b047c7cf1984f7a64c
7
+ data.tar.gz: a16c175304176e2f20d405c10d0bf288a5583f1795faeca81bf4db2ce1dcd8a4cef0fe6e3206b1ca39675f22b2662daa26c5601f1eea3eb9151d2c5fab91e732
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ .byebug_history
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- k8s_kit (0.0.1)
4
+ k8s_kit (0.0.6)
5
5
  gli (= 2.18.1)
6
6
 
7
7
  GEM
@@ -16,6 +16,7 @@ GEM
16
16
  thor (~> 0.19)
17
17
  backports (3.15.0)
18
18
  builder (3.2.3)
19
+ byebug (11.0.1)
19
20
  childprocess (2.0.0)
20
21
  rake (< 13.0)
21
22
  contracts (0.16.0)
@@ -48,15 +49,18 @@ GEM
48
49
  rspec-support (~> 3.8.0)
49
50
  rspec-support (3.8.2)
50
51
  thor (0.20.3)
52
+ waitutil (0.2.1)
51
53
 
52
54
  PLATFORMS
53
55
  ruby
54
56
 
55
57
  DEPENDENCIES
56
58
  aruba
59
+ byebug
57
60
  k8s_kit!
58
61
  rake
59
62
  rdoc
63
+ waitutil
60
64
 
61
65
  BUNDLED WITH
62
66
  2.0.2
@@ -1,13 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'gli'
3
- begin # XXX: Remove this begin/rescue before distributing your app
4
3
  require 'k8s_kit'
5
- rescue LoadError
6
- STDERR.puts "In development, you need to use `bundle exec bin/k8s_kit` to run your app"
7
- STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
8
- STDERR.puts "Feel free to remove this message from bin/k8s_kit now"
9
- exit 64
10
- end
11
4
 
12
5
  class App
13
6
  extend GLI::App
@@ -66,7 +59,12 @@ class App
66
59
  on_error do |exception|
67
60
  # Error logic here
68
61
  # return false to skip default error handling
69
- true
62
+ case exception
63
+ when SystemExit
64
+ exit exception.status
65
+ else
66
+ true
67
+ end
70
68
  end
71
69
  end
72
70
 
@@ -14,8 +14,10 @@ spec = Gem::Specification.new do |s|
14
14
  s.rdoc_options << '--title' << 'k8s_kit' << '--main' << 'README.rdoc' << '-ri'
15
15
  s.bindir = 'bin'
16
16
  s.executables << 'k8s_kit'
17
+ s.add_development_dependency('byebug')
17
18
  s.add_development_dependency('rake')
18
19
  s.add_development_dependency('rdoc')
19
20
  s.add_development_dependency('aruba')
20
21
  s.add_runtime_dependency('gli','2.18.1')
22
+ s.add_runtime_dependency('waitutil')
21
23
  end
@@ -43,14 +43,23 @@ module K8sKit
43
43
  def wait_for_all_pods_ready(timeout: 300)
44
44
  t0 = Time.now
45
45
 
46
+ print 'Waiting for all pods to be ready...'
46
47
  loop do
47
48
  statuses = run('get pods -o jsonpath="{.items.*.status.containerStatuses[*].ready}"')
49
+ if statuses.empty?
50
+ puts ''
51
+ raise StandardError, 'No pod could be found in the namespace'
52
+ end
53
+
48
54
  return unless statuses.include?('false')
49
55
 
50
- raise StandardError, 'Timeout while waiting for pods to become ready' if t0 + timeout < Time.now
56
+ if t0 + timeout < Time.now
57
+ puts ''
58
+ raise StandardError, 'Timeout while waiting for pods to become ready'
59
+ end
51
60
 
52
- puts 'Some pods are not ready yet, retrying...'
53
- sleep 5
61
+ print '.'
62
+ sleep 2
54
63
  end
55
64
  end
56
65
  end
@@ -1,3 +1,5 @@
1
+ require 'waitutil'
2
+
1
3
  module K8sKit
2
4
  class Job
3
5
  attr_reader :context, :name
@@ -10,6 +12,13 @@ module K8sKit
10
12
  def attach(container:, delete_on_completion: true, exit_on_completion: true)
11
13
  pod.wait_until_ready
12
14
  pod.logs(container: container, stream: true)
15
+
16
+ WaitUtil.wait_for_condition("pod has exit code",
17
+ :timeout_sec => 30,
18
+ :delay_sec => 0.5) do
19
+ pod.exit_code(container: container) != nil
20
+ end
21
+
13
22
  exit_code = pod.exit_code(container: container)
14
23
 
15
24
  delete if delete_on_completion
@@ -21,7 +21,7 @@ module K8sKit
21
21
 
22
22
  def exit_code(container:)
23
23
  json_path = "{ .status.containerStatuses[?(@.name == '#{container}')].state.terminated.exitCode }"
24
- context.run("get pod #{name} -o jsonpath=\"#{json_path}\"").to_i
24
+ Integer(context.run("get pod #{name} -o jsonpath=\"#{json_path}\""))
25
25
  rescue StandardError
26
26
  nil
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module K8sKit
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k8s_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Your Name Here
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-07 00:00:00.000000000 Z
11
+ date: 2020-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - '='
67
81
  - !ruby/object:Gem::Version
68
82
  version: 2.18.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: waitutil
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description:
70
98
  email: your@email.address.com
71
99
  executables:
@@ -73,6 +101,7 @@ executables:
73
101
  extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
104
+ - ".gitignore"
76
105
  - Gemfile
77
106
  - Gemfile.lock
78
107
  - bin/k8s_kit
@@ -106,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
135
  - !ruby/object:Gem::Version
107
136
  version: '0'
108
137
  requirements: []
109
- rubygems_version: 3.0.3
138
+ rubygems_version: 3.1.2
110
139
  signing_key:
111
140
  specification_version: 4
112
141
  summary: A description of your project