kubeclient 4.6.0 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of kubeclient might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/CHANGELOG.md +10 -0
- data/README.md +135 -44
- data/RELEASING.md +3 -1
- data/kubeclient.gemspec +1 -1
- data/lib/kubeclient.rb +1 -1
- data/lib/kubeclient/common.rb +1 -1
- data/lib/kubeclient/google_application_default_credentials.rb +6 -1
- data/lib/kubeclient/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 886ba443bde8e7b8a2403dc5cc300fa53f8ffdad30782f2c7c58911049d7d322
|
4
|
+
data.tar.gz: 340073ed06a0252095adb47a73ea972332e2615afdefe9fab5f357db61ceb2f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 129ca12cda43fdb8e7c2b7400f31b6086cbd06ba4c7874a4c88d07fdcfeb165b88acb620a9673a1a3a7d60f12571cef48e4167f1dd65c8c68d35022db2264320
|
7
|
+
data.tar.gz: 6184774412f3d0fa0d5a16e43520530cf279a8f8d23129f50d9973a91f58cb8bf1db4c55ddccecb710ab7577ab1737a3eba569096b8b257935ee9463e23c34c6
|
data/.travis.yml
CHANGED
@@ -11,7 +11,8 @@ rvm:
|
|
11
11
|
- "2.3.0"
|
12
12
|
- "2.4.0"
|
13
13
|
- "2.5.0"
|
14
|
-
- "2.6.
|
14
|
+
- "2.6.0"
|
15
|
+
- "2.7.0"
|
15
16
|
env:
|
16
17
|
- TASK=test
|
17
18
|
matrix:
|
@@ -20,6 +21,8 @@ matrix:
|
|
20
21
|
rvm: "2.2.0"
|
21
22
|
- os: osx
|
22
23
|
rvm: "2.3.0"
|
24
|
+
# No point running Rubocop on different rubies, results will be same.
|
25
|
+
# The rubies it expects the code to target are controlled in .rubocop.yml.
|
23
26
|
include:
|
24
27
|
- os: linux
|
25
28
|
rvm: "2.5.0"
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,16 @@ 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.0 — 2020-06-14
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
- Ruby 2.7 compatibility: bumped minimum recursive-open-struct to one that works on 2.7 (#439).
|
11
|
+
- Ruby 2.7 warnings (#433, #438).
|
12
|
+
- Improved watch documentation, including behavior planned to change in 5.0.0 (#436).
|
13
|
+
|
14
|
+
### Added
|
15
|
+
- Google Application Default Credentials: Added `userinfo.email` to requested scopes, which is necessary for RBAC policies (#441).
|
16
|
+
|
7
17
|
## 4.6.0 — 2019-12-30
|
8
18
|
|
9
19
|
### Fixed
|
data/README.md
CHANGED
@@ -207,7 +207,7 @@ client = Kubeclient::Client.new(
|
|
207
207
|
|
208
208
|
### Timeouts
|
209
209
|
|
210
|
-
Watching never
|
210
|
+
Watching configures the socket to never time out (however, sooner or later all watches terminate).
|
211
211
|
|
212
212
|
One-off actions like `.get_*`, `.delete_*` have a configurable timeout:
|
213
213
|
```ruby
|
@@ -420,16 +420,45 @@ We try to support the last 3 minor versions, matching the [official support poli
|
|
420
420
|
Kubernetes 1.2 and below have known issues and are unsupported.
|
421
421
|
Kubernetes 1.3 presumed to still work although nobody is really testing on such old versions...
|
422
422
|
|
423
|
-
##
|
423
|
+
## Supported actions & examples:
|
424
424
|
|
425
|
-
|
425
|
+
Summary of main CRUD actions:
|
426
|
+
|
427
|
+
```
|
428
|
+
get_foos(namespace: 'namespace', **opts) # namespaced collection
|
429
|
+
get_foos(**opts) # all namespaces or global collection
|
430
|
+
|
431
|
+
get_foo('name', 'namespace', opts) # namespaced
|
432
|
+
get_foo('name', nil, opts) # global
|
433
|
+
|
434
|
+
watch_foos(namespace: ns, **opts) # namespaced collection
|
435
|
+
watch_foos(**opts) # all namespaces or global collection
|
436
|
+
watch_foos(namespace: ns, name: 'name', **opts) # namespaced single object
|
437
|
+
watch_foos(name: 'name', **opts) # global single object
|
438
|
+
|
439
|
+
delete_foo('name', 'namespace', opts) # namespaced
|
440
|
+
delete_foo('name', nil, opts) # global
|
441
|
+
|
442
|
+
create_foo(Kubeclient::Resource.new({metadata: {name: 'name', namespace: 'namespace', ...}, ...}))
|
443
|
+
create_foo(Kubeclient::Resource.new({metadata: {name: 'name', ...}, ...})) # global
|
444
|
+
|
445
|
+
update_foo(Kubeclient::Resource.new({metadata: {name: 'name', namespace: 'namespace', ...}, ...}))
|
446
|
+
update_foo(Kubeclient::Resource.new({metadata: {name: 'name', ...}, ...})) # global
|
447
|
+
|
448
|
+
patch_foo('name', patch, 'namespace') # namespaced
|
449
|
+
patch_foo('name', patch) # global
|
450
|
+
```
|
451
|
+
|
452
|
+
These grew to be quite inconsistent :confounded:, see https://github.com/abonas/kubeclient/issues/312 and https://github.com/abonas/kubeclient/issues/332 for improvement plans.
|
453
|
+
|
454
|
+
### Get all instances of a specific entity type
|
426
455
|
Such as: `get_pods`, `get_secrets`, `get_services`, `get_nodes`, `get_replication_controllers`, `get_resource_quotas`, `get_limit_ranges`, `get_persistent_volumes`, `get_persistent_volume_claims`, `get_component_statuses`, `get_service_accounts`
|
427
456
|
|
428
457
|
```ruby
|
429
458
|
pods = client.get_pods
|
430
459
|
```
|
431
460
|
|
432
|
-
Get all entities of a specific type in a namespace
|
461
|
+
Get all entities of a specific type in a namespace:
|
433
462
|
|
434
463
|
```ruby
|
435
464
|
services = client.get_services(namespace: 'development')
|
@@ -447,13 +476,22 @@ You can specify multiple labels (that option will return entities which have bot
|
|
447
476
|
pods = client.get_pods(label_selector: 'name=redis-master,app=redis')
|
448
477
|
```
|
449
478
|
|
450
|
-
|
479
|
+
There is also [a limited ability to filter by *some* fields](https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/). Which fields are supported is not documented, you can try and see if you get an error...
|
480
|
+
```ruby
|
481
|
+
client.get_pods(field_selector: 'spec.nodeName=master-0')
|
482
|
+
```
|
451
483
|
|
484
|
+
You can ask for entities at a specific version by specifying a parameter named `resource_version`:
|
452
485
|
```ruby
|
453
486
|
pods = client.get_pods(resource_version: '0')
|
454
487
|
```
|
488
|
+
but it's not guaranteed you'll get it. See https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions to understand the semantics.
|
489
|
+
|
490
|
+
With default (`as: :ros`) return format, the returned object acts like an array of the individual pods, but also supports a `.resourceVersion` method.
|
491
|
+
|
492
|
+
With `:parsed` and `:parsed_symbolized` formats, the returned data structure matches kubernetes list structure: it's a hash containing `metadata` and `items` keys, the latter containing the individual pods.
|
455
493
|
|
456
|
-
Get all entities of a specific type in chunks
|
494
|
+
#### Get all entities of a specific type in chunks
|
457
495
|
|
458
496
|
```ruby
|
459
497
|
continue = nil
|
@@ -508,7 +546,87 @@ Other formats are:
|
|
508
546
|
- `:parsed` for `JSON.parse`
|
509
547
|
- `:parsed_symbolized` for `JSON.parse(..., symbolize_names: true)`
|
510
548
|
|
511
|
-
|
549
|
+
### Watch — Receive entities updates
|
550
|
+
|
551
|
+
See https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes for an overview.
|
552
|
+
|
553
|
+
It is possible to receive live update notices watching the relevant entities:
|
554
|
+
|
555
|
+
```ruby
|
556
|
+
client.watch_pods do |notice|
|
557
|
+
# process notice data
|
558
|
+
end
|
559
|
+
```
|
560
|
+
|
561
|
+
The notices have `.type` field which may be `'ADDED'`, `'MODIFIED'`, `'DELETED'`, or currently `'ERROR'`, and an `.object` field containing the object. **UPCOMING CHANGE**: In next major version, we plan to raise exceptions instead of passing on ERROR into the block.
|
562
|
+
|
563
|
+
For namespaced entities, the default watches across all namespaces, and you can specify `client.watch_secrets(namespace: 'foo')` to only watch in a single namespace.
|
564
|
+
|
565
|
+
You can narrow down using `label_selector:` and `field_selector:` params, like with `get_pods` methods.
|
566
|
+
|
567
|
+
You can also watch a single object by specifying `name:` e.g. `client.watch_nodes(name: 'gandalf')` (not namespaced so a name is enough) or `client.watch_pods(namespace: 'foo', name: 'bar')` (namespaced, need both params).
|
568
|
+
Note the method name is still plural! There is no `watch_pod`, only `watch_pods`. The yielded "type" remains the same — watch notices, it's just they'll always refer to the same object.
|
569
|
+
|
570
|
+
You can use `as:` param to control the format of the yielded notices.
|
571
|
+
|
572
|
+
#### All watches come to an end!
|
573
|
+
|
574
|
+
While nominally the watch block *looks* like an infinite loop, that's unrealistic. Network connections eventually get severed, and kubernetes apiserver is known to terminate watches.
|
575
|
+
|
576
|
+
Unfortunately, this sometimes raises an exception and sometimes the loop just exits. **UPCOMING CHANGE**: In next major version, non-deliberate termination will always raise an exception; the block will only exit silenty if stopped deliberately.
|
577
|
+
|
578
|
+
#### Deliberately stopping a watch
|
579
|
+
|
580
|
+
You can use `break` or `return` inside the watch block.
|
581
|
+
|
582
|
+
It is possible to interrupt the watcher from another thread with:
|
583
|
+
|
584
|
+
```ruby
|
585
|
+
watcher = client.watch_pods
|
586
|
+
|
587
|
+
watcher.each do |notice|
|
588
|
+
# process notice data
|
589
|
+
end
|
590
|
+
# <- control will pass here after .finish is called
|
591
|
+
|
592
|
+
### In another thread ###
|
593
|
+
watcher.finish
|
594
|
+
```
|
595
|
+
|
596
|
+
#### Starting watch version
|
597
|
+
|
598
|
+
You can specify version to start from, commonly used in "List+Watch" pattern:
|
599
|
+
```
|
600
|
+
list = client.get_pods
|
601
|
+
collection_version = list.resourceVersion
|
602
|
+
# or with other return formats:
|
603
|
+
list = client.get_pods(as: :parsed)
|
604
|
+
collection_version = list['metadata']['resourceVersion']
|
605
|
+
|
606
|
+
# note spelling resource_version vs resourceVersion.
|
607
|
+
client.watch_pods(resource_version: collection_version) do |notice|
|
608
|
+
# process notice data
|
609
|
+
end
|
610
|
+
```
|
611
|
+
It's important to understand [the effects of unset/0/specific resource_version](https://kubernetes.io/docs/reference/using-api/api-concepts/#resource-versions) as it modifies the behavior of the watch — in some modes you'll first see a burst of synthetic 'ADDED' notices for all existing objects.
|
612
|
+
|
613
|
+
If you re-try a terminated watch again without specific resourceVersion, you might see previously seen notices again, and might miss some events.
|
614
|
+
|
615
|
+
To attempt resuming a watch from same point, you can try using last resourceVersion observed during the watch. Or do list+watch again.
|
616
|
+
|
617
|
+
Whenever you ask for a specific version, you must be prepared for an 410 "Gone" error if the server no longer recognizes it.
|
618
|
+
|
619
|
+
#### Watch events about a particular object
|
620
|
+
Events are [entities in their own right](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/#event-v1-core).
|
621
|
+
You can use the `field_selector` option as part of the watch methods.
|
622
|
+
|
623
|
+
```ruby
|
624
|
+
client.watch_events(namespace: 'development', field_selector: 'involvedObject.name=redis-master') do |notice|
|
625
|
+
# process notice date
|
626
|
+
end
|
627
|
+
```
|
628
|
+
|
629
|
+
### Delete an entity (by name)
|
512
630
|
|
513
631
|
For example: `delete_pod "pod name"` , `delete_replication_controller "rc name"`, `delete_node "node name"`, `delete_secret "secret name"`
|
514
632
|
|
@@ -532,7 +650,7 @@ delete_options = Kubeclient::Resource.new(
|
|
532
650
|
client.delete_deployment(deployment_name, namespace, delete_options: delete_options)
|
533
651
|
```
|
534
652
|
|
535
|
-
|
653
|
+
### Create an entity
|
536
654
|
For example: `create_pod pod_object`, `create_replication_controller rc_obj`, `create_secret secret_object`, `create_resource_quota resource_quota_object`, `create_limit_range limit_range_object`, `create_persistent_volume persistent_volume_object`, `create_persistent_volume_claim persistent_volume_claim_object`, `create_service_account service_account_object`
|
537
655
|
|
538
656
|
Input parameter - object of type `Service`, `Pod`, `ReplicationController`.
|
@@ -558,7 +676,7 @@ service.metadata.labels.role = 'slave'
|
|
558
676
|
client.create_service(service)
|
559
677
|
```
|
560
678
|
|
561
|
-
|
679
|
+
### Update an entity
|
562
680
|
For example: `update_pod`, `update_service`, `update_replication_controller`, `update_secret`, `update_resource_quota`, `update_limit_range`, `update_persistent_volume`, `update_persistent_volume_claim`, `update_service_account`
|
563
681
|
|
564
682
|
Input parameter - object of type `Pod`, `Service`, `ReplicationController` etc.
|
@@ -569,7 +687,7 @@ The below example is for v1
|
|
569
687
|
updated = client.update_service(service1)
|
570
688
|
```
|
571
689
|
|
572
|
-
|
690
|
+
### Patch an entity (by name)
|
573
691
|
For example: `patch_pod`, `patch_service`, `patch_secret`, `patch_resource_quota`, `patch_persistent_volume`
|
574
692
|
|
575
693
|
Input parameters - name (string) specifying the entity name, patch (hash) to be applied to the resource, optional: namespace name (string)
|
@@ -584,44 +702,17 @@ patched = client.patch_pod("docker-registry", {metadata: {annotations: {key: 'va
|
|
584
702
|
|
585
703
|
`patch_#{entity}` is called using a [strategic merge patch](https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#notes-on-the-strategic-merge-patch). `json_patch_#{entity}` and `merge_patch_#{entity}` are also available that use JSON patch and JSON merge patch, respectively. These strategies are useful for resources that do not support strategic merge patch, such as Custom Resources. Consult the [Kubernetes docs](https://kubernetes.io/docs/tasks/run-application/update-api-object-kubectl-patch/#use-a-json-merge-patch-to-update-a-deployment) for more information about the different patch strategies.
|
586
704
|
|
587
|
-
|
588
|
-
Returns a hash with the following keys (node, secret, service, pod, replication_controller, namespace, resource_quota, limit_range, endpoint, event, persistent_volume, persistent_volume_claim, component_status and service_account). Each key points to an EntityList of same type.
|
589
|
-
This method is a convenience method instead of calling each entity's get method separately.
|
705
|
+
### Get all entities of all types : all_entities
|
590
706
|
|
591
|
-
|
592
|
-
client.all_entities
|
593
|
-
```
|
707
|
+
Makes requests for all entities of each discovered kind (in this client's API group). This method is a convenience method instead of calling each entity's get method separately.
|
594
708
|
|
595
|
-
|
596
|
-
It is possible to receive live update notices watching the relevant entities:
|
709
|
+
Returns a hash with keys being the *singular* entity kind, in lowercase underscore style. For example for core API group may return keys `"node'`, `"secret"`, `"service"`, `"pod"`, `"replication_controller"`, `"namespace"`, `"resource_quota"`, `"limit_range"`, `"endpoint"`, `"event"`, `"persistent_volume"`, `"persistent_volume_claim"`, `"component_status"`, `"service_account"`. Each key points to an EntityList of same type.
|
597
710
|
|
598
711
|
```ruby
|
599
|
-
client.
|
600
|
-
# process notice data
|
601
|
-
end
|
602
|
-
```
|
603
|
-
|
604
|
-
It is possible to interrupt the watcher from another thread with:
|
605
|
-
|
606
|
-
```ruby
|
607
|
-
watcher = client.watch_pods
|
608
|
-
watcher.each do |notice|
|
609
|
-
# process notice data
|
610
|
-
end
|
611
|
-
|
612
|
-
watcher.finish # other thread
|
613
|
-
```
|
614
|
-
|
615
|
-
#### Watch events for a particular object
|
616
|
-
You can use the `field_selector` option as part of the watch methods.
|
617
|
-
|
618
|
-
```ruby
|
619
|
-
client.watch_events(namespace: 'development', field_selector: 'involvedObject.name=redis-master') do |notice|
|
620
|
-
# process notice date
|
621
|
-
end
|
712
|
+
client.all_entities
|
622
713
|
```
|
623
714
|
|
624
|
-
|
715
|
+
### Get a proxy URL
|
625
716
|
You can get a complete URL for connecting a kubernetes entity via the proxy.
|
626
717
|
|
627
718
|
```ruby
|
@@ -636,7 +727,7 @@ client.proxy_url('pod', 'podname', 5001, 'ns')
|
|
636
727
|
# => "https://localhost.localdomain:8443/api/v1/namespaces/ns/pods/podname:5001/proxy"
|
637
728
|
```
|
638
729
|
|
639
|
-
|
730
|
+
### Get the logs of a pod
|
640
731
|
You can get the logs of a running pod, specifying the name of the pod and the
|
641
732
|
namespace where the pod is running:
|
642
733
|
|
@@ -687,7 +778,7 @@ client.watch_pod_log('pod-name', 'default', container: 'ruby') do |line|
|
|
687
778
|
end
|
688
779
|
```
|
689
780
|
|
690
|
-
|
781
|
+
### OpenShift: Process a template
|
691
782
|
Returns a processed template containing a list of objects to create.
|
692
783
|
Input parameter - template (hash)
|
693
784
|
Besides its metadata, the template should include a list of objects to be processed and a list of parameters
|
data/RELEASING.md
CHANGED
@@ -20,7 +20,9 @@ Edit `CHANGELOG.md` as necessary. Even if all included changes remembered to up
|
|
20
20
|
|
21
21
|
Bump `lib/kubeclient/version.rb` manually, or by using:
|
22
22
|
```bash
|
23
|
-
|
23
|
+
RELEASE_VERSION=x.y.z
|
24
|
+
|
25
|
+
git checkout -b "release-$RELEASE_VERSION" $RELEASE_BRANCH
|
24
26
|
# Won't work with uncommitted changes, you have to commit the changelog first.
|
25
27
|
gem bump --version $RELEASE_VERSION
|
26
28
|
git show # View version bump change.
|
data/kubeclient.gemspec
CHANGED
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'jsonpath', '~> 1.0'
|
34
34
|
|
35
35
|
spec.add_dependency 'rest-client', '~> 2.0'
|
36
|
-
spec.add_dependency 'recursive-open-struct', '~> 1.
|
36
|
+
spec.add_dependency 'recursive-open-struct', '~> 1.1', '>= 1.1.1'
|
37
37
|
spec.add_dependency 'http', '>= 3.0', '< 5.0'
|
38
38
|
end
|
data/lib/kubeclient.rb
CHANGED
data/lib/kubeclient/common.rb
CHANGED
@@ -229,7 +229,7 @@ module Kubeclient
|
|
229
229
|
|
230
230
|
define_singleton_method("delete_#{entity.method_names[0]}") \
|
231
231
|
do |name, namespace = nil, opts = {}|
|
232
|
-
delete_entity(entity.resource_name, name, namespace, opts)
|
232
|
+
delete_entity(entity.resource_name, name, namespace, **opts)
|
233
233
|
end
|
234
234
|
|
235
235
|
define_singleton_method("create_#{entity.method_names[0]}") do |entity_config|
|
@@ -16,7 +16,12 @@ module Kubeclient
|
|
16
16
|
'googleauth gem. To support auth-provider gcp, you must include it in your ' \
|
17
17
|
"calling application. Failed with: #{e.message}"
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
|
+
scopes = [
|
21
|
+
'https://www.googleapis.com/auth/cloud-platform',
|
22
|
+
'https://www.googleapis.com/auth/userinfo.email'
|
23
|
+
]
|
24
|
+
|
20
25
|
authorization = Google::Auth.get_application_default(scopes)
|
21
26
|
authorization.apply({})
|
22
27
|
authorization.access_token
|
data/lib/kubeclient/version.rb
CHANGED
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.7.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:
|
11
|
+
date: 2020-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -184,20 +184,20 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: '1.
|
187
|
+
version: '1.1'
|
188
188
|
- - ">="
|
189
189
|
- !ruby/object:Gem::Version
|
190
|
-
version: 1.
|
190
|
+
version: 1.1.1
|
191
191
|
type: :runtime
|
192
192
|
prerelease: false
|
193
193
|
version_requirements: !ruby/object:Gem::Requirement
|
194
194
|
requirements:
|
195
195
|
- - "~>"
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
version: '1.
|
197
|
+
version: '1.1'
|
198
198
|
- - ">="
|
199
199
|
- !ruby/object:Gem::Version
|
200
|
-
version: 1.
|
200
|
+
version: 1.1.1
|
201
201
|
- !ruby/object:Gem::Dependency
|
202
202
|
name: http
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
@@ -372,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
372
372
|
- !ruby/object:Gem::Version
|
373
373
|
version: '0'
|
374
374
|
requirements: []
|
375
|
-
rubygems_version: 3.
|
375
|
+
rubygems_version: 3.1.2
|
376
376
|
signing_key:
|
377
377
|
specification_version: 4
|
378
378
|
summary: A client for Kubernetes REST api
|