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 +4 -4
- data/README.md +8 -0
- data/bin/k8s-client +12 -6
- data/lib/k8s/client.rb +4 -2
- data/lib/k8s/client/version.rb +1 -1
- data/lib/k8s/resource.rb +2 -1
- data/lib/k8s/stack.rb +1 -1
- data/lib/k8s/transport.rb +5 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f007ab73089515a1766b43c947c33c8c3e8dfd902b19ce47aa6e5b3a87892536
|
4
|
+
data.tar.gz: 4d3b616e388ae5334966588ea93828f3efb6dac602d4a0f25906063d4360fc82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
72
|
+
options.server = server
|
73
73
|
end
|
74
|
-
parser.on('--insecure-skip-tls-verify') do
|
75
|
-
options.insecure_skip_tls_verify =
|
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
|
-
|
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
|
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]
|
data/lib/k8s/client/version.rb
CHANGED
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
|
-
|
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=#{
|
61
|
+
logger.info "Using config with server=#{server}"
|
60
62
|
|
61
|
-
new(
|
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.
|
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-
|
11
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|