k8s-client 0.3.2 → 0.3.3

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: 0c52ed78175ae8e13a19fdc6a8e0140bd638f49e7120c7b8227bbfb23086487a
4
- data.tar.gz: 43224378fdcb6d08636e346d8c79090e572957cf298d72b2fb6be1bb4a13c948
3
+ metadata.gz: f007ab73089515a1766b43c947c33c8c3e8dfd902b19ce47aa6e5b3a87892536
4
+ data.tar.gz: 4d3b616e388ae5334966588ea93828f3efb6dac602d4a0f25906063d4360fc82
5
5
  SHA512:
6
- metadata.gz: fb131b63d5a7ea82c0afbb0a32543ee60b13156c13f13f62b23ff9260491c26561e863c76495600f2db1ccf1cd51a956f9acc195d494a97f9e7e66b1764209cc
7
- data.tar.gz: 71d19732db165ac68306d031981f95b4d1dda404ada3e6a2dca146b42c2b7bb427432e74c2192d673010d92668eefb046efd22782c9ba7f9e460cd685c4c2e9a
6
+ metadata.gz: e13b44376050184651c88518d752062657bb2c1ac820af787090d603411c0ae6a86ae0e9b069dc79ed1a9de3ab07dfbc5e93ae5e6c847b65c16aa1dacf30ae45
7
+ data.tar.gz: 6344b7a1809baabb31ecd747711171928ae2a0102183732c46029285f773282e82c314e6fb22cbacecaaa281aa331a2eafb3807cb2951ff0ff628a4c024778f2
data/README.md CHANGED
@@ -63,6 +63,14 @@ The keyword options are [Excon](https://github.com/excon/excon/) options.
63
63
  client = K8s::Client.config(K8s::Config.load_file('~/.kube/config'))
64
64
  ```
65
65
 
66
+ ##### With overrides
67
+
68
+ ```ruby
69
+ client = K8s::Client.config(K8s::Config.load_file('~/.kube/config'),
70
+ server: 'http://localhost:8001',
71
+ )
72
+ ```
73
+
66
74
  #### In-cluster client from pod envs/secrets
67
75
 
68
76
  ```ruby
data/bin/k8s-client CHANGED
@@ -69,10 +69,10 @@ parser = OptionParser.new do |parser|
69
69
  options.config = K8s::Config.load_file(path)
70
70
  end
71
71
  parser.on('--server=SERVER') do |server|
72
- options.server = URI(server)
72
+ options.server = server
73
73
  end
74
- parser.on('--insecure-skip-tls-verify') do
75
- options.insecure_skip_tls_verify = true
74
+ parser.on('--insecure-skip-tls-verify', TrueClass) do |bool|
75
+ options.insecure_skip_tls_verify = bool
76
76
  end
77
77
  parser.on('--prefetch-resources', TrueClass) do |bool|
78
78
  options.prefetch_resources = bool
@@ -160,11 +160,17 @@ end
160
160
  parser.parse!
161
161
 
162
162
  if options.config
163
- client = K8s::Client.config(options.config)
163
+ overrides = {}
164
+ overrides[:ssl_verify_peer] = false if options.insecure_skip_tls_verify
165
+
166
+ client = K8s::Client.config(options.config,
167
+ server: options.server,
168
+ **overrides
169
+ )
164
170
  elsif options.in_cluster_config
165
171
  client = K8s::Client.in_cluster_config
166
172
  else
167
- client = K8s.client(options.server.to_s,
173
+ client = K8s.client(options.server,
168
174
  ssl_verify_peer: !options.insecure_skip_tls_verify,
169
175
  )
170
176
  end
@@ -178,7 +184,7 @@ end
178
184
  if options.list_resource_kinds
179
185
  client.resources.sort_by{|r| r.kind}.each do |resource_client|
180
186
  next if resource_client.subresource?
181
-
187
+
182
188
  puts "#{resource_client.kind} => #{resource_client.api_version} #{resource_client.name}"
183
189
  end
184
190
  end
data/lib/k8s/client.rb CHANGED
@@ -10,8 +10,10 @@ module K8s
10
10
  class Client
11
11
  # @param config [Phraos::Kube::Config]
12
12
  # @return [K8s::Client]
13
- def self.config(config)
14
- new(Transport.config(config))
13
+ def self.config(config, namespace: nil, **options)
14
+ new(Transport.config(config, **options),
15
+ namespace: namespace,
16
+ )
15
17
  end
16
18
 
17
19
  # @return [K8s::Client]
@@ -1,5 +1,5 @@
1
1
  module K8s
2
2
  class Client
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
data/lib/k8s/resource.rb CHANGED
@@ -25,7 +25,8 @@ module K8s
25
25
  stat = File.stat(path)
26
26
 
27
27
  if stat.directory?
28
- Dir.glob("#{path}/*.{yml,yaml}").map{|path| self.load_files(path) }.flatten
28
+ # recurse
29
+ Dir.glob("#{path}/*.{yml,yaml}").sort.map{|path| self.from_files(path) }.flatten
29
30
  else
30
31
  ::YAML.load_stream(File.read(path), path).map{|doc| new(doc) }
31
32
  end
data/lib/k8s/stack.rb CHANGED
@@ -38,7 +38,7 @@ module K8s
38
38
 
39
39
  attr_reader :name, :resources
40
40
 
41
- def initialize(name, resources = [], debug: false, label: LABEL, checksum_annotation: CHECKSUM_ANNOTATION)
41
+ def initialize(name, resources = [], debug: false, label: self.class::LABEL, checksum_annotation: self.class::CHECKSUM_ANNOTATION)
42
42
  @name = name
43
43
  @resources = resources
44
44
  @keep_resources = {}
data/lib/k8s/transport.rb CHANGED
@@ -20,9 +20,11 @@ module K8s
20
20
  #
21
21
  # @param config [Phraos::Kube::Config]
22
22
  # @return [K8s::Transport]
23
- def self.config(config)
23
+ def self.config(config, server: nil, **overrides)
24
24
  options = {}
25
25
 
26
+ server ||= config.cluster.server
27
+
26
28
  if config.cluster.insecure_skip_tls_verify
27
29
  logger.debug "Using config with .cluster.insecure_skip_tls_verify"
28
30
 
@@ -56,9 +58,9 @@ module K8s
56
58
  options[:client_key_data] = Base64.decode64(key_data)
57
59
  end
58
60
 
59
- logger.info "Using config with server=#{config.cluster.server}"
61
+ logger.info "Using config with server=#{server}"
60
62
 
61
- new(config.cluster.server, **options)
63
+ new(server, **options, **overrides)
62
64
  end
63
65
 
64
66
  # In-cluster config within a kube pod, using the kubernetes service envs and serviceaccount secrets
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k8s-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-16 00:00:00.000000000 Z
11
+ date: 2018-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon