MangoHost Blog / How to Set Up an Elasticsearch, Fluentd, and Kibana (EFK) Logging Stack on Kubernetes
How to Set Up an Elasticsearch, Fluentd, and Kibana (EFK) Logging Stack on Kubernetes
Setting up a centralized logging solution on Kubernetes is crucial for monitoring distributed applications and troubleshooting issues across multiple pods and services. The EFK stack (Elasticsearch, Fluentd, and Kibana) provides a powerful combination where Elasticsearch stores and indexes logs, Fluentd collects and forwards log data, and Kibana visualizes the information through interactive dashboards. This guide will walk you through deploying a complete EFK logging stack on Kubernetes, covering everything from basic setup to advanced configurations and common troubleshooting scenarios.
How the EFK Stack Works
The EFK architecture follows a simple but effective flow: Fluentd runs as a DaemonSet on each Kubernetes node, collecting logs from containers and system components, then forwards them to Elasticsearch for storage and indexing. Kibana connects to Elasticsearch to provide a web interface for searching, filtering, and visualizing log data.
Here’s what each component handles:
Fluentd: Acts as the log collector and forwarder, parsing various log formats and enriching them with Kubernetes metadata like pod names, namespaces, and labels
Elasticsearch: Stores logs in indexes, provides full-text search capabilities, and handles data retention policies
Kibana: Offers visualization tools, dashboard creation, and advanced search interfaces for log analysis
Compared to other logging solutions like ELK (Logstash instead of Fluentd) or Loki, EFK typically uses less memory and provides better Kubernetes integration out of the box. Fluentd’s plugin ecosystem is particularly strong for Kubernetes environments.
Prerequisites and Cluster Requirements
Before diving into the setup, ensure your Kubernetes cluster meets these requirements:
Kubernetes version 1.16 or higher
At least 4GB RAM per node (Elasticsearch is memory-intensive)
Persistent volume support for Elasticsearch data
kubectl configured to access your cluster
Helm 3.x installed (optional but recommended)
Check your cluster resources:
kubectl get nodes
kubectl get storageclass
kubectl top nodes
Step-by-Step EFK Stack Deployment
Step 1: Create Namespace and RBAC
First, create a dedicated namespace for the logging stack:
kubectl create namespace logging
Create the necessary RBAC permissions for Fluentd:
The EFK stack integrates well with other Kubernetes monitoring tools:
Prometheus: Use elasticsearch_exporter for metrics collection
Grafana: Create dashboards combining logs and metrics
Jaeger: Correlate distributed traces with log events
AlertManager: Set up log-based alerting rules
You can also export logs to external systems like AWS CloudWatch, Google Cloud Logging, or Splunk using Fluentd’s extensive plugin ecosystem.
For additional configuration options and advanced features, check the official documentation for Elasticsearch, Fluentd, and Kibana. The EFK stack provides a robust foundation for centralized logging that scales with your Kubernetes infrastructure while offering powerful search and visualization capabilities for troubleshooting and monitoring your applications.
This article incorporates information and material from various online sources. We acknowledge and appreciate the work of all original authors, publishers, and websites. While every effort has been made to appropriately credit the source material, any unintentional oversight or omission does not constitute a copyright infringement. All trademarks, logos, and images mentioned are the property of their respective owners. If you believe that any content used in this article infringes upon your copyright, please contact us immediately for review and prompt action.
This article is intended for informational and educational purposes only and does not infringe on the rights of the copyright owners. If any copyrighted material has been used without proper credit or in violation of copyright laws, it is unintentional and we will rectify it promptly upon notification.
Please note that the republishing, redistribution, or reproduction of part or all of the contents in any form is prohibited without express written permission from the author and website owner. For permissions or further inquiries, please contact us.