k8s-client 0.10.2 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/k8s-client.gemspec +3 -3
- data/lib/k8s/client/version.rb +1 -1
- data/lib/k8s/client.rb +8 -2
- data/lib/k8s/config.rb +0 -1
- data/lib/k8s/stack.rb +6 -1
- data/lib/k8s/transport.rb +3 -2
- data/lib/k8s/util.rb +1 -1
- metadata +9 -11
- data/lib/k8s/foo.yaml +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 781a19c46761e39d8b647885955a8e947c993d39448b441008c6abef723cd68e
|
4
|
+
data.tar.gz: 0fca7c3e1b3fb2f6fff59036ce1aa21b7659a3d168efe70af840e5c78c98997c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c2ff77f3c91c3107dd77f984af8411036ce5181bbe329d475e446e6d3274eed1d93444e128e71bc0f543b2b2720fbc34828b9739af97302b678b8137d216ad0
|
7
|
+
data.tar.gz: 7ad27a638df184987b658a3d2f9f15f4b9051942d4f2a96ff9b232a8900f64614ca8edd277c4e49398b2d83cbaf26567d9220a936c00775296b89339db25e94a
|
data/k8s-client.gemspec
CHANGED
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
spec.required_ruby_version = '~> 2.4'
|
25
25
|
|
26
|
-
spec.add_runtime_dependency "excon", "~> 0.
|
26
|
+
spec.add_runtime_dependency "excon", "~> 0.66"
|
27
27
|
spec.add_runtime_dependency "dry-struct", "~> 0.5.0"
|
28
28
|
spec.add_runtime_dependency "dry-types", "~> 0.13.0"
|
29
29
|
spec.add_runtime_dependency "recursive-open-struct", "~> 1.1.0"
|
30
|
-
spec.add_runtime_dependency 'hashdiff', '~> 0.
|
30
|
+
spec.add_runtime_dependency 'hashdiff', '~> 1.0.0'
|
31
31
|
spec.add_runtime_dependency 'jsonpath', '~> 0.9.5'
|
32
32
|
spec.add_runtime_dependency 'yajl-ruby', '~> 1.4.0'
|
33
33
|
spec.add_runtime_dependency "yaml-safe_load_stream", "~> 0.1"
|
@@ -35,6 +35,6 @@ Gem::Specification.new do |spec|
|
|
35
35
|
spec.add_development_dependency "bundler", ">= 1.17", "< 3.0"
|
36
36
|
spec.add_development_dependency "rake", "~> 10.0"
|
37
37
|
spec.add_development_dependency "rspec", "~> 3.7"
|
38
|
-
spec.add_development_dependency "webmock", "~> 3.
|
38
|
+
spec.add_development_dependency "webmock", "~> 3.6.2"
|
39
39
|
spec.add_development_dependency "rubocop", "~> 0.59"
|
40
40
|
end
|
data/lib/k8s/client/version.rb
CHANGED
data/lib/k8s/client.rb
CHANGED
@@ -82,8 +82,14 @@ module K8s
|
|
82
82
|
configuration = K8s::Config.build(server: ENV['KUBE_SERVER'], ca: ENV['KUBE_CA'], auth_token: token)
|
83
83
|
elsif !ENV['KUBECONFIG'].to_s.empty?
|
84
84
|
configuration = K8s::Config.from_kubeconfig_env(ENV['KUBECONFIG'])
|
85
|
-
|
86
|
-
|
85
|
+
else
|
86
|
+
found_config = [
|
87
|
+
File.join(Dir.home, '.kube', 'config'),
|
88
|
+
'/etc/kubernetes/admin.conf',
|
89
|
+
'/etc/kubernetes/kubelet.conf'
|
90
|
+
].find { |f| File.exist?(f) && File.readable?(f) }
|
91
|
+
|
92
|
+
configuration = K8s::Config.load_file(found_config) if found_config
|
87
93
|
end
|
88
94
|
|
89
95
|
if configuration
|
data/lib/k8s/config.rb
CHANGED
data/lib/k8s/stack.rb
CHANGED
@@ -129,7 +129,10 @@ module K8s
|
|
129
129
|
# @param resource [K8s::Resource]
|
130
130
|
# @return [Boolean]
|
131
131
|
def keep_resource?(resource)
|
132
|
-
@keep_resources["#{resource.kind}:#{resource.metadata.name}@#{resource.metadata.namespace}"]
|
132
|
+
keep_annotation = @keep_resources["#{resource.kind}:#{resource.metadata.name}@#{resource.metadata.namespace}"]
|
133
|
+
return false unless keep_annotation
|
134
|
+
|
135
|
+
keep_annotation == resource.metadata&.annotations.dig(@checksum_annotation)
|
133
136
|
end
|
134
137
|
|
135
138
|
# Delete all stack resources that were not applied
|
@@ -157,6 +160,8 @@ module K8s
|
|
157
160
|
|
158
161
|
if resource_label != name
|
159
162
|
# apiserver did not respect labelSelector
|
163
|
+
elsif resource.metadata&.ownerReferences && !resource.metadata.ownerReferences.empty?
|
164
|
+
logger.info "Server resource #{resource.apiVersion}:#{resource.apiKind}/#{resource.metadata.name} in namespace #{resource.metadata.namespace} has ownerReferences and will be kept"
|
160
165
|
elsif keep_resources && keep_resource?(resource)
|
161
166
|
# resource is up-to-date
|
162
167
|
else
|
data/lib/k8s/transport.rb
CHANGED
@@ -131,7 +131,7 @@ module K8s
|
|
131
131
|
raise(K8s::Error::Configuration, "in_cluster_config failed: KUBERNETES_SERVICE_HOST environment not set") if host.empty?
|
132
132
|
|
133
133
|
port = ENV['KUBERNETES_SERVICE_PORT_HTTPS'].to_s
|
134
|
-
raise(K8s::Error::Configuration, "in_cluster_config failed:
|
134
|
+
raise(K8s::Error::Configuration, "in_cluster_config failed: KUBERNETES_SERVICE_PORT_HTTPS environment not set") if port.empty?
|
135
135
|
|
136
136
|
new(
|
137
137
|
"https://#{host}:#{port}",
|
@@ -180,7 +180,8 @@ module K8s
|
|
180
180
|
# @param parts [Array<String>] join path parts together to build the full URL
|
181
181
|
# @return [String]
|
182
182
|
def path(*parts)
|
183
|
-
File.join(
|
183
|
+
joined_parts = File.join(*parts)
|
184
|
+
joined_parts.start_with?(path_prefix) ? joined_parts : File.join(path_prefix, joined_parts)
|
184
185
|
end
|
185
186
|
|
186
187
|
# @param request_object [Object] include request body using to_json
|
data/lib/k8s/util.rb
CHANGED
@@ -98,7 +98,7 @@ module K8s
|
|
98
98
|
# @param patch_to [Hash] Hash to compute patches against
|
99
99
|
# @param patch_from [Hash] New Hash to compute patches "from"
|
100
100
|
def self.json_patch(patch_to, patch_from)
|
101
|
-
diffs =
|
101
|
+
diffs = Hashdiff.diff(patch_to, patch_from, array_path: true)
|
102
102
|
ops = []
|
103
103
|
# Each diff is like:
|
104
104
|
# ["+", ["spec", "selector", "food"], "kebab"]
|
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.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kontena, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.66'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.66'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: dry-struct
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 1.0.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 1.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: jsonpath
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,14 +176,14 @@ dependencies:
|
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version: 3.
|
179
|
+
version: 3.6.2
|
180
180
|
type: :development
|
181
181
|
prerelease: false
|
182
182
|
version_requirements: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
184
|
- - "~>"
|
185
185
|
- !ruby/object:Gem::Version
|
186
|
-
version: 3.
|
186
|
+
version: 3.6.2
|
187
187
|
- !ruby/object:Gem::Dependency
|
188
188
|
name: rubocop
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
@@ -233,7 +233,6 @@ files:
|
|
233
233
|
- lib/k8s/client/version.rb
|
234
234
|
- lib/k8s/config.rb
|
235
235
|
- lib/k8s/error.rb
|
236
|
-
- lib/k8s/foo.yaml
|
237
236
|
- lib/k8s/logging.rb
|
238
237
|
- lib/k8s/resource.rb
|
239
238
|
- lib/k8s/resource_client.rb
|
@@ -259,8 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
258
|
- !ruby/object:Gem::Version
|
260
259
|
version: '0'
|
261
260
|
requirements: []
|
262
|
-
|
263
|
-
rubygems_version: 2.6.14.4
|
261
|
+
rubygems_version: 3.0.3
|
264
262
|
signing_key:
|
265
263
|
specification_version: 4
|
266
264
|
summary: Kubernetes client library
|
data/lib/k8s/foo.yaml
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
apiVersion: v1
|
2
|
-
kind: Pod
|
3
|
-
metadata:
|
4
|
-
name: myapp
|
5
|
-
spec:
|
6
|
-
containers:
|
7
|
-
- name: myapp
|
8
|
-
image: docker.io/nginx/:1-alpine
|
9
|
-
resources:
|
10
|
-
limits:
|
11
|
-
memory: "10Mi"
|
12
|
-
cpu: "100m"
|
13
|
-
|
14
|
-
---
|
15
|
-
|
16
|
-
apiVersion: v1
|
17
|
-
kind: Pod
|
18
|
-
metadata:
|
19
|
-
name: myapp
|
20
|
-
labels: {}
|
21
|
-
spec:
|
22
|
-
containers:
|
23
|
-
- name: myapp
|
24
|
-
image: docker.io/nginx/:1-alpine
|
25
|
-
resources:
|
26
|
-
limits:
|
27
|
-
memory: "10Mi"
|
28
|
-
cpu: "100m"
|
29
|
-
ports: []
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|