Adaltas Cloud Academy
Sign out >

Example: Elasticsearch

In this example, we will be installing the ELK Stack with the official Helm Chart.

“ELK” is the acronym for three open source projects: Elasticsearch, Logstash, and Kibana. Elasticsearch is an open-source, RESTful, distributed search and analytics engine built on Apache Lucene. Logstash is a server‑side data processing pipeline that ingests data from multiple sources simultaneously, transforms it, and then sends it to a “stash” like Elasticsearch. Kibana lets users visualize data with charts and graphs in Elasticsearch.

Helm is the package manager for Kubernetes, it is the go-to utlity to use software built for Kubernetes. Charts are a bundle of information necessary to create an instance of a Kubernetes application (ex: Elasticsearch, MySQL, WordPress). Charts are configurable through a set of given parameters (depending on the chart). An instance of a chart and its given configuration is called a release.

[[info | Setup Kubernetes and login first]] | Before interacting with Kubernetes, your environnment must be configured and you shall be authenticated. Read the Kubernetes onboarding instructions to get started.

Pre-configuration

Our local Helm installation is not aware of the Helm chart we want to use yet, we need to configure the repo and look for the stable/elastic-stack chart:

helm repo add stable https://kubernetes-charts.storage.googleapis.com/
helm repo update

Once the repo is configured properly, we should be able to find the stable/elastic-stack chart:

helm search repo elastic

NAME                         	CHART VERSION	APP VERSION	DESCRIPTION
stable/elastic-stack         	2.0.1        	6          	A Helm chart for ELK
stable/elasticsearch         	1.32.5       	6.8.6      	DEPRECATED Flexible and powerful open source, d...
stable/elasticsearch-curator 	2.1.5        	5.7.6      	A Helm chart for Elasticsearch Curator
stable/elasticsearch-exporter	3.4.0        	1.1.0      	Elasticsearch stats exporter for Prometheus

Configuration

The first thing we need to do is describe the resources that Helm is going to create:

elasticsearch:
  enabled: true
  master:
    replicas: 2
    persistence:
      size: "2Gi"
  data:
    replicas: 1
    persistence:
      size: "15Gi"
  client:
    replicas: 1
    serviceType: NodePort
kibana:
  enabled: true
  service:
    type: NodePort
  env:
    ELASTICSEARCH_HOSTS: http://{{ .Release.Name }}-elasticsearch-client:9200
logstash:
  enabled: false

Only elasticsearch and kibana services are enabled (tough Kibana is optional here). This configuration will create a two master / 1 worker Elasticsearch cluster as well as persistent storage for these containers.

Installation

To install the stable/elastic-stack chart customized with out configuration file:

RELEASE_NAME=mba-esg-elastic-stack
NAMESPACE=mba-esg
helm install $RELEASE_NAME stable/elastic-stack -f elastic-stack-esg.yaml -n $NAMESPACE

Wait for all the pods to be ready (1/1):

watch kubectl get pods -n $NAMESPACE -l release=$RELEASE_NAME

Usage

To get the ports attached to Elasticsearch and Kibana:

kubectl get svc -l release=$RELEASE_NAME -n $NAMESPACE

NAME                                            TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
mba-esg-elastic-stack-elasticsearch-client      NodePort    10.111.214.243   <none>        9200:31443/TCP   11m
mba-esg-elastic-stack-elasticsearch-discovery   ClusterIP   None             <none>        9300/TCP         11m
mba-esg-elastic-stack-kibana                    NodePort    10.110.49.151    <none>        443:31972/TCP    11m

To test the Elasticsearch:

curl k8s-1.au.adaltas.cloud:31443/_cat/health
1593178812 13:40:12 elasticsearch green 4 1 1 1 0 0 0 0 - 100.0%

In this example, the Kibana Web UI is reachable at 31972.

Deletion

To uninstall the release:

helm uninstall $RELEASE_NAME -n $NAMESPACE

The uninstall does not delete the underlying PVC (persistent storage objects), to delete them:

kubectl delete pvc -l release=$RELEASE_NAME -n $NAMESPACE