Get a DemoStart Free TrialSign In

ELK, Resources

3 min read

The main objective of the ELK (Elasticsearch, Logstash, and Kibana) is to aggregate logs. However, with the increased usage of ELK and Kubernetes as a pairing the solution can go beyond the aggregation of standard logs and include monitoring and analysis of Kubernetes telemetry data. Therefore, more users are looking at deploying the ELK stack on Kubernetes. Yet, deploying the ELK stack on Kubernetes can be a complex task but with the assistance of Helm charts, the process is much simpler.

This article will highlight why deploying the ELK stack on Kubernetes is beneficial to an organization and outline a configuration guide for deploying the ELK stack on Kubernetes with Helm charts.

Contents

What is Kubernetes?

Kubernetes, regularly abbreviated as K8s, is an open-source container orchestration platform originally developed by Google and now maintained by the Cloud Native Computing Foundation (CNCF). It offers a platform for deploying and managing containerized workloads via a cluster of machines. The tool abstracts away the underlying infrastructure, enabling developers to concentrate on constructing and deploying applications without worrying about the details of where those applications will operate.

What is Helm?

Helm is a powerful package manager for Kubernetes, designed to simplify the deployment and management of applications within Kubernetes clusters. It streamlines the challenging process of managing Kubernetes resources by encapsulating them into reusable and version-controlled packages known as charts. These charts contain all the Kubernetes manifests, templates, and configuration files needed to deploy an application or service.

A key feature of Helm is its templating engine, which enables users to customize deployments by dynamically generating Kubernetes manifests based on user-defined values. This flexibility allows users to alter parameters such as resource allocations, environment variables, and replica counts without changing the underlying chart. Helm's templating capability guarantees consistency across deployments while accommodating variations in configuration requirements.

Why Deploy the ELK Stack on Kubernetes?

Deploying the ELK stack on Kubernetes can be particularly advantageous, this is because it is highly scalable. Kubernetes offers native support for scaling applications horizontally by inputting or removing instances based on resource demand. This scalability is vital for ELK stack components, especially Elasticsearch, which regularly needs to manage large volumes of data.

Additionally, users can gain from automated deployment and management. Kubernetes simplifies the deployment and management of complex applications like the ELK stack via automation. Operators or Helm charts can be utilized to outline the desired state of the ELK stack deployment, making it simpler to provision, update, and scale the infrastructure.

As well as this, by deploying the ELK stack on Kubernetes you can optimize resource utilization. Kubernetes enhances resource utilization by scheduling ELK stack components as containerized workloads on shared infrastructure. This allows organizations to make efficient use of computing resources, reducing costs and increasing the return on investment (ROI) of their infrastructure.

Lastly, with the ELK deployed on Kubernetes users can benefit from increased fault tolerance. Kubernetes optimizes fault tolerance by automatically restarting failed containers and rescheduling workloads on healthy nodes. This aids organizations in maintaining the integrity and reliability of their ELK stack deployments, even in the face of hardware failures or other disruptions.

How to Deploy the ELK Stack on Kubernetes with Helm Chats

In this section, we will outline in detail how to deploy the ELK stack on Kubernetes using Helm charts. Before following this configuration guide, it’s important to ensure you have a Kubernetes cluster running and that you have Helm installed on your local machine and Tiller (Helm's server-side component) deployed in your Kubernetes cluster.

  1. Add Elastic Helm Charts Repository: Elastic offers official Helm charts for deploying the ELK stack components. By adding the Elastic Helm repository to your Helm configuration, you attain access to these charts.

helm repo add elastic https://helm.elastic.co helm repo update

  1. Install Elasticsearch: Elasticsearch is the core of the ELK stack, responsible for storing and indexing log data. When installing Elasticsearch with Helm, you can customize parameters such as the number of replicas (for high availability) and JVM heap size using Helm chart values. Replace with the Kubernetes namespace where you want to deploy Elasticsearch.

helm install elasticsearch elastic/elasticsearch
--namespace
--set replicas=3
--set esJavaOpts="-Xmx512m -Xms512m"

  1. Install Kibana: Kibana is the visualization and dashboarding component of the ELK stack. It offers a user-friendly interface for exploring and analyzing log data stored in Elasticsearch. By installing Kibana with Helm, you can quickly deploy and configure it to connect to your Elasticsearch cluster.

helm install kibana elastic/kibana
--namespace

  1. Install Logstash (Optional): Logstash is an optional component used for log ingestion, processing, and enrichment. If you have specific log processing requirements, such as parsing structured logs or applying filters, you can install Logstash using the Elastic Helm chart.

helm install logstash elastic/logstash
--namespace

  1. Configure Ingress (Optional): If you want to access Kibana via a web browser, you can configure an Ingress resource. Replace with your desired hostname.

apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: kibana-ingress namespace: spec: rules: host: http: paths: path: / pathType: Prefix backend: service: name: kibana-kibana port: number: 5601

  1. Access Kibana: If you configured an Ingress, you can access Kibana via . Otherwise, you can use port-forwarding to access it.

kubectl port-forward service/kibana-kibana :5601 --namespace

Then, open http://localhost: in your web browser.

  1. Configure Index Patterns in Kibana: Before visualizing log data in Kibana, you need to define index patterns that specify which Elasticsearch indices to query. Index patterns define the structure of your log data and enable Kibana's powerful search and visualization capabilities.

  2. Configure Logstash (Optional): If you installed Logstash, configure Logstash pipelines to ingest and process your logs. You can define Logstash configuration files and mount them as ConfigMaps or use other methods for configuration management.

  3. Monitor Elasticsearch and Kibana: Monitor Elasticsearch and Kibana using built-in metrics or integrate with external monitoring solutions like Prometheus and Grafana for comprehensive observability.

If you've enjoyed this article why not read How To Harness The Full Potential of ELK Clusters or The Best ELK Dashboard Examples next?

Get the latest elastic Stack & logging resources when you subscribe

© 2024 Logit.io Ltd, All rights reserved.