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"
@@ -594,12 +595,19 @@ def kibana
594595 # kibana.k8s.elastic.co/name=mynewsdesk-funnel
595596
596597 require "socket"
598+ if ENV [ "K_LISTEN_ON_ALL_INTERFACES" ] == "true"
599+ kubectl_address_flag = " --address 0.0.0.0"
600+ hostname = Socket . gethostname
601+ else
602+ kubectl_address_flag = ""
603+ hostname = "localhost"
604+ end
597605
598606 5601 . upto ( 5700 ) do |port |
599607 # If we can connect to the port another kibana is already active and we skip to the next port
600608 next if TCPSocket . new ( "127.0.0.1" , port ) . close . nil? rescue false # rubocop:disable Style/RescueModifier
601609
602- puts "Making kibana accessible at: http://localhost :#{ port } /app/monitoring#/overview"
610+ puts "Making kibana accessible at: http://#{ hostname } :#{ port } /app/monitoring#/overview"
603611 if system "which pbcopy > /dev/null 2>&1"
604612 puts "Storing kibana password in clipboard..."
605613 puts ""
@@ -612,7 +620,7 @@ def kibana
612620 puts "Login with username 'elastic' and paste the password '#{ password } '"
613621 end
614622 puts ""
615- kubectl "port-forward service/#{ application } -kb-http #{ port } :5601"
623+ kubectl "port-forward service/#{ application } -kb-http #{ port } :5601#{ kubectl_address_flag } "
616624 end
617625end
618626
0 commit comments