kubeclient 2.5.2 → 3.0.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.
Potentially problematic release.
This version of kubeclient might be problematic. Click here for more details.
- checksums.yaml +4 -4
 - data/.rubocop.yml +13 -5
 - data/.travis.yml +2 -10
 - data/CHANGELOG.md +21 -2
 - data/README.md +112 -46
 - data/Rakefile +2 -5
 - data/kubeclient.gemspec +9 -7
 - data/lib/kubeclient.rb +8 -8
 - data/lib/kubeclient/common.rb +88 -105
 - data/lib/kubeclient/config.rb +10 -10
 - data/lib/kubeclient/http_error.rb +25 -0
 - data/lib/kubeclient/missing_kind_compatibility.rb +1 -1
 - data/lib/kubeclient/resource.rb +11 -0
 - data/lib/kubeclient/resource_not_found_error.rb +4 -0
 - data/lib/kubeclient/version.rb +1 -1
 - data/lib/kubeclient/watch_stream.rb +17 -10
 - data/test/test_common.rb +3 -3
 - data/test/test_component_status.rb +16 -14
 - data/test/test_config.rb +11 -11
 - data/test/test_endpoint.rb +16 -12
 - data/test/test_guestbook_go.rb +64 -62
 - data/test/test_helper.rb +2 -0
 - data/test/test_kubeclient.rb +268 -282
 - data/test/test_limit_range.rb +11 -11
 - data/test/test_missing_methods.rb +3 -3
 - data/test/test_namespace.rb +27 -27
 - data/test/test_node.rb +17 -15
 - data/test/test_persistent_volume.rb +16 -14
 - data/test/test_persistent_volume_claim.rb +16 -14
 - data/test/test_pod.rb +16 -14
 - data/test/test_pod_log.rb +4 -4
 - data/test/test_process_template.rb +7 -7
 - data/test/test_replication_controller.rb +29 -4
 - data/test/test_resource_list_without_kind.rb +7 -7
 - data/test/test_resource_quota.rb +4 -4
 - data/test/test_secret.rb +11 -10
 - data/test/test_service.rb +36 -31
 - data/test/test_service_account.rb +4 -4
 - data/test/test_watch.rb +52 -29
 - data/test/test_watch_notice.rb +1 -1
 - metadata +35 -26
 - data/Gemfile-rest-client-1.8.rb +0 -11
 - data/lib/kubeclient/kube_exception.rb +0 -14
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: e9aaeb2002708298a57d829ccce3530a4233de62
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4343990defde5ef36719ccbf02936b92e7e1be5c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 928f8df41783e2eb13c65536de2ad3270f3ed3fcc95459d25fcb21a66a6e86b0f279a9c238cddb7196dc82bd7c9cc7dd42a778f208ee56397e149a4c0f048f3c
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 9a541d45aba922c4ab24196bd3d0cb755a46ae5bd276436510fa66e60cdc6c60056eba4501152036751ec5cd8ec3ec8c0d254687c54b6ba532ac18812634a06b
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    | 
         @@ -1,9 +1,10 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            AllCops:
         
     | 
| 
      
 2 
     | 
    
         
            +
              DisplayCopNames: true
         
     | 
| 
      
 3 
     | 
    
         
            +
              TargetRubyVersion: 2.2 # Oldest version kubeclient supports
         
     | 
| 
       1 
4 
     | 
    
         
             
            MethodLength:
         
     | 
| 
       2 
5 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       3 
6 
     | 
    
         
             
            ClassLength:
         
     | 
| 
       4 
7 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       5 
     | 
    
         
            -
            Documentation:
         
     | 
| 
       6 
     | 
    
         
            -
              Enabled: false
         
     | 
| 
       7 
8 
     | 
    
         
             
            Metrics/AbcSize:
         
     | 
| 
       8 
9 
     | 
    
         
             
              Enabled: false
         
     | 
| 
       9 
10 
     | 
    
         
             
            Metrics/LineLength:
         
     | 
| 
         @@ -13,7 +14,14 @@ Metrics/ParameterLists: 
     | 
|
| 
       13 
14 
     | 
    
         
             
              CountKeywordArgs: false
         
     | 
| 
       14 
15 
     | 
    
         
             
            Metrics/CyclomaticComplexity:
         
     | 
| 
       15 
16 
     | 
    
         
             
              Max: 8
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              Exclude: [Gemfile*]
         
     | 
| 
       18 
     | 
    
         
            -
            Style/SignalException:
         
     | 
| 
      
 17 
     | 
    
         
            +
            Metrics/ModuleLength:
         
     | 
| 
       19 
18 
     | 
    
         
             
              Enabled: false
         
     | 
| 
      
 19 
     | 
    
         
            +
            Style/MethodCallWithArgsParentheses:
         
     | 
| 
      
 20 
     | 
    
         
            +
              Enabled: true
         
     | 
| 
      
 21 
     | 
    
         
            +
              IgnoredMethods: [require, raise, include, attr_reader, refute, assert]
         
     | 
| 
      
 22 
     | 
    
         
            +
              Exclude: [Gemfile, Rakefile, kubeclient.gemspec]
         
     | 
| 
      
 23 
     | 
    
         
            +
            Security/MarshalLoad:
         
     | 
| 
      
 24 
     | 
    
         
            +
              Exclude: [test/**/*]
         
     | 
| 
      
 25 
     | 
    
         
            +
            Style/MethodCallWithArgsParentheses:
         
     | 
| 
      
 26 
     | 
    
         
            +
              IgnoredMethods:
         
     | 
| 
      
 27 
     | 
    
         
            +
              - require_relative
         
     | 
    
        data/.travis.yml
    CHANGED
    
    | 
         @@ -1,20 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            language: ruby
         
     | 
| 
       2 
2 
     | 
    
         
             
            rvm:
         
     | 
| 
       3 
     | 
    
         
            -
              - "2.0"
         
     | 
| 
       4 
     | 
    
         
            -
              - "2.1"
         
     | 
| 
       5 
3 
     | 
    
         
             
              - "2.2"
         
     | 
| 
       6 
4 
     | 
    
         
             
              - "2.3.0"
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              - Gemfile-rest-client-1.8.rb
         
     | 
| 
      
 5 
     | 
    
         
            +
              - "2.4.0"
         
     | 
| 
      
 6 
     | 
    
         
            +
              - "2.5.0"
         
     | 
| 
       10 
7 
     | 
    
         
             
            sudo: false
         
     | 
| 
       11 
8 
     | 
    
         
             
            cache: bundler
         
     | 
| 
       12 
9 
     | 
    
         
             
            script: bundle exec rake $TASK
         
     | 
| 
       13 
10 
     | 
    
         
             
            env:
         
     | 
| 
       14 
11 
     | 
    
         
             
             - TASK=test
         
     | 
| 
       15 
12 
     | 
    
         
             
             - TASK=rubocop
         
     | 
| 
       16 
     | 
    
         
            -
            matrix:
         
     | 
| 
       17 
     | 
    
         
            -
              exclude:
         
     | 
| 
       18 
     | 
    
         
            -
                # No point running rubocop with old rest-client
         
     | 
| 
       19 
     | 
    
         
            -
                - gemfile: Gemfile-rest-client-1.8.rb
         
     | 
| 
       20 
     | 
    
         
            -
                  env: TASK=rubocop
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -3,11 +3,30 @@ 
     | 
|
| 
       3 
3 
     | 
    
         
             
            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 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            ##  
     | 
| 
      
 6 
     | 
    
         
            +
            ## 3.0.0 - 2018-02-01
         
     | 
| 
      
 7 
     | 
    
         
            +
            ### Removed
         
     | 
| 
      
 8 
     | 
    
         
            +
            - Dropped entity classes (`Kubeclient::Pod` etc.), only `Kubeclient::Resource` exists now (#292, #288).
         
     | 
| 
      
 9 
     | 
    
         
            +
            - Ruby 2.0, 2.1 no longer supported (#253, #291).
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       7 
11 
     | 
    
         
             
            ### Fixed
         
     | 
| 
       8 
12 
     | 
    
         
             
            - Watch results are now `RecursiveOpenStruct` inside arrays too (#279).
         
     | 
| 
       9 
13 
     | 
    
         
             
            - Fixed watch `.finish` sometimes caused `Errno::EBADF` exception from the reading loop (#280).
         
     | 
| 
       10 
     | 
    
         
            -
            -  
     | 
| 
      
 14 
     | 
    
         
            +
            - Added missing singular `get_security_context_constraint`, fixed `get_security_context_constraints` to mean plural (#261).
         
     | 
| 
      
 15 
     | 
    
         
            +
            - Fixed `@http_proxy_uri` undefined warning (#261).
         
     | 
| 
      
 16 
     | 
    
         
            +
            - Documentation fixes & improvements (#225, #229, #243, #296).
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            ### Added
         
     | 
| 
      
 19 
     | 
    
         
            +
            - `delete_options:` parameter to `delete_*` methods, useful for cascade delete (#267).
         
     | 
| 
      
 20 
     | 
    
         
            +
            - `as: :raw` option for watch (#285).
         
     | 
| 
      
 21 
     | 
    
         
            +
            - Now raises `Kubeclient::HttpError`.  Rescuing `KubeException` still works but is deprecated. (#195, #288)
         
     | 
| 
      
 22 
     | 
    
         
            +
              - 404 error raise `Kubeclient::ResourceNotFoundError`, a subclass of `HttpError` (#233).
         
     | 
| 
      
 23 
     | 
    
         
            +
            - Include request info in exception message (#221).
         
     | 
| 
      
 24 
     | 
    
         
            +
            - Ruby 2.4 and 2.5 are now supported & tested (#247, #295).
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            ### Changed
         
     | 
| 
      
 27 
     | 
    
         
            +
            - `Kubeclient::Config#context(nonexistent_context_name)` raises `KeyError` instead of `RuntimeError`.
         
     | 
| 
      
 28 
     | 
    
         
            +
            - `update_*`, `delete_*`, `patch_*` now all return `RecursiveOpenStruct` consistently (#290).
         
     | 
| 
      
 29 
     | 
    
         
            +
            - Many dependencies bumped (#204, #231, #253, #269).
         
     | 
| 
       11 
30 
     | 
    
         | 
| 
       12 
31 
     | 
    
         
             
            ## 2.5.1 - 2017-10-12
         
     | 
| 
       13 
32 
     | 
    
         
             
            No changes since 2.5.0, fixed packaging mistake.
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -6,8 +6,9 @@ 
     | 
|
| 
       6 
6 
     | 
    
         
             
            [](https://gemnasium.com/abonas/kubeclient)
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            A Ruby client for Kubernetes REST api.
         
     | 
| 
       9 
     | 
    
         
            -
            The client supports GET, POST, PUT, DELETE on  
     | 
| 
      
 9 
     | 
    
         
            +
            The client supports GET, POST, PUT, DELETE on all the entities available in kubernetes in both the core and group apis.
         
     | 
| 
       10 
10 
     | 
    
         
             
            The client currently supports Kubernetes REST api version v1.
         
     | 
| 
      
 11 
     | 
    
         
            +
            To learn more about groups and versions in kubernetes refer to [k8s docs](https://kubernetes.io/docs/api/)
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
            ## Installation
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
         @@ -19,23 +20,28 @@ gem 'kubeclient' 
     | 
|
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
            And then execute:
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
            ```Bash
         
     | 
| 
      
 24 
     | 
    
         
            +
            bundle
         
     | 
| 
      
 25 
     | 
    
         
            +
            ```
         
     | 
| 
       23 
26 
     | 
    
         | 
| 
       24 
27 
     | 
    
         
             
            Or install it yourself as:
         
     | 
| 
       25 
28 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 29 
     | 
    
         
            +
            ```Bash
         
     | 
| 
      
 30 
     | 
    
         
            +
            gem install kubeclient
         
     | 
| 
      
 31 
     | 
    
         
            +
            ```
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
       28 
33 
     | 
    
         
             
            ## Usage
         
     | 
| 
       29 
34 
     | 
    
         | 
| 
       30 
35 
     | 
    
         
             
            Initialize the client:
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
       31 
37 
     | 
    
         
             
            ```ruby
         
     | 
| 
       32 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
      
 38 
     | 
    
         
            +
            client = Kubeclient::Client.new('http://localhost:8080/api/', "v1")
         
     | 
| 
       33 
39 
     | 
    
         
             
            ```
         
     | 
| 
       34 
40 
     | 
    
         | 
| 
       35 
41 
     | 
    
         
             
            Or without specifying version (it will be set by default to "v1")
         
     | 
| 
       36 
42 
     | 
    
         | 
| 
       37 
43 
     | 
    
         
             
            ```ruby
         
     | 
| 
       38 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
      
 44 
     | 
    
         
            +
            client = Kubeclient::Client.new('http://localhost:8080/api/')
         
     | 
| 
       39 
45 
     | 
    
         
             
            ```
         
     | 
| 
       40 
46 
     | 
    
         | 
| 
       41 
47 
     | 
    
         
             
            For A Group Api:
         
     | 
| 
         @@ -48,7 +54,7 @@ Another option is to initialize the client with URI object: 
     | 
|
| 
       48 
54 
     | 
    
         | 
| 
       49 
55 
     | 
    
         
             
            ```ruby
         
     | 
| 
       50 
56 
     | 
    
         
             
            uri = URI::HTTP.build(host: "somehostname", port: 8080)
         
     | 
| 
       51 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
      
 57 
     | 
    
         
            +
            client = Kubeclient::Client.new(uri)
         
     | 
| 
       52 
58 
     | 
    
         
             
            ```
         
     | 
| 
       53 
59 
     | 
    
         | 
| 
       54 
60 
     | 
    
         
             
            ### SSL
         
     | 
| 
         @@ -62,8 +68,9 @@ ssl_options = { 
     | 
|
| 
       62 
68 
     | 
    
         
             
              ca_file:     '/path/to/ca.crt',
         
     | 
| 
       63 
69 
     | 
    
         
             
              verify_ssl:  OpenSSL::SSL::VERIFY_PEER
         
     | 
| 
       64 
70 
     | 
    
         
             
            }
         
     | 
| 
       65 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
      
 71 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 72 
     | 
    
         
            +
              'https://localhost:8443/api/', "v1", ssl_options: ssl_options
         
     | 
| 
      
 73 
     | 
    
         
            +
            )
         
     | 
| 
       67 
74 
     | 
    
         
             
            ```
         
     | 
| 
       68 
75 
     | 
    
         | 
| 
       69 
76 
     | 
    
         
             
            As an alternative to the `ca_file` it's possible to use the `cert_store`:
         
     | 
| 
         @@ -75,16 +82,18 @@ ssl_options = { 
     | 
|
| 
       75 
82 
     | 
    
         
             
              cert_store: cert_store,
         
     | 
| 
       76 
83 
     | 
    
         
             
              verify_ssl: OpenSSL::SSL::VERIFY_PEER
         
     | 
| 
       77 
84 
     | 
    
         
             
            }
         
     | 
| 
       78 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
      
 85 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 86 
     | 
    
         
            +
              'https://localhost:8443/api/', "v1", ssl_options: ssl_options
         
     | 
| 
      
 87 
     | 
    
         
            +
            )
         
     | 
| 
       80 
88 
     | 
    
         
             
            ```
         
     | 
| 
       81 
89 
     | 
    
         | 
| 
       82 
90 
     | 
    
         
             
            For testing and development purpose you can disable the ssl check with:
         
     | 
| 
       83 
91 
     | 
    
         | 
| 
       84 
92 
     | 
    
         
             
            ```ruby
         
     | 
| 
       85 
93 
     | 
    
         
             
            ssl_options = { verify_ssl: OpenSSL::SSL::VERIFY_NONE }
         
     | 
| 
       86 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
      
 94 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 95 
     | 
    
         
            +
              'https://localhost:8443/api/', 'v1', ssl_options: ssl_options
         
     | 
| 
      
 96 
     | 
    
         
            +
            )
         
     | 
| 
       88 
97 
     | 
    
         
             
            ```
         
     | 
| 
       89 
98 
     | 
    
         | 
| 
       90 
99 
     | 
    
         
             
            ### Authentication
         
     | 
| 
         @@ -98,8 +107,9 @@ auth_options = { 
     | 
|
| 
       98 
107 
     | 
    
         
             
              username: 'username',
         
     | 
| 
       99 
108 
     | 
    
         
             
              password: 'password'
         
     | 
| 
       100 
109 
     | 
    
         
             
            }
         
     | 
| 
       101 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
      
 110 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 111 
     | 
    
         
            +
              'https://localhost:8443/api/', 'v1', auth_options: auth_options
         
     | 
| 
      
 112 
     | 
    
         
            +
            )
         
     | 
| 
       103 
113 
     | 
    
         
             
            ```
         
     | 
| 
       104 
114 
     | 
    
         | 
| 
       105 
115 
     | 
    
         
             
            or
         
     | 
| 
         @@ -108,8 +118,9 @@ or 
     | 
|
| 
       108 
118 
     | 
    
         
             
            auth_options = {
         
     | 
| 
       109 
119 
     | 
    
         
             
              bearer_token: 'MDExMWJkMjItOWY1Ny00OGM5LWJlNDEtMjBiMzgxODkxYzYz'
         
     | 
| 
       110 
120 
     | 
    
         
             
            }
         
     | 
| 
       111 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
      
 121 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 122 
     | 
    
         
            +
              'https://localhost:8443/api/', 'v1', auth_options: auth_options
         
     | 
| 
      
 123 
     | 
    
         
            +
            )
         
     | 
| 
       113 
124 
     | 
    
         
             
            ```
         
     | 
| 
       114 
125 
     | 
    
         | 
| 
       115 
126 
     | 
    
         
             
            or
         
     | 
| 
         @@ -118,8 +129,9 @@ or 
     | 
|
| 
       118 
129 
     | 
    
         
             
            auth_options = {
         
     | 
| 
       119 
130 
     | 
    
         
             
              bearer_token_file: '/path/to/token_file'
         
     | 
| 
       120 
131 
     | 
    
         
             
            }
         
     | 
| 
       121 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
      
 132 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 133 
     | 
    
         
            +
              'https://localhost:8443/api/', 'v1', auth_options: auth_options
         
     | 
| 
      
 134 
     | 
    
         
            +
            )
         
     | 
| 
       123 
135 
     | 
    
         
             
            ```
         
     | 
| 
       124 
136 
     | 
    
         | 
| 
       125 
137 
     | 
    
         
             
            If you are running your app using kubeclient inside a Kubernetes cluster, then you can have a bearer token file
         
     | 
| 
         @@ -133,15 +145,16 @@ for more details). For example: 
     | 
|
| 
       133 
145 
     | 
    
         
             
            auth_options = {
         
     | 
| 
       134 
146 
     | 
    
         
             
              bearer_token_file: '/var/run/secrets/kubernetes.io/serviceaccount/token'
         
     | 
| 
       135 
147 
     | 
    
         
             
            }
         
     | 
| 
       136 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
      
 148 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 149 
     | 
    
         
            +
              'https://localhost:8443/api/', 'v1', auth_options: auth_options
         
     | 
| 
      
 150 
     | 
    
         
            +
            )
         
     | 
| 
       138 
151 
     | 
    
         
             
            ```
         
     | 
| 
       139 
152 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
            You can find information about  
     | 
| 
      
 153 
     | 
    
         
            +
            You can find information about tokens in [this guide](http://kubernetes.io/docs/user-guide/accessing-the-cluster/) and in [this reference](http://kubernetes.io/docs/admin/authentication/).
         
     | 
| 
       141 
154 
     | 
    
         | 
| 
       142 
155 
     | 
    
         
             
            ### Non-blocking IO
         
     | 
| 
       143 
156 
     | 
    
         | 
| 
       144 
     | 
    
         
            -
            You can also use kubeclient with non-blocking sockets such as Celluloid::IO, see [here](https://github.com/httprb/http/wiki/Parallel-requests-with-Celluloid%3A%3AIO) 
     | 
| 
      
 157 
     | 
    
         
            +
            You can also use kubeclient with non-blocking sockets such as Celluloid::IO, see [here](https://github.com/httprb/http/wiki/Parallel-requests-with-Celluloid%3A%3AIO)
         
     | 
| 
       145 
158 
     | 
    
         
             
            for details. For example:
         
     | 
| 
       146 
159 
     | 
    
         | 
| 
       147 
160 
     | 
    
         
             
            ```ruby
         
     | 
| 
         @@ -150,8 +163,9 @@ socket_options = { 
     | 
|
| 
       150 
163 
     | 
    
         
             
              socket_class: Celluloid::IO::TCPSocket,
         
     | 
| 
       151 
164 
     | 
    
         
             
              ssl_socket_class: Celluloid::IO::SSLSocket
         
     | 
| 
       152 
165 
     | 
    
         
             
            }
         
     | 
| 
       153 
     | 
    
         
            -
            client = Kubeclient::Client.new 
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
      
 166 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 167 
     | 
    
         
            +
              'https://localhost:8443/api/', 'v1', socket_options: socket_options
         
     | 
| 
      
 168 
     | 
    
         
            +
            )
         
     | 
| 
       155 
169 
     | 
    
         
             
            ```
         
     | 
| 
       156 
170 
     | 
    
         | 
| 
       157 
171 
     | 
    
         
             
            This affects only `.watch_*` sockets, not one-off actions like `.get_*`, `.delete_*` etc.
         
     | 
| 
         @@ -162,8 +176,9 @@ You can also use kubeclient with an http proxy server such as tinyproxy. It can 
     | 
|
| 
       162 
176 
     | 
    
         
             
            For example:
         
     | 
| 
       163 
177 
     | 
    
         
             
            ```ruby
         
     | 
| 
       164 
178 
     | 
    
         
             
            proxy_uri = URI::HTTP.build(host: "myproxyhost", port: 8443)
         
     | 
| 
       165 
     | 
    
         
            -
            client = Kubeclient::Client.new( 
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
      
 179 
     | 
    
         
            +
            client = Kubeclient::Client.new(
         
     | 
| 
      
 180 
     | 
    
         
            +
              'https://localhost:8443/api/', http_proxy_uri: proxy_uri
         
     | 
| 
      
 181 
     | 
    
         
            +
            )
         
     | 
| 
       167 
182 
     | 
    
         
             
            ```
         
     | 
| 
       168 
183 
     | 
    
         | 
| 
       169 
184 
     | 
    
         | 
| 
         @@ -193,13 +208,15 @@ If you want ruby-independent behavior, always specify `:open`. 
     | 
|
| 
       193 
208 
     | 
    
         
             
            Discovery from the kube-apiserver is done lazily on method calls so it would not change behavior.
         
     | 
| 
       194 
209 
     | 
    
         | 
| 
       195 
210 
     | 
    
         
             
            It can also  be done explicitly:
         
     | 
| 
       196 
     | 
    
         
            -
             
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       197 
213 
     | 
    
         
             
            client = Kubeclient::Client.new('http://localhost:8080/api', 'v1')
         
     | 
| 
       198 
214 
     | 
    
         
             
            client.discover
         
     | 
| 
       199 
215 
     | 
    
         
             
            ```
         
     | 
| 
       200 
216 
     | 
    
         | 
| 
       201 
217 
     | 
    
         
             
            It is possible to check the status of discovery
         
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
      
 218 
     | 
    
         
            +
             
     | 
| 
      
 219 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       203 
220 
     | 
    
         
             
            unless client.discovered
         
     | 
| 
       204 
221 
     | 
    
         
             
              client.discover
         
     | 
| 
       205 
222 
     | 
    
         
             
            end
         
     | 
| 
         @@ -208,6 +225,7 @@ end 
     | 
|
| 
       208 
225 
     | 
    
         
             
            ### Kubeclient::Config
         
     | 
| 
       209 
226 
     | 
    
         | 
| 
       210 
227 
     | 
    
         
             
            If you've been using `kubectl` and have a `.kube/config` file, you can auto-populate a config object using `Kubeclient::Config`:
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
       211 
229 
     | 
    
         
             
            ```ruby
         
     | 
| 
       212 
230 
     | 
    
         
             
            config = Kubeclient::Config.read('/path/to/.kube/config')
         
     | 
| 
       213 
231 
     | 
    
         
             
            ```
         
     | 
| 
         @@ -216,21 +234,22 @@ config = Kubeclient::Config.read('/path/to/.kube/config') 
     | 
|
| 
       216 
234 
     | 
    
         | 
| 
       217 
235 
     | 
    
         
             
            ```
         
     | 
| 
       218 
236 
     | 
    
         
             
            Kubeclient::Client.new(
         
     | 
| 
       219 
     | 
    
         
            -
             
     | 
| 
      
 237 
     | 
    
         
            +
              config.context.api_endpoint,
         
     | 
| 
       220 
238 
     | 
    
         
             
                config.context.api_version,
         
     | 
| 
       221 
239 
     | 
    
         
             
                {
         
     | 
| 
       222 
     | 
    
         
            -
             
     | 
| 
       223 
     | 
    
         
            -
             
     | 
| 
      
 240 
     | 
    
         
            +
                  ssl_options: config.context.ssl_options,
         
     | 
| 
      
 241 
     | 
    
         
            +
                  auth_options: config.context.auth_options
         
     | 
| 
       224 
242 
     | 
    
         
             
                }
         
     | 
| 
       225 
243 
     | 
    
         
             
            )
         
     | 
| 
       226 
244 
     | 
    
         
             
            ```
         
     | 
| 
       227 
245 
     | 
    
         | 
| 
       228 
246 
     | 
    
         
             
            You can also load your JSONified config in from an ENV variable (e.g. `KUBE_CONFIG`) like so:
         
     | 
| 
       229 
247 
     | 
    
         | 
| 
       230 
     | 
    
         
            -
            ```
         
     | 
| 
      
 248 
     | 
    
         
            +
            ```ruby
         
     | 
| 
       231 
249 
     | 
    
         
             
            Kubeclient::Config.new(JSON.parse(ENV['KUBE_CONFIG']), nil)
         
     | 
| 
       232 
250 
     | 
    
         
             
            ```
         
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
      
 251 
     | 
    
         
            +
             
     | 
| 
      
 252 
     | 
    
         
            +
            ### Supported kubernetes versions
         
     | 
| 
       234 
253 
     | 
    
         | 
| 
       235 
254 
     | 
    
         
             
            For 1.1 only the core api v1 is supported, all api groups are supported in later versions.
         
     | 
| 
       236 
255 
     | 
    
         | 
| 
         @@ -256,6 +275,7 @@ pods = client.get_pods(label_selector: 'name=redis-master') 
     | 
|
| 
       256 
275 
     | 
    
         
             
            ```
         
     | 
| 
       257 
276 
     | 
    
         | 
| 
       258 
277 
     | 
    
         
             
            You can specify multiple labels (that option will return entities which have both labels:
         
     | 
| 
      
 278 
     | 
    
         
            +
             
     | 
| 
       259 
279 
     | 
    
         
             
            ```ruby
         
     | 
| 
       260 
280 
     | 
    
         
             
            pods = client.get_pods(label_selector: 'name=redis-master,app=redis')
         
     | 
| 
       261 
281 
     | 
    
         
             
            ```
         
     | 
| 
         @@ -289,8 +309,23 @@ node = client.get_node "127.0.0.1", as: :raw 
     | 
|
| 
       289 
309 
     | 
    
         
             
            For example: `delete_pod "pod name"` , `delete_replication_controller "rc name"`, `delete_node "node name"`, `delete_secret "secret name"`
         
     | 
| 
       290 
310 
     | 
    
         | 
| 
       291 
311 
     | 
    
         
             
            Input parameter - name (string) specifying service name, pod name, replication controller name.
         
     | 
| 
      
 312 
     | 
    
         
            +
             
     | 
| 
      
 313 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 314 
     | 
    
         
            +
            deleted = client.delete_service("redis-service")
         
     | 
| 
      
 315 
     | 
    
         
            +
            ```
         
     | 
| 
      
 316 
     | 
    
         
            +
             
     | 
| 
      
 317 
     | 
    
         
            +
            If you want to cascade delete, for example a deployment, you can use the `delete_options` parameter.
         
     | 
| 
      
 318 
     | 
    
         
            +
             
     | 
| 
       292 
319 
     | 
    
         
             
            ```ruby
         
     | 
| 
       293 
     | 
    
         
            -
             
     | 
| 
      
 320 
     | 
    
         
            +
            deployment_name = 'redis-deployment'
         
     | 
| 
      
 321 
     | 
    
         
            +
            namespace = 'default'
         
     | 
| 
      
 322 
     | 
    
         
            +
            delete_options = Kubeclient::Resource.new(
         
     | 
| 
      
 323 
     | 
    
         
            +
                apiVersion: 'meta/v1',
         
     | 
| 
      
 324 
     | 
    
         
            +
                gracePeriodSeconds: 0,
         
     | 
| 
      
 325 
     | 
    
         
            +
                kind: 'DeleteOptions',
         
     | 
| 
      
 326 
     | 
    
         
            +
                propagationPolicy: 'Foreground' # Orphan, Foreground, or Background
         
     | 
| 
      
 327 
     | 
    
         
            +
            )
         
     | 
| 
      
 328 
     | 
    
         
            +
            client.delete_deployment(deployment_name, namespace, delete_options: delete_options)
         
     | 
| 
       294 
329 
     | 
    
         
             
            ```
         
     | 
| 
       295 
330 
     | 
    
         | 
| 
       296 
331 
     | 
    
         
             
            #### Create an entity
         
     | 
| 
         @@ -301,21 +336,22 @@ Input parameter - object of type `Service`, `Pod`, `ReplicationController`. 
     | 
|
| 
       301 
336 
     | 
    
         
             
            The below example is for v1
         
     | 
| 
       302 
337 
     | 
    
         | 
| 
       303 
338 
     | 
    
         
             
            ```ruby
         
     | 
| 
       304 
     | 
    
         
            -
            service =  
     | 
| 
      
 339 
     | 
    
         
            +
            service = Kubeclient::Resource.new
         
     | 
| 
       305 
340 
     | 
    
         
             
            service.metadata = {}
         
     | 
| 
       306 
341 
     | 
    
         
             
            service.metadata.name = "redis-master"
         
     | 
| 
       307 
342 
     | 
    
         
             
            service.metadata.namespace = 'staging'
         
     | 
| 
       308 
343 
     | 
    
         
             
            service.spec = {}
         
     | 
| 
       309 
     | 
    
         
            -
            service.spec.ports = [{ 
     | 
| 
       310 
     | 
    
         
            -
             
     | 
| 
       311 
     | 
    
         
            -
             
     | 
| 
      
 344 
     | 
    
         
            +
            service.spec.ports = [{
         
     | 
| 
      
 345 
     | 
    
         
            +
              'port' => 6379,
         
     | 
| 
      
 346 
     | 
    
         
            +
              'targetPort' => 'redis-server'
         
     | 
| 
      
 347 
     | 
    
         
            +
            }]
         
     | 
| 
       312 
348 
     | 
    
         
             
            service.spec.selector = {}
         
     | 
| 
       313 
349 
     | 
    
         
             
            service.spec.selector.name = "redis"
         
     | 
| 
       314 
350 
     | 
    
         
             
            service.spec.selector.role = "master"
         
     | 
| 
       315 
351 
     | 
    
         
             
            service.metadata.labels = {}
         
     | 
| 
       316 
352 
     | 
    
         
             
            service.metadata.labels.app = 'redis'
         
     | 
| 
       317 
353 
     | 
    
         
             
            service.metadata.labels.role = 'slave'
         
     | 
| 
       318 
     | 
    
         
            -
            client.create_service 
     | 
| 
      
 354 
     | 
    
         
            +
            client.create_service(service)
         
     | 
| 
       319 
355 
     | 
    
         
             
            ```
         
     | 
| 
       320 
356 
     | 
    
         | 
| 
       321 
357 
     | 
    
         
             
            #### Update an entity
         
     | 
| 
         @@ -326,7 +362,7 @@ Input parameter - object of type `Pod`, `Service`, `ReplicationController` etc. 
     | 
|
| 
       326 
362 
     | 
    
         
             
            The below example is for v1
         
     | 
| 
       327 
363 
     | 
    
         | 
| 
       328 
364 
     | 
    
         
             
            ```ruby
         
     | 
| 
       329 
     | 
    
         
            -
            client.update_service 
     | 
| 
      
 365 
     | 
    
         
            +
            updated = client.update_service(service1)
         
     | 
| 
       330 
366 
     | 
    
         
             
            ```
         
     | 
| 
       331 
367 
     | 
    
         | 
| 
       332 
368 
     | 
    
         
             
            #### Patch an entity (by name)
         
     | 
| 
         @@ -339,7 +375,7 @@ The PATCH request should include the namespace name, except for nodes and namesp 
     | 
|
| 
       339 
375 
     | 
    
         
             
            The below example is for v1
         
     | 
| 
       340 
376 
     | 
    
         | 
| 
       341 
377 
     | 
    
         
             
            ```ruby
         
     | 
| 
       342 
     | 
    
         
            -
            client.patch_pod 
     | 
| 
      
 378 
     | 
    
         
            +
            patched = client.patch_pod("docker-registry", {metadata: {annotations: {key: 'value'}}}, "default")
         
     | 
| 
       343 
379 
     | 
    
         
             
            ```
         
     | 
| 
       344 
380 
     | 
    
         | 
| 
       345 
381 
     | 
    
         
             
            #### Get all entities of all types : all_entities
         
     | 
| 
         @@ -366,6 +402,8 @@ It is possible to interrupt the watcher from another thread with: 
     | 
|
| 
       366 
402 
     | 
    
         
             
            watcher.finish
         
     | 
| 
       367 
403 
     | 
    
         
             
            ```
         
     | 
| 
       368 
404 
     | 
    
         | 
| 
      
 405 
     | 
    
         
            +
            Pass `as: :raw` to `watch_*` get raw replies.
         
     | 
| 
      
 406 
     | 
    
         
            +
             
     | 
| 
       369 
407 
     | 
    
         
             
            #### Watch events for a particular object
         
     | 
| 
       370 
408 
     | 
    
         
             
            You can use the `field_selector` option as part of the watch methods.
         
     | 
| 
       371 
409 
     | 
    
         | 
| 
         @@ -381,14 +419,14 @@ You can get a complete URL for connecting a kubernetes entity via the proxy. 
     | 
|
| 
       381 
419 
     | 
    
         | 
| 
       382 
420 
     | 
    
         
             
            ```ruby
         
     | 
| 
       383 
421 
     | 
    
         
             
            client.proxy_url('service', 'srvname', 'srvportname', 'ns')
         
     | 
| 
       384 
     | 
    
         
            -
             => "https://localhost.localdomain:8443/api/v1/proxy/namespaces/ns/services/srvname:srvportname"
         
     | 
| 
      
 422 
     | 
    
         
            +
            # => "https://localhost.localdomain:8443/api/v1/proxy/namespaces/ns/services/srvname:srvportname"
         
     | 
| 
       385 
423 
     | 
    
         
             
            ```
         
     | 
| 
       386 
424 
     | 
    
         | 
| 
       387 
425 
     | 
    
         
             
            Note the third parameter, port, is a port name for services and an integer for pods:
         
     | 
| 
       388 
426 
     | 
    
         | 
| 
       389 
427 
     | 
    
         
             
            ```ruby
         
     | 
| 
       390 
428 
     | 
    
         
             
            client.proxy_url('pod', 'podname', 5001, 'ns')
         
     | 
| 
       391 
     | 
    
         
            -
             => "https://localhost.localdomain:8443/api/v1/namespaces/ns/pods/podname:5001/proxy"
         
     | 
| 
      
 429 
     | 
    
         
            +
            # => "https://localhost.localdomain:8443/api/v1/namespaces/ns/pods/podname:5001/proxy"
         
     | 
| 
       392 
430 
     | 
    
         
             
            ```
         
     | 
| 
       393 
431 
     | 
    
         | 
| 
       394 
432 
     | 
    
         
             
            #### Get the logs of a pod
         
     | 
| 
         @@ -397,14 +435,14 @@ namespace where the pod is running: 
     | 
|
| 
       397 
435 
     | 
    
         | 
| 
       398 
436 
     | 
    
         
             
            ```ruby
         
     | 
| 
       399 
437 
     | 
    
         
             
            client.get_pod_log('pod-name', 'default')
         
     | 
| 
       400 
     | 
    
         
            -
             => "Running...\nRunning...\nRunning...\n"
         
     | 
| 
      
 438 
     | 
    
         
            +
            # => "Running...\nRunning...\nRunning...\n"
         
     | 
| 
       401 
439 
     | 
    
         
             
            ```
         
     | 
| 
       402 
440 
     | 
    
         | 
| 
       403 
441 
     | 
    
         
             
            If that pod has more than one container, you must specify the container:
         
     | 
| 
       404 
442 
     | 
    
         | 
| 
       405 
443 
     | 
    
         
             
            ```ruby
         
     | 
| 
       406 
444 
     | 
    
         
             
            client.get_pod_log('pod-name', 'default', container: 'ruby')
         
     | 
| 
       407 
     | 
    
         
            -
             => "..."
         
     | 
| 
      
 445 
     | 
    
         
            +
            # => "..."
         
     | 
| 
       408 
446 
     | 
    
         
             
            ```
         
     | 
| 
       409 
447 
     | 
    
         | 
| 
       410 
448 
     | 
    
         
             
            If a container in a pod terminates, a new container is started, and you want to
         
     | 
| 
         @@ -412,7 +450,7 @@ retrieve the logs of the dead container, you can pass in the `:previous` option: 
     | 
|
| 
       412 
450 
     | 
    
         | 
| 
       413 
451 
     | 
    
         
             
            ```ruby
         
     | 
| 
       414 
452 
     | 
    
         
             
            client.get_pod_log('pod-name', 'default', previous: true)
         
     | 
| 
       415 
     | 
    
         
            -
             => "..."
         
     | 
| 
      
 453 
     | 
    
         
            +
            # => "..."
         
     | 
| 
       416 
454 
     | 
    
         
             
            ```
         
     | 
| 
       417 
455 
     | 
    
         | 
| 
       418 
456 
     | 
    
         
             
            You can also watch the logs of a pod to get a stream of data:
         
     | 
| 
         @@ -430,21 +468,49 @@ Input parameter - template (hash) 
     | 
|
| 
       430 
468 
     | 
    
         
             
            Besides its metadata, the template should include a list of objects to be processed and a list of parameters
         
     | 
| 
       431 
469 
     | 
    
         
             
            to be substituted. Note that for a required parameter that does not provide a generated value, you must supply a value.
         
     | 
| 
       432 
470 
     | 
    
         | 
| 
      
 471 
     | 
    
         
            +
            ##### Note: This functionality is not supported by K8s at this moment. See the following [issue](https://github.com/kubernetes/kubernetes/issues/23896)
         
     | 
| 
      
 472 
     | 
    
         
            +
             
     | 
| 
       433 
473 
     | 
    
         
             
            ```ruby
         
     | 
| 
       434 
474 
     | 
    
         
             
            client.process_template template
         
     | 
| 
       435 
475 
     | 
    
         
             
            ```
         
     | 
| 
       436 
476 
     | 
    
         | 
| 
       437 
477 
     | 
    
         
             
            ## Upgrading
         
     | 
| 
       438 
478 
     | 
    
         | 
| 
      
 479 
     | 
    
         
            +
            See [CHANGELOG.md](CHANGELOG.md) for full changelog.
         
     | 
| 
      
 480 
     | 
    
         
            +
             
     | 
| 
      
 481 
     | 
    
         
            +
            #### past version 3.0
         
     | 
| 
      
 482 
     | 
    
         
            +
             
     | 
| 
      
 483 
     | 
    
         
            +
            Ruby versions < 2.2 are no longer supported
         
     | 
| 
      
 484 
     | 
    
         
            +
             
     | 
| 
      
 485 
     | 
    
         
            +
            Specific entity classes mentioned in [past version 1.2.0](#past_version_1.2.0) have been dropped.
         
     | 
| 
      
 486 
     | 
    
         
            +
            Return values and expected classes are always Kubeclient::Resource.
         
     | 
| 
      
 487 
     | 
    
         
            +
            Checking the type of a resource can be done using:
         
     | 
| 
      
 488 
     | 
    
         
            +
            ```
         
     | 
| 
      
 489 
     | 
    
         
            +
            > pod.kind
         
     | 
| 
      
 490 
     | 
    
         
            +
            => "Pod"
         
     | 
| 
      
 491 
     | 
    
         
            +
            ```
         
     | 
| 
      
 492 
     | 
    
         
            +
             
     | 
| 
      
 493 
     | 
    
         
            +
            update_* delete_* and patch_* now return a RecursiveOpenStruct like the get_* methods
         
     | 
| 
      
 494 
     | 
    
         
            +
             
     | 
| 
      
 495 
     | 
    
         
            +
            The gem raises Kubeclient::HttpError or subclasses now. Catching KubeException still works but is deprecated.
         
     | 
| 
      
 496 
     | 
    
         
            +
             
     | 
| 
      
 497 
     | 
    
         
            +
            `Kubeclient::Config#context` raises KeyError instead of RuntimeError for non-existent context name.
         
     | 
| 
      
 498 
     | 
    
         
            +
             
     | 
| 
      
 499 
     | 
    
         
            +
            <a name="past_version_1.2.0">
         
     | 
| 
      
 500 
     | 
    
         
            +
             
     | 
| 
       439 
501 
     | 
    
         
             
            #### past version 1.2.0
         
     | 
| 
       440 
502 
     | 
    
         
             
            Replace Specific Entity class references:
         
     | 
| 
      
 503 
     | 
    
         
            +
             
     | 
| 
       441 
504 
     | 
    
         
             
            ```ruby
         
     | 
| 
       442 
505 
     | 
    
         
             
            Kubeclient::Service
         
     | 
| 
       443 
506 
     | 
    
         
             
            ```
         
     | 
| 
      
 507 
     | 
    
         
            +
             
     | 
| 
       444 
508 
     | 
    
         
             
            with the generic
         
     | 
| 
      
 509 
     | 
    
         
            +
             
     | 
| 
       445 
510 
     | 
    
         
             
            ```ruby
         
     | 
| 
       446 
511 
     | 
    
         
             
            Kubeclient::Resource.new
         
     | 
| 
       447 
512 
     | 
    
         
             
            ```
         
     | 
| 
      
 513 
     | 
    
         
            +
             
     | 
| 
       448 
514 
     | 
    
         
             
            Where ever possible.
         
     | 
| 
       449 
515 
     | 
    
         | 
| 
       450 
516 
     | 
    
         
             
            ## Contributing
         
     |