How to connect from minikube to elasticsearch installed on host (local development & kvm2)

1/24/2020

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 (Add logging and metrics to the PHP / Redis Guestbook example), and I couldn't connect to my external hosted elasticsearch & kibana.

How to configure elasticsearch/kibana & kube-state-metrics in minikube?

-- surfealokesea
elasticsearch
kibana
kubernetes
minikube

1 Answer

1/24/2020

First must bind elasticsearch & kibana to the specific host ip that minikube "can see".

Get the ip:

minikube ssh "route -n | grep ^0.0.0.0 | awk '{ print \$2 }'"

In my case it returns 192.168.122.1

Update elastic & kibana configuration & restart:

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

Verify servers are running:

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

Verify conectivity from inside minikube:

minikube ssh
                         _             _            
            _         _ ( )           ( )           
  ___ ___  (_)  ___  (_)| |/')  _   _ | |_      __  
/' _ ` _ `\| |/' _ `\| || , <  ( ) ( )| '_`\  /'__`\
| ( ) ( ) || || ( ) || || |\`\ | (_) || |_) )(  ___/
(_) (_) (_)(_)(_) (_)(_)(_) (_)`\___/'(_,__/'`\____)

$ curl 192.168.122.1:9200
$ curl 192.168.122.1:5601/api/status

Now we just need to use this ip in the kubernetes secret configuration kubernetes secret configuration for filebeat:

ELASTICSEARCH_HOSTS

["http://192.168.122.1:9200"]

KIBANA_HOSTS

"192.168.122.1:5601"
-- surfealokesea
Source: StackOverflow