Setting up EFK with minikube

minikube provides an add-on feature for EFK out of the box, but it is disabled by default. So, you need to enable EFK on your minikube manually. EFK consumes a large amount of heap memory but minikube allocates only 2 GB by default, which is absolutely not sufficient to run the EFK stack in minikube. Therefore, we'll need to enlarge minikube's memory size explicitly.

In addition, you should use the latest version of minikube, due to several bug fixes made for EFK while writing this cookbook. So, we are using minikube version 0.25.2. Let's configure minikube to enable EFK using the following steps:

  1. If you are already running minikube, stop minikube first:
$ minikube stop
  1. Update to the latest version of minikube:
//if you are using macOS 
$ brew update
$ brew cask upgrade


//if you are using Windows, download a latest binary from
https://github.com/kubernetes/minikube/releases
  1. Since EFK consumes a large amount of heap memory, start minikube with 5 GB of memory:
$ minikube start --vm-driver=hyperkit --memory 5120
  1. Make sure, all Pods in the kube-system Namespace are up, because EFK relies on kube-addon-manager-minikube:
$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system kube-addon-manager-minikube 1/1 Running 0 1m
kube-system kube-dns-54cccfbdf8-rc7gf 3/3 Running 0 1m
kube-system kubernetes-dashboard-77d8b98585-hkjrr 1/1 Running 0 1m
kube-system storage-provisioner 1/1 Running 0 1m
  1. Enable the efk add-on:
$ minikube addons enable efk
efk was successfully enabled
  1. Wait for a while; Elasticsearch, fluentd and kibana Pod have been deployed in the kube-system namespace automatically. Wait for the STATUS to become Running. It should take at least 10 minutes to complete:
$ kubectl get pods --namespace=kube-system
NAME READY STATUS RESTARTS AGE
$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system elasticsearch-logging-t5tq7 1/1 Running 0 9m
kube-system fluentd-es-8z2tr 1/1 Running 0 9m
kube-system kibana-logging-dgql7 1/1 Running 0 9m
kube-system kube-addon-manager-minikube 1/1 Running 1 34m
  1. Use kubectl logs to watch a kibana that waits for the state to become green. This also takes an additional five minutes:
$ kubectl logs -f kibana-logging-dgql7  --namespace=kube-system
{"type":"log","@timestamp":"2018-03-25T18:53:54Z","tags":["info","optimize"],"pid":1,"message":"Optimizing and caching bundles for graph, ml, kibana, stateSessionStorageRedirect, timelion and status_page. This may take a few minutes"}

(wait for around 5min)

{"type":"log","@timestamp":"2018-03-25T19:03:10Z","tags":["status","plugin:[email protected]","info"],"pid":1,"state":"yellow","message":"Status changed from yellow to yellow - No existing Kibana index found","prevState":"yellow","prevMsg":"Waiting for Elasticsearch"}
{"type":"log","@timestamp":"2018-03-25T19:03:15Z","tags":["status","plugin:[email protected]","info"],"pid":1,"state":"green","message":"Status changed from yellow to green - Kibana index ready","prevState":"yellow","prevMsg":"No existing Kibana index found"}
  1. Access the kibana service using the minikube service command:
$ minikube service kibana-logging --namespace=kube-system
Opening kubernetes service kube-system/kibana-logging in default browser...

Now, you have access to the Kibana UI from your machine. You just need to set up an index. Since Fluentd keeps sending a log with the index name as logstash-yyyy.mm.dd, the index pattern is logstash-* by default. Click the Create button:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.218.20.25