Method: Fluent::KubernetesMetadataInput#watch_resource

Defined in:
lib/fluent/plugin/in_kubernetes_metadata.rb

#watch_resourceObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/fluent/plugin/in_kubernetes_metadata.rb', line 146

def watch_resource
  loop do
    begin
      resource_version = @client.send(@get_res_string).resourceVersion
      watcher          = @client.watch_entities(@resource, options = {resource_version: resource_version})
    rescue Exception => e
      raise Fluent::ConfigError, "Exception encountered fetching metadata from Kubernetes API endpoint: #{e.message}"
    end


    begin
      watcher.each do |notice|
        time = Engine.now
        emit_event(notice.object, time, notice.type)
      end
      log.trace "Exited resource watcher"
    rescue
      log.error "Unexpected error in resource watcher", :error=>$!.to_s
      log.error_backtrace
    end
  end
end