Method: Kubeclient::ClientMixin#watch_pod_log

Defined in:
lib/kubeclient/common.rb

#watch_pod_log(pod_name, namespace, container: nil, &block) ⇒ Object



482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
# File 'lib/kubeclient/common.rb', line 482

def watch_pod_log(pod_name, namespace, container: nil, &block)
  # Adding the "follow=true" query param tells the Kubernetes API to keep
  # the connection open and stream updates to the log.
  params = { follow: true }
  params[:container] = container if container

  ns = build_namespace_prefix(namespace)

  uri = @api_endpoint.dup
  uri.path += "/#{@api_version}/#{ns}pods/#{pod_name}/log"
  uri.query = URI.encode_www_form(params)

  watcher = Kubeclient::Common::WatchStream.new(
    uri, http_options(uri), formatter: ->(value) { value }
  )
  return_or_yield_to_watcher(watcher, &block)
end