fluent-plugin-kubernetes-objects 1.1.9 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +27 -23
- data/VERSION +1 -1
- data/fluent-plugin-kubernetes-objects.gemspec +2 -2
- data/lib/fluent/plugin/in_kubernetes_objects.rb +28 -15
- data/test/fluent/plugin/in_kubernetes_objects_test.rb +26 -2
- data/test/test_helper.rb +21 -0
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ed6573de6d2faa08a127f6254940f109642d86a120f77e01049208718e3ed47
|
4
|
+
data.tar.gz: 4c2b866680f316d56082dee6b217baee5cb52c7eb1f8ee67ceb42be2c6ff8c7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8198ca5056cdad411ce1e7163e06990f03cf7184f84a5932e57896f02bd05bf2d6509bc5220d97c946bb6003e4f992034929f1b53a56925d84dc72a24d99a266
|
7
|
+
data.tar.gz: e8e1b0bad7566e7d075c9ae3035a7337d6c321b5c02616ef809ca828829185c0f939d569cbd48d575aa1ede558a14703c7686edf47210f3126d92d49d1926b89
|
data/Gemfile.lock
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-kubernetes-objects (1.1.
|
4
|
+
fluent-plugin-kubernetes-objects (1.1.12)
|
5
5
|
fluentd (>= 1.9.1)
|
6
|
-
http_parser.rb (= 0.
|
7
|
-
kubeclient (~> 4.
|
6
|
+
http_parser.rb (= 0.8.0)
|
7
|
+
kubeclient (~> 4.9.3)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
addressable (2.8.0)
|
13
13
|
public_suffix (>= 2.0.2, < 5.0)
|
14
|
-
concurrent-ruby (1.1.
|
14
|
+
concurrent-ruby (1.1.10)
|
15
15
|
cool.io (1.7.1)
|
16
16
|
crack (0.4.5)
|
17
17
|
rexml
|
18
18
|
docile (1.4.0)
|
19
19
|
domain_name (0.5.20190701)
|
20
20
|
unf (>= 0.0.5, < 1.0.0)
|
21
|
-
ffi (1.15.
|
21
|
+
ffi (1.15.5)
|
22
22
|
ffi-compiler (1.0.1)
|
23
23
|
ffi (>= 1.0.0)
|
24
24
|
rake
|
25
|
-
fluentd (1.14.
|
25
|
+
fluentd (1.14.6)
|
26
26
|
bundler
|
27
27
|
cool.io (>= 1.4.5, < 2.0.0)
|
28
|
-
http_parser.rb (>= 0.5.1, < 0.
|
28
|
+
http_parser.rb (>= 0.5.1, < 0.9.0)
|
29
29
|
msgpack (>= 1.3.1, < 2.0.0)
|
30
|
-
serverengine (>= 2.2.
|
30
|
+
serverengine (>= 2.2.5, < 3.0.0)
|
31
31
|
sigdump (~> 0.2.2)
|
32
32
|
strptime (>= 0.2.4, < 1.0.0)
|
33
33
|
tzinfo (>= 1.0, < 3.0)
|
@@ -46,19 +46,23 @@ GEM
|
|
46
46
|
http-form_data (2.3.0)
|
47
47
|
http-parser (1.2.3)
|
48
48
|
ffi-compiler (>= 1.0, < 2.0)
|
49
|
-
http_parser.rb (0.
|
50
|
-
|
49
|
+
http_parser.rb (0.8.0)
|
50
|
+
jsonpath (1.1.2)
|
51
|
+
multi_json
|
52
|
+
kubeclient (4.9.3)
|
51
53
|
http (>= 3.0, < 5.0)
|
52
|
-
|
54
|
+
jsonpath (~> 1.0)
|
55
|
+
recursive-open-struct (~> 1.1, >= 1.1.1)
|
53
56
|
rest-client (~> 2.0)
|
54
|
-
mime-types (3.
|
57
|
+
mime-types (3.4.1)
|
55
58
|
mime-types-data (~> 3.2015)
|
56
|
-
mime-types-data (3.
|
57
|
-
minitest (5.
|
58
|
-
msgpack (1.
|
59
|
+
mime-types-data (3.2022.0105)
|
60
|
+
minitest (5.15.0)
|
61
|
+
msgpack (1.5.1)
|
62
|
+
multi_json (1.15.0)
|
59
63
|
netrc (0.11.0)
|
60
64
|
power_assert (2.0.1)
|
61
|
-
public_suffix (4.0.
|
65
|
+
public_suffix (4.0.7)
|
62
66
|
rake (13.0.6)
|
63
67
|
recursive-open-struct (1.1.3)
|
64
68
|
rest-client (2.1.0)
|
@@ -67,7 +71,7 @@ GEM
|
|
67
71
|
mime-types (>= 1.16, < 4.0)
|
68
72
|
netrc (~> 0.8)
|
69
73
|
rexml (3.2.5)
|
70
|
-
serverengine (2.2.
|
74
|
+
serverengine (2.2.5)
|
71
75
|
sigdump (~> 0.2.2)
|
72
76
|
sigdump (0.2.4)
|
73
77
|
simplecov (0.21.2)
|
@@ -75,23 +79,23 @@ GEM
|
|
75
79
|
simplecov-html (~> 0.11)
|
76
80
|
simplecov_json_formatter (~> 0.1)
|
77
81
|
simplecov-html (0.12.3)
|
78
|
-
simplecov_json_formatter (0.1.
|
82
|
+
simplecov_json_formatter (0.1.4)
|
79
83
|
strptime (0.2.5)
|
80
|
-
test-unit (3.5.
|
84
|
+
test-unit (3.5.3)
|
81
85
|
power_assert
|
82
86
|
tzinfo (2.0.4)
|
83
87
|
concurrent-ruby (~> 1.0)
|
84
|
-
tzinfo-data (1.
|
88
|
+
tzinfo-data (1.2022.1)
|
85
89
|
tzinfo (>= 1.0.0)
|
86
90
|
unf (0.1.4)
|
87
91
|
unf_ext
|
88
|
-
unf_ext (0.0.8)
|
92
|
+
unf_ext (0.0.8.1)
|
89
93
|
webmock (3.14.0)
|
90
94
|
addressable (>= 2.8.0)
|
91
95
|
crack (>= 0.3.2)
|
92
96
|
hashdiff (>= 0.4.0, < 2.0.0)
|
93
97
|
webrick (1.7.0)
|
94
|
-
yajl-ruby (1.4.
|
98
|
+
yajl-ruby (1.4.2)
|
95
99
|
|
96
100
|
PLATFORMS
|
97
101
|
ruby
|
@@ -106,4 +110,4 @@ DEPENDENCIES
|
|
106
110
|
webmock (~> 3.5)
|
107
111
|
|
108
112
|
BUNDLED WITH
|
109
|
-
2.
|
113
|
+
2.3.12
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.12
|
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.required_ruby_version = '>= 2.3.0'
|
24
24
|
spec.add_runtime_dependency 'fluentd', '>= 1.9.1'
|
25
|
-
spec.add_runtime_dependency 'kubeclient', '~> 4.
|
26
|
-
spec.add_runtime_dependency 'http_parser.rb', '= 0.
|
25
|
+
spec.add_runtime_dependency 'kubeclient', '~> 4.9.3'
|
26
|
+
spec.add_runtime_dependency 'http_parser.rb', '= 0.8.0'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler', '~> 2.0'
|
29
29
|
spec.add_development_dependency 'minitest', '~> 5.11'
|
@@ -20,6 +20,9 @@ module Fluent::Plugin
|
|
20
20
|
desc 'Kubernetes API version.'
|
21
21
|
config_param :api_version, :string, default: 'v1'
|
22
22
|
|
23
|
+
desc 'Kubernetes API endpoint.'
|
24
|
+
config_param :api_endpoint, :string, default: 'api'
|
25
|
+
|
23
26
|
desc 'Path to the certificate file for this client.'
|
24
27
|
config_param :client_cert, :string, default: nil
|
25
28
|
|
@@ -139,7 +142,7 @@ module Fluent::Plugin
|
|
139
142
|
env_host = ENV['KUBERNETES_SERVICE_HOST']
|
140
143
|
env_port = ENV['KUBERNETES_SERVICE_PORT']
|
141
144
|
if env_host && env_port
|
142
|
-
@kubernetes_url = "https://#{env_host}:#{env_port}/#{@
|
145
|
+
@kubernetes_url = "https://#{env_host}:#{env_port}/#{@api_endpoint.delete_prefix('/')}"
|
143
146
|
end
|
144
147
|
end
|
145
148
|
|
@@ -200,7 +203,12 @@ module Fluent::Plugin
|
|
200
203
|
tag = generate_tag resource_name
|
201
204
|
while thread_current_running?
|
202
205
|
log.debug "Going to pull #{resource_name}"
|
203
|
-
|
206
|
+
begin
|
207
|
+
response = @client.public_send "get_#{resource_name}", options
|
208
|
+
rescue Kubeclient::ResourceNotFoundError, NoMethodError
|
209
|
+
log.error "resource '#{resource_name}' not found. Stopped pulling it"
|
210
|
+
break
|
211
|
+
end
|
204
212
|
now = Fluent::Engine.now
|
205
213
|
es = Fluent::MultiEventStream.new
|
206
214
|
|
@@ -243,22 +251,27 @@ module Fluent::Plugin
|
|
243
251
|
|
244
252
|
thread_create :"watch_#{resource_name}" do
|
245
253
|
while thread_current_running?
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
254
|
+
begin
|
255
|
+
@client.public_send("watch_#{resource_name}", options).tap do |watcher|
|
256
|
+
tag = generate_tag "#{resource_name}"
|
257
|
+
begin
|
258
|
+
watcher.each do |entity|
|
259
|
+
begin
|
260
|
+
entity = JSON.parse(entity)
|
261
|
+
router.emit tag, Fluent::Engine.now, entity
|
262
|
+
options[:resource_version] = entity['object']['metadata']['resourceVersion']
|
263
|
+
@storage.put resource_name, entity['object']['metadata']['resourceVersion']
|
264
|
+
rescue => e
|
265
|
+
log.info "Got exception #{e} parsing entity #{entity}. Resetting watcher."
|
266
|
+
end
|
257
267
|
end
|
268
|
+
rescue => e
|
269
|
+
log.info "Got exception #{e}. Resetting watcher."
|
258
270
|
end
|
259
|
-
rescue => e
|
260
|
-
log.info "Got exception #{e}. Resetting watcher."
|
261
271
|
end
|
272
|
+
rescue Kubeclient::ResourceNotFoundError, NoMethodError
|
273
|
+
log.error "resource '#{resource_name}' not found. Stopped watching it"
|
274
|
+
break
|
262
275
|
end
|
263
276
|
end
|
264
277
|
end
|
@@ -57,8 +57,9 @@ describe Fluent::Plugin::KubernetesObjectsInput do
|
|
57
57
|
puts 'Test: should use pick the right path'
|
58
58
|
ENV['KUBERNETES_SERVICE_HOST'] = k8s_host
|
59
59
|
ENV['KUBERNETES_SERVICE_PORT'] = k8s_port
|
60
|
-
expect(create_input_driver(<<~CONF).instance.kubernetes_url).must_equal k8s_url('apis')
|
61
|
-
|
60
|
+
expect(create_input_driver(<<~CONF).instance.kubernetes_url).must_equal k8s_url('apis/apps')
|
61
|
+
api_endpoint apis/apps
|
62
|
+
api_version v1
|
62
63
|
<pull>
|
63
64
|
resource_name deployments
|
64
65
|
</pull>
|
@@ -144,5 +145,28 @@ describe Fluent::Plugin::KubernetesObjectsInput do
|
|
144
145
|
f.unlink
|
145
146
|
end
|
146
147
|
end
|
148
|
+
it "checks for invalid pull request" do
|
149
|
+
d = create_input_driver(<<~CONF)
|
150
|
+
kubernetes_url #{k8s_url}
|
151
|
+
<pull>
|
152
|
+
resource_name fakeResource
|
153
|
+
</pull>
|
154
|
+
CONF
|
155
|
+
|
156
|
+
d.run expect_emits: 0, timeout: 3
|
157
|
+
|
158
|
+
expect(d.logs.any? { |log| log.include? "resource 'fakeResource' not found." }).must_equal(true)
|
159
|
+
end
|
160
|
+
it "checks for invalid watch request" do
|
161
|
+
d = create_input_driver(<<~CONF)
|
162
|
+
kubernetes_url #{k8s_url}
|
163
|
+
<watch>
|
164
|
+
resource_name fakeResource
|
165
|
+
</watch>
|
166
|
+
CONF
|
167
|
+
|
168
|
+
d.run expect_emits: 0, timeout: 3
|
169
|
+
expect(d.logs.any? { |log| log.include? "resource 'fakeResource' not found." }).must_equal(true)
|
170
|
+
end
|
147
171
|
end
|
148
172
|
end
|
data/test/test_helper.rb
CHANGED
@@ -54,6 +54,9 @@ module PluginTestHelper
|
|
54
54
|
stub_k8s_nodes
|
55
55
|
stub_k8s_pods
|
56
56
|
stub_k8s_events
|
57
|
+
stub_k8s_apps
|
58
|
+
stub_k8s_apps_v1
|
59
|
+
stub_k8s_apps_v1_namespace
|
57
60
|
end
|
58
61
|
|
59
62
|
def stub_k8s_api
|
@@ -68,6 +71,24 @@ module PluginTestHelper
|
|
68
71
|
end.close
|
69
72
|
end
|
70
73
|
|
74
|
+
def stub_k8s_apps
|
75
|
+
File.open(File.expand_path('apps.json', __dir__)).tap do |f|
|
76
|
+
stub_request(:get, k8s_url('apis/apps')).to_return(body: f.read)
|
77
|
+
end.close
|
78
|
+
end
|
79
|
+
|
80
|
+
def stub_k8s_apps_v1
|
81
|
+
File.open(File.expand_path('apps-v1.json', __dir__)).tap do |f|
|
82
|
+
stub_request(:get, k8s_url('apis/apps/v1')).to_return(body: f.read)
|
83
|
+
end.close
|
84
|
+
end
|
85
|
+
|
86
|
+
def stub_k8s_apps_v1_namespace
|
87
|
+
File.open(File.expand_path('apps-v1-namespace.json', __dir__)).tap do |f|
|
88
|
+
stub_request(:get, k8s_url('apis/apps')).to_return(body: f.read)
|
89
|
+
end.close
|
90
|
+
end
|
91
|
+
|
71
92
|
def stub_k8s_v1
|
72
93
|
File.open(File.expand_path('v1.json', __dir__)).tap do |f|
|
73
94
|
stub_request(:get, "#{k8s_url}/v1").to_return(body: f.read)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-kubernetes-objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Splunk Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
33
|
+
version: 4.9.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 4.
|
40
|
+
version: 4.9.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: http_parser.rb
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.8.0
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.8.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,12 +172,12 @@ signing_key:
|
|
172
172
|
specification_version: 4
|
173
173
|
summary: Fluentd Plugin for Kubernetes Objects.
|
174
174
|
test_files:
|
175
|
-
- test/test_helper.rb
|
176
|
-
- test/lib/no_webmock/http_lib_adapters/httpclient_adapter.rb
|
177
175
|
- test/lib/no_webmock/http_lib_adapters/manticore_adapter.rb
|
178
|
-
- test/lib/no_webmock/http_lib_adapters/
|
179
|
-
- test/lib/no_webmock/http_lib_adapters/
|
176
|
+
- test/lib/no_webmock/http_lib_adapters/httpclient_adapter.rb
|
177
|
+
- test/lib/no_webmock/http_lib_adapters/patron_adapter.rb
|
180
178
|
- test/lib/no_webmock/http_lib_adapters/excon_adapter.rb
|
179
|
+
- test/lib/no_webmock/http_lib_adapters/em_http_request_adapter.rb
|
180
|
+
- test/lib/no_webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
|
181
181
|
- test/lib/no_webmock/http_lib_adapters/curb_adapter.rb
|
182
|
-
- test/
|
182
|
+
- test/test_helper.rb
|
183
183
|
- test/fluent/plugin/in_kubernetes_objects_test.rb
|