<p>On Ubuntu 18 I have installed elasticsearch and kibana on my pc as a service.  Also, installed minikube (using kvm2 driver).  I was following the tutorials on kubernetes (<a href="https://kubernetes.io/docs/tutorials/stateless-application/guestbook-logs-metrics-with-elk/" rel="nofollow noreferrer">Add logging and metrics to the PHP / Redis Guestbook example</a>), and I couldn't connect to my external hosted elasticsearch &amp; kibana.</p>

<p>How to configure elasticsearch/kibana &amp; kube-state-metrics in minikube?</p>

surfealokesea
<p>First must bind elasticsearch &amp; kibana to the specific host ip that minikube "can see".</p>

<p>Get the ip:</p>

<pre><code>minikube ssh "route -n | grep ^0.0.0.0 | awk '{ print \$2 }'"
</code></pre>

<blockquote>
  <p>In my case it returns 192.168.122.1</p>
</blockquote>

<p>Update elastic &amp; kibana configuration &amp; restart:</p>

<pre><code>sudo nano /etc/elasticsearch/elasticsearch.yml
network.host: 192.168.122.1
cluster.initial_master_nodes: ["node-1","node-2"]

sudo nano /etc/kibana/kibana.yml
server.host: 192.168.122.1
elasticsearch.hosts: ["http://192.168.122.1:9200"]

sudo systemctl restart elasticsearch.service
sudo systemctl restart kibana.service
</code></pre>

<p>Verify servers are running:</p>

<pre><code>curl 192.168.122.1:9200
curl 192.168.122.1:5601
curl 192.168.122.1:5601/api/status

sudo journalctl -u kibana
sudo journalctl -u elasticsearch
</code></pre>

<p>Verify conectivity from inside minikube:</p>

<pre><code>minikube ssh
                         _             _            
            _         _ ( )           ( )           
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  
/' _ ` _ `\| |/' _ `\| || , &lt;  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ curl 192.168.122.1:9200
$ curl 192.168.122.1:5601/api/status
</code></pre>

<p>Now we just need to use this ip in the kubernetes secret configuration <a href="https://kubernetes.io/docs/tutorials/stateless-application/guestbook-logs-metrics-with-elk/#create-a-kubernetes-secret" rel="nofollow noreferrer">kubernetes secret configuration for filebeat</a>:</p>

<p><em>ELASTICSEARCH_HOSTS</em></p>

<pre><code>["http://192.168.122.1:9200"]
</code></pre>

<p><em>KIBANA_HOSTS</em></p>

<pre><code>"192.168.122.1:5601"
</code></pre>
