The deployment of the Elastic Stack—comprising Elasticsearch, Logstash, and Kibana—within a Kubernetes environment represents a fundamental shift toward scalable, cloud-native observability. By leveraging Helm, the package manager for Kubernetes, engineers can transform the complex process of orchestrating distributed stateful sets and stateless visualization layers into a manageable, repeatable operation. This architectural approach ensures that logging infrastructure can scale dynamically with the application workloads it monitors, providing real-time insights into system health and application performance.
The ELK stack serves as the backbone for centralized logging. Elasticsearch provides the distributed search and indexing engine, Logstash acts as the server-side data processing pipeline, and Kibana serves as the visualization window. In a Kubernetes context, these components must be meticulously configured to handle persistence, networking, and resource allocation to prevent the common pitfall of cluster instability caused by the resource-intensive nature of JVM-based applications.
Infrastructure Provisioning on Google Kubernetes Engine (GKE)
Before the deployment of the ELK stack, a robust compute foundation must be established. Utilizing Google Cloud Platform (GCP) via Google Kubernetes Engine (GKE) allows for a highly available environment that integrates seamlessly with cloud storage and networking.
The initial phase involves the definition of global environment variables to ensure consistency across the deployment lifecycle. These variables act as the source of truth for the cluster's geographical and naming identity.
$ LOCATION=us-central1-a
$ CLUSTER_NAME=kubetest
The selection of the machine type is a critical technical decision. By default, GKE may provision clusters using e2-medium instances, which provide 2 vCPUs and 4 GB of memory. However, Elasticsearch is notoriously memory-hungry due to its Heap requirements and the Lucene index buffers. Deploying ELK on e2-medium nodes typically leads to Out-of-Memory (OOM) kills or severe performance degradation.
To identify available hardware profiles that can support the memory demands of the Elastic Stack, the following command is used to filter available machine types in the specified region:
$ gcloud compute machine-types list --filter="$LOCATION"
Based on the requirements for a stable production-grade or development-grade ELK cluster, the e2-standard-4 machine type is recommended. This instance provides significantly more memory, ensuring that the JVM has sufficient headroom for indexing operations and query execution.
The cluster is then instantiated using the following gcloud command:
$ gcloud container clusters create $CLUSTER_NAME \
--zone $LOCATION \
--node-locations $LOCATION \
--machine-type e2-standard-4
The resulting infrastructure yields a cluster with the following characteristics:
| Attribute | Value |
|---|---|
| Cluster Name | kubetest |
| Location | us-central1-a |
| Master Version | 1.28.8-gke.1095000 |
| Master IP | 34.72.13.154 |
| Machine Type | e2-standard-4 |
| Node Version | 1.28.8-gke.1095000 |
| Node Count | 3 |
| Status | RUNNING |
This infrastructure provides the necessary compute overhead to handle the distributed nature of Elasticsearch. Should the environment need to be decommissioned, the process is handled via:
$ gcloud container clusters delete $CLUSTER_NAME --location $LOCATION
Helm Integration and Repository Management
Helm acts as the orchestrator for Kubernetes applications, allowing users to define, install, and upgrade complex applications using "charts." A chart is essentially a collection of templates that describe the desired state of the ELK components.
The first technical requirement is the installation of the Helm binary on the local workstation. Once installed, the official Elastic Helm charts repository must be added. These charts are designed as lightweight configurations for the official Elastic Docker images, reducing the manual overhead of writing YAML manifests for every service.
The integration process begins by adding the repository:
$ helm repo add elastic https://helm.elastic.co
Following the addition, the local cache must be synchronized with the remote repository to ensure the most recent chart versions are available:
$ helm repo update
This process ensures that the deployment uses the latest stable releases of the Elastic components, which is vital for security patches and performance improvements.
Namespace Isolation and Component Deployment
To maintain a clean architectural separation between application workloads and monitoring infrastructure, the ELK stack should be deployed within a dedicated Kubernetes namespace. This prevents naming collisions and allows for granular Role-Based Access Control (RBAC) and resource quotas.
The creation of the monitoring namespace is executed as follows:
$ kubectl create namespace monit
Elasticsearch Implementation
Elasticsearch is the core engine of the stack. It is a distributed, RESTful search and analytics engine that handles the storage and indexing of all log data. In a Kubernetes environment, Elasticsearch is typically deployed as a StatefulSet to ensure that pods maintain a consistent identity and that data is persisted across pod restarts.
The primary role of Elasticsearch in this architecture is to provide a scalable backend that can ingest massive volumes of logs and provide near real-time search capabilities. Because it stores the actual data, the underlying storage class in Kubernetes must be configured to provide persistent volumes (PVs) that survive node failures.
Logstash Configuration and Deployment
Logstash serves as the data processing pipeline. While Elasticsearch stores the data, Logstash is responsible for transforming it. It consumes logs from various sources, transforms them through filters (such as Grok or mutate), and writes them to the destination (Elasticsearch).
If the environment requires specific log processing, such as parsing structured logs or applying complex filters, Logstash must be deployed using the Elastic Helm chart. The installation command is:
$ helm install logstash elastic/logstash --namespace monit
To verify the operational status of the Logstash pods, the following monitoring command is utilized:
$ kubectl get pods --namespace=monit -l app=logstash-logstash -w
A successful deployment will result in a status indicating that the container is ready:
NAME READY STATUS RESTARTS AGE
logstash-logstash-0 1/1 Running 0 2m17s
The impact of utilizing Logstash is the ability to normalize disparate log formats into a unified schema, which significantly improves the efficiency of searches within Kibana.
Kibana Visualization and Access
Kibana provides the graphical user interface for the ELK stack. It allows users to visualize the data indexed in Elasticsearch through dashboards, charts, and maps.
Once Kibana is deployed, the primary task is the configuration of Index Patterns. An index pattern is a definition that tells Kibana which Elasticsearch indices to query. Without these patterns, Kibana cannot interpret the structure of the log data, rendering the visualization capabilities useless.
The technical workflow for Kibana involves:
- Defining the index pattern based on the naming convention of the Elasticsearch indices.
- Mapping the timestamp field to enable time-series analysis.
- Creating dashboards that aggregate log data for real-time monitoring.
Advanced Deployment Strategies and ECK
While standard Helm charts provide a lightweight way to configure Docker images, Elastic provides a more robust alternative known as Elastic Cloud on Kubernetes (ECK). ECK is an operator-based approach that provides superior operational benefits.
The transition toward ECK is highlighted by the fact that as of version 8.5.1, Elastic has handed over the maintenance of standard Helm charts to the community. The company now focuses on maintaining Helm charts that are applicable to ECK Custom Resources.
The operational advantages of ECK include:
- Automatic recovery of cluster nodes lost due to infrastructure failure.
- Seamless, automated version upgrades.
- Orchestration of rolling cluster changes without downtime.
For those utilizing ECK, the deployment options for ingress and external access are more sophisticated. Since ECK-managed workloads can be publicly exposed using ingress resources, it requires in-house Kubernetes expertise to configure the ingress controller. If this is too complex, a standard LoadBalancer service is recommended as a simpler alternative.
Ingress Implementation for Individual Charts
If a user is deploying an individual Elasticsearch cluster via the eck-elasticsearch chart with ingress enabled, the following command is used:
helm install es-quickstart elastic/eck-elasticsearch -n elastic-stack --create-namespace \
--set=ingress.enabled=true --set=ingress.hosts[0].host=elasticsearch.example.com --set=ingress.hosts[0].path="/"
Ingress Implementation for the Full Stack
When deploying the combined eck-stack chart, which includes both Elasticsearch and Kibana, the command incorporates configurations for both components:
helm install es-kb-quickstart elastic/eck-stack -n elastic-stack --create-namespace \
--set=eck-elasticsearch.ingress.enabled=true --set=eck-elasticsearch.ingress.hosts[0].host=elasticsearch.example.com --set=eck-elasticsearch.ingress.hosts[0].path="/" \
--set=eck-kibana.ingress.enabled=true --set=eck-kibana.ingress.hosts[0].host=kibana.example.com --set=eck-kibana.ingress.hosts[0].path="/"
This configuration creates ingress objects that route external traffic to the internal Kubernetes services, allowing administrators and developers to access the Kibana dashboard and Elasticsearch API via a friendly URL.
Post-Deployment Optimization and Maintenance
After the successful installation of the ELK components, the focus must shift to operational excellence and long-term stability.
The following tasks are mandatory for a production-ready environment:
Logstash Pipeline Configuration: For those who installed Logstash, it is necessary to define pipelines for ingesting and processing logs. This is typically achieved by defining Logstash configuration files and mounting them into the pods as ConfigMaps. This allows for dynamic updates to the processing logic without rebuilding the container image.
Comprehensive Monitoring: The health of the ELK stack should not be monitored solely by pod status. Integration with external monitoring solutions such as Prometheus and Grafana is recommended. By exporting built-in metrics from Elasticsearch and Kibana, engineers can create dashboards that monitor JVM heap usage, disk I/O, and query latency.
Index Management: To prevent disk exhaustion, index lifecycle management (ILM) policies should be implemented. This ensures that old logs are automatically rolled over, shrunk, or deleted based on the age of the data.
Summary of Component Roles and Technical Requirements
| Component | Primary Function | Resource Requirement | Deployment Method |
|---|---|---|---|
| Elasticsearch | Data Storage & Indexing | High Memory (e2-standard-4) | Helm/ECK (StatefulSet) |
| Logstash | Data Processing/Filtering | Moderate CPU/Memory | Helm (Deployment) |
| Kibana | Data Visualization | Moderate Memory | Helm (Deployment) |
Conclusion
The deployment of the ELK stack on Kubernetes using Helm is a sophisticated operation that bridges the gap between raw log data and actionable intelligence. The move from standard Helm charts to the Elastic Cloud on Kubernetes (ECK) operator signifies a shift toward a more automated, self-healing infrastructure. By carefully selecting the appropriate machine types—specifically avoiding the e2-medium in favor of e2-standard-4—and implementing strategic ingress configurations, organizations can ensure a stable and scalable observability platform. The integration of Logstash for complex parsing and the use of dedicated namespaces for isolation further harden the environment. Ultimately, the success of an ELK deployment on Kubernetes is measured not just by the "Running" status of the pods, but by the efficiency of the index patterns in Kibana and the robustness of the monitoring integration with tools like Prometheus and Grafana.