lib/fluent/plugin/in_kubernetes_objects.rb in fluent-plugin-kubernetes-objects-1.2.0 vs lib/fluent/plugin/in_kubernetes_objects.rb in fluent-plugin-kubernetes-objects-1.2.1
- old
+ new
@@ -1,9 +1,10 @@
# frozen_string_literal: true
require 'fluent/plugin/input'
require 'kubeclient'
+require 'resolv'
module Fluent::Plugin
class KubernetesObjectsInput < Fluent::Plugin::Input
VERSION = '1.1.2'.freeze
@@ -138,9 +139,10 @@
def initialize_client
# mostly borrowed from Fluentd Kubernetes Metadata Filter Plugin
if @kubernetes_url.nil?
# Use Kubernetes default service account if we're in a pod.
env_host = ENV['KUBERNETES_SERVICE_HOST']
+ env_host = "[#{env_host}]" if env_host =~ Resolv::IPv6::Regex
env_port = ENV['KUBERNETES_SERVICE_PORT']
if env_host && env_port
@kubernetes_url = "https://#{env_host}:#{env_port}/#{@api_endpoint.delete_prefix('/')}"
end
end