kubeclient 4.9.3 → 4.10.0
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/.github/workflows/actions.yml +3 -2
- data/CHANGELOG.md +19 -1
- data/README.md +1 -2
- data/kubeclient.gemspec +3 -1
- data/lib/kubeclient/common.rb +29 -17
- data/lib/kubeclient/version.rb +1 -1
- data/lib/kubeclient/watch_stream.rb +1 -0
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68296079e6db48ae555a4ca1f53c39b4c6349f3aebb426f443f884c984b904a1
|
4
|
+
data.tar.gz: 1524dfc158d01ac299c732f54dcf5e757cbd112eb07f3358ba798c3c8b09977d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aa6e0f5d6934ef4de10a71a1388f53323ab235ca4b3c1a560b99a483fba3603c51cf463a5211554ab2d97d1dfce6a5623ce65898c0f188c231476b320180bc3
|
7
|
+
data.tar.gz: a6319a5a38d228db8b0ed08eb356d7539858cb0660ec2dba376177a3c02568b19ea42d5799feef04b5d86dc4284673c978d6cdaf82b286f3642ae33a0449eba0
|
@@ -16,7 +16,9 @@ jobs:
|
|
16
16
|
matrix:
|
17
17
|
ruby: [ '2.5', '2.6', '2.7', '3.0', '3.1', 'ruby-head', 'truffleruby-head' ]
|
18
18
|
os_and_command:
|
19
|
-
- os:
|
19
|
+
- os: macos-latest
|
20
|
+
command: 'env TESTOPTS="--verbose" bundle exec rake test'
|
21
|
+
- os: windows-latest
|
20
22
|
command: 'env TESTOPTS="--verbose" bundle exec rake test'
|
21
23
|
- os: ubuntu-latest
|
22
24
|
# Sometimes minitest starts and then just hangs printing nothing.
|
@@ -35,7 +37,6 @@ jobs:
|
|
35
37
|
with:
|
36
38
|
ruby-version: ${{ matrix.ruby }}
|
37
39
|
bundler-cache: false # disable running 'bundle install' and caching installed gems see https://github.com/httprb/http/issues/572
|
38
|
-
- run: gem install rake bundler
|
39
40
|
- run: bundle install
|
40
41
|
- run: ${{ matrix.os_and_command.command }}
|
41
42
|
timeout-minutes: 10
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,21 @@ Notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
|
5
5
|
Kubeclient release versioning follows [SemVer](https://semver.org/).
|
6
6
|
|
7
|
-
## 4.
|
7
|
+
## 4.10.0 — 2022-08-29
|
8
|
+
|
9
|
+
### Added
|
10
|
+
|
11
|
+
- When using `:bearer_token_file`, re-read the file on every request. (#566 closed #561)
|
12
|
+
|
13
|
+
Kubernetes version 1.21 graduated [BoundServiceAccountTokenVolume feature][] to beta
|
14
|
+
and enabled it by default, so standard in-cluster auth now uses short-lived tokens.
|
15
|
+
|
16
|
+
This changes allows a long-lived `Client` object to keep working when the token file gets
|
17
|
+
rotated. It's not optimized at all, if you feel the performance overhead, please report!
|
18
|
+
|
19
|
+
[BoundServiceAccountTokenVolume feature]: https://github.com/kubernetes/enhancements/issues/542
|
20
|
+
|
21
|
+
## 4.9.3 — 2022-03-23
|
8
22
|
|
9
23
|
### Fixed
|
10
24
|
|
@@ -23,12 +37,16 @@ Kubeclient release versioning follows [SemVer](https://semver.org/).
|
|
23
37
|
This was broken IN ALL RELEASES MADE BEFORE 2022, ever since
|
24
38
|
[`Kubeclient::Config` was created](https://github.com/ManageIQ/kubeclient/pull/127/files#diff-32e70f2f6781a9e9c7b83ae5e7eaf5ffd068a05649077fa38f6789e72f3de837R41-R48).
|
25
39
|
|
40
|
+
[#554](https://github.com/ManageIQ/kubeclient/issues/554).
|
41
|
+
|
26
42
|
- Bug fix: kubeconfig `insecure-skip-tls-verify` field was ignored.
|
27
43
|
When kubeconfig did define custom CA, `Config` was returning hard-coded `VERIFY_PEER`.
|
28
44
|
|
29
45
|
Now we honor it, return `VERIFY_NONE` iff kubeconfig has explicit
|
30
46
|
`insecure-skip-tls-verify: true`, otherwise `VERIFY_PEER`.
|
31
47
|
|
48
|
+
[#555](https://github.com/ManageIQ/kubeclient/issues/555).
|
49
|
+
|
32
50
|
- `Config`: fixed parsing of `certificate-authority` file containing concatenation of
|
33
51
|
several certificates. Previously, server's cert was checked against only first CA cert,
|
34
52
|
resulting in possible "certificate verify failed" errors.
|
data/README.md
CHANGED
@@ -13,8 +13,7 @@ To learn more about groups and versions in kubernetes refer to [k8s docs](https:
|
|
13
13
|
|
14
14
|
If you use `Kubeclient::Config`, all gem versions released before 2022 could return incorrect `ssl_options[:verify_ssl]`,
|
15
15
|
endangering your connection and cluster credentials.
|
16
|
-
See
|
17
|
-
Open an issue if you want a backport to another version.
|
16
|
+
See https://github.com/ManageIQ/kubeclient/issues/554 for details and which versions got a fix.
|
18
17
|
|
19
18
|
## Installation
|
20
19
|
|
data/kubeclient.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '>= 1.6'
|
25
25
|
spec.add_development_dependency 'rake', '~> 12.0'
|
26
|
-
spec.add_development_dependency 'minitest'
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.15.0'
|
27
27
|
spec.add_development_dependency 'minitest-rg'
|
28
28
|
spec.add_development_dependency 'webmock', '~> 3.0'
|
29
29
|
spec.add_development_dependency 'vcr'
|
@@ -32,6 +32,8 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency('mocha', '~> 1.5')
|
33
33
|
spec.add_development_dependency 'openid_connect', '~> 1.1'
|
34
34
|
spec.add_development_dependency 'net-smtp'
|
35
|
+
# needed on Windows, at least for openid_connect
|
36
|
+
spec.add_development_dependency 'tzinfo-data'
|
35
37
|
|
36
38
|
spec.add_dependency 'jsonpath', '~> 1.0'
|
37
39
|
spec.add_dependency 'rest-client', '~> 2.0'
|
data/lib/kubeclient/common.rb
CHANGED
@@ -78,7 +78,7 @@ module Kubeclient
|
|
78
78
|
@api_version = version
|
79
79
|
@headers = {}
|
80
80
|
@ssl_options = ssl_options
|
81
|
-
@auth_options = auth_options
|
81
|
+
@auth_options = auth_options.dup
|
82
82
|
@socket_options = socket_options
|
83
83
|
# Allow passing partial timeouts hash, without unspecified
|
84
84
|
# @timeouts[:foo] == nil resulting in infinite timeout.
|
@@ -87,11 +87,18 @@ module Kubeclient
|
|
87
87
|
@http_max_redirects = http_max_redirects
|
88
88
|
@as = as
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
90
|
+
@log = Logger.new(STDOUT)
|
91
|
+
@log.formatter = proc do |severity, datetime, progname, msg|
|
92
|
+
"#{datetime} [#{severity}]: #{msg}\n"
|
93
|
+
end
|
94
|
+
|
95
|
+
if auth_options[:bearer_token_file]
|
93
96
|
validate_bearer_token_file
|
97
|
+
@log.info("Reading bearer token from #{@auth_options[:bearer_token_file]}")
|
94
98
|
bearer_token(File.read(@auth_options[:bearer_token_file]))
|
99
|
+
elsif auth_options[:bearer_token]
|
100
|
+
bearer_token(@auth_options[:bearer_token])
|
101
|
+
@log.info("bearer_token_file path not provided. Kubeclient will not be able to refresh the token if it expires")
|
95
102
|
end
|
96
103
|
end
|
97
104
|
|
@@ -136,6 +143,11 @@ module Kubeclient
|
|
136
143
|
@discovered = true
|
137
144
|
end
|
138
145
|
|
146
|
+
def get_headers
|
147
|
+
bearer_token(File.read(@auth_options[:bearer_token_file])) if @auth_options[:bearer_token_file]
|
148
|
+
@headers
|
149
|
+
end
|
150
|
+
|
139
151
|
def self.parse_definition(kind, name)
|
140
152
|
# Kubernetes gives us 3 inputs:
|
141
153
|
# kind: "ComponentStatus", "NetworkPolicy", "Endpoints"
|
@@ -349,7 +361,7 @@ module Kubeclient
|
|
349
361
|
ns_prefix = build_namespace_prefix(options[:namespace])
|
350
362
|
response = handle_exception do
|
351
363
|
rest_client[ns_prefix + resource_name]
|
352
|
-
.get({ 'params' => params }.merge(
|
364
|
+
.get({ 'params' => params }.merge(get_headers))
|
353
365
|
end
|
354
366
|
format_response(options[:as] || @as, response.body, entity_type)
|
355
367
|
end
|
@@ -362,7 +374,7 @@ module Kubeclient
|
|
362
374
|
ns_prefix = build_namespace_prefix(namespace)
|
363
375
|
response = handle_exception do
|
364
376
|
rest_client[ns_prefix + resource_name + "/#{name}"]
|
365
|
-
.get(
|
377
|
+
.get(get_headers)
|
366
378
|
end
|
367
379
|
format_response(options[:as] || @as, response.body)
|
368
380
|
end
|
@@ -378,7 +390,7 @@ module Kubeclient
|
|
378
390
|
rs.options.merge(
|
379
391
|
method: :delete,
|
380
392
|
url: rs.url,
|
381
|
-
headers: { 'Content-Type' => 'application/json' }.merge(
|
393
|
+
headers: { 'Content-Type' => 'application/json' }.merge(get_headers),
|
382
394
|
payload: payload
|
383
395
|
)
|
384
396
|
)
|
@@ -400,7 +412,7 @@ module Kubeclient
|
|
400
412
|
hash[:apiVersion] = @api_group + @api_version
|
401
413
|
response = handle_exception do
|
402
414
|
rest_client[ns_prefix + resource_name]
|
403
|
-
.post(hash.to_json, { 'Content-Type' => 'application/json' }.merge(
|
415
|
+
.post(hash.to_json, { 'Content-Type' => 'application/json' }.merge(get_headers))
|
404
416
|
end
|
405
417
|
format_response(@as, response.body)
|
406
418
|
end
|
@@ -410,7 +422,7 @@ module Kubeclient
|
|
410
422
|
ns_prefix = build_namespace_prefix(entity_config[:metadata][:namespace])
|
411
423
|
response = handle_exception do
|
412
424
|
rest_client[ns_prefix + resource_name + "/#{name}"]
|
413
|
-
.put(entity_config.to_h.to_json, { 'Content-Type' => 'application/json' }.merge(
|
425
|
+
.put(entity_config.to_h.to_json, { 'Content-Type' => 'application/json' }.merge(get_headers))
|
414
426
|
end
|
415
427
|
format_response(@as, response.body)
|
416
428
|
end
|
@@ -421,7 +433,7 @@ module Kubeclient
|
|
421
433
|
rest_client[ns_prefix + resource_name + "/#{name}"]
|
422
434
|
.patch(
|
423
435
|
patch.to_json,
|
424
|
-
{ 'Content-Type' => "application/#{strategy}+json" }.merge(
|
436
|
+
{ 'Content-Type' => "application/#{strategy}+json" }.merge(get_headers)
|
425
437
|
)
|
426
438
|
end
|
427
439
|
format_response(@as, response.body)
|
@@ -434,7 +446,7 @@ module Kubeclient
|
|
434
446
|
rest_client[ns_prefix + resource_name + "/#{name}"]
|
435
447
|
.patch(
|
436
448
|
resource.to_json,
|
437
|
-
{ 'Content-Type' => 'application/apply-patch+yaml' }.merge(
|
449
|
+
{ 'Content-Type' => 'application/apply-patch+yaml' }.merge(get_headers)
|
438
450
|
)
|
439
451
|
end
|
440
452
|
format_response(@as, response.body)
|
@@ -468,7 +480,7 @@ module Kubeclient
|
|
468
480
|
ns = build_namespace_prefix(namespace)
|
469
481
|
handle_exception do
|
470
482
|
rest_client[ns + "pods/#{pod_name}/log"]
|
471
|
-
.get({ 'params' => params }.merge(
|
483
|
+
.get({ 'params' => params }.merge(get_headers))
|
472
484
|
end
|
473
485
|
end
|
474
486
|
|
@@ -506,7 +518,7 @@ module Kubeclient
|
|
506
518
|
ns_prefix = build_namespace_prefix(template[:metadata][:namespace])
|
507
519
|
response = handle_exception do
|
508
520
|
rest_client[ns_prefix + 'processedtemplates']
|
509
|
-
.post(template.to_h.to_json, { 'Content-Type' => 'application/json' }.merge(
|
521
|
+
.post(template.to_h.to_json, { 'Content-Type' => 'application/json' }.merge(get_headers))
|
510
522
|
end
|
511
523
|
JSON.parse(response)
|
512
524
|
end
|
@@ -519,7 +531,7 @@ module Kubeclient
|
|
519
531
|
end
|
520
532
|
|
521
533
|
def api
|
522
|
-
response = handle_exception { create_rest_client.get(
|
534
|
+
response = handle_exception { create_rest_client.get(get_headers) }
|
523
535
|
JSON.parse(response)
|
524
536
|
end
|
525
537
|
|
@@ -593,7 +605,7 @@ module Kubeclient
|
|
593
605
|
end
|
594
606
|
|
595
607
|
def fetch_entities
|
596
|
-
JSON.parse(handle_exception { rest_client.get(
|
608
|
+
JSON.parse(handle_exception { rest_client.get(get_headers) })
|
597
609
|
end
|
598
610
|
|
599
611
|
def bearer_token(bearer_token)
|
@@ -638,11 +650,11 @@ module Kubeclient
|
|
638
650
|
options = {
|
639
651
|
basic_auth_user: @auth_options[:username],
|
640
652
|
basic_auth_password: @auth_options[:password],
|
641
|
-
headers:
|
653
|
+
headers: get_headers,
|
642
654
|
http_proxy_uri: @http_proxy_uri,
|
643
655
|
http_max_redirects: http_max_redirects
|
644
656
|
}
|
645
|
-
|
657
|
+
options[:bearer_token_file] = @auth_options[:bearer_token_file] if @auth_options[:bearer_token_file]
|
646
658
|
if uri.scheme == 'https'
|
647
659
|
options[:ssl] = {
|
648
660
|
ca_file: @ssl_options[:ca_file],
|
data/lib/kubeclient/version.rb
CHANGED
@@ -79,6 +79,7 @@ module Kubeclient
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def build_client_options
|
82
|
+
@http_options[:headers][:Authorization] = "Bearer #{File.read(@http_options[:bearer_token_file])}" if @http_options[:bearer_token_file]
|
82
83
|
client_options = {
|
83
84
|
headers: @http_options[:headers],
|
84
85
|
proxy: using_proxy
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubeclient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alissa Bonas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 5.15.0
|
48
48
|
type: :development
|
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: 5.15.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest-rg
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: tzinfo-data
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: jsonpath
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|