55# KAIL_PATH - path to kail executable, defaults to "kail"
66# KUBESEAL_PATH - path to kubeseal executable, defaults to "kubeseal"
77# YQ_PATH - path to yq executable, defaults to "yq"
8+ # K_LISTEN_ON_ALL_INTERFACES - if set to "true", listen on 0.0.0.0 for local forwards
89
910require "date" # to protect against YAML bug present in certain psych versions: https://github.com/ruby/psych/pull/695
1011require "yaml"
@@ -605,12 +606,19 @@ def kibana
605606 # kibana.k8s.elastic.co/name=mynewsdesk-funnel
606607
607608 require "socket"
609+ if ENV [ "K_LISTEN_ON_ALL_INTERFACES" ] == "true"
610+ kubectl_address_flag = " --address 0.0.0.0"
611+ hostname = Socket . gethostname
612+ else
613+ kubectl_address_flag = ""
614+ hostname = "localhost"
615+ end
608616
609617 5601 . upto ( 5700 ) do |port |
610618 # If we can connect to the port another kibana is already active and we skip to the next port
611619 next if TCPSocket . new ( "127.0.0.1" , port ) . close . nil? rescue false # rubocop:disable Style/RescueModifier
612620
613- puts "Making kibana accessible at: http://localhost :#{ port } /app/monitoring#/overview"
621+ puts "Making kibana accessible at: http://#{ hostname } :#{ port } /app/monitoring#/overview"
614622 if system "which pbcopy > /dev/null 2>&1"
615623 puts "Storing kibana password in clipboard..."
616624 puts ""
@@ -623,7 +631,7 @@ def kibana
623631 puts "Login with username 'elastic' and paste the password '#{ password } '"
624632 end
625633 puts ""
626- kubectl "port-forward service/#{ application } -kb-http #{ port } :5601"
634+ kubectl "port-forward service/#{ application } -kb-http #{ port } :5601#{ kubectl_address_flag } "
627635 end
628636end
629637
0 commit comments