elasticsearch

by joaquinito2051

Helm chartv0.6.1App 5.4

Flexible and powerful open source, distributed real-time search and analytics engine.

About this chart

Elasticsearch Helm Chart

This chart uses a standard Docker image of Elasticsearch (hub.docker.com/r/blacktop/elasticsearch) and uses a service pointing to the master's transport port for service discovery. Elasticsearch does not communicate with the Kubernetes API, hence no need for RBAC permissions.

Warning for previous users

If you are upgrading to Elasticsearch 6 from the 5.5 version used in this chart before, please note that your cluster needs to do a full cluster restart. The simplest way to do that is to delete the installation (keep the PVs) and install this chart again with the new version. If you want to avoid doing that upgrade to Elasticsearch 5.6 first before moving on to Elasticsearch 6.0.

Prerequisites Details

  • Kubernetes 1.6+
  • PV dynamic provisioning support on the underlying infrastructure

StatefulSets Details

  • https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/

StatefulSets Caveats

  • https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#limitations

Todo

  • Implement TLS/Auth/Security
  • Smarter upscaling/downscaling
  • Solution for memory locking

Chart Details

This chart will do the following:

  • Implemented a dynamically scalable elasticsearch cluster using Kubernetes StatefulSets/Deployments
  • Multi-role deployment: master, client (coordinating) and data nodes
  • Statefulset Supports scaling down without degrading the cluster

Installing the Chart

To install the chart with the release name my-release:

$ helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
$ helm install --name my-release incubator/elasticsearch

Deleting the Charts

Delete the Helm deployment as normal

$ helm delete my-release

Deletion of the StatefulSet doesn't cascade to deleting associated PVCs. To delete them:

$ kubectl delete pvc -l release=my-release,component=data

Configuration

The following table lists the configurable parameters of the elasticsearch chart and their default values.

ParameterDescriptionDefault
appVersionApplication Version (Elasticsearch)5.4
image.repositoryContainer image namecenterforopenscience/elasticsearch
image.tagContainer image tag5.4
image.pullPolicyContainer pull policyAlways
cluster.nameCluster nameelasticsearch
cluster.kubernetesDomainKubernetes cluster domain namecluster.local
cluster.xpackEnableWrites the X-Pack configuration options to the configuration filefalse
cluster.configAdditional cluster config appended{}
cluster.envCluster environment variables{}
client.nameClient component nameclient
client.replicasClient node replicas (deployment)2
client.resourcesClient node resources requests & limits{} - cpu limit must be an integer
client.heapSizeClient node heap size512m
client.podAnnotationsClient Deployment annotations{}
client.serviceAnnotationsClient Service annotations{}
client.serviceTypeClient service typeClusterIP
master.exposeHttpExpose http port 9200 on master Pods for monitoring, etcfalse
master.nameMaster component namemaster
master.replicasMaster node replicas (deployment)2
master.resourcesMaster node resources requests & limits{} - cpu limit must be an integer
master.podAnnotationsMaster Deployment annotations{}
master.heapSizeMaster node heap size512m
master.nameMaster component namemaster
master.persistence.enabledMaster persistent enabled/disabledtrue
master.persistence.nameMaster statefulset PVC template namedata
master.persistence.sizeMaster persistent volume size4Gi
master.persistence.storageClassMaster persistent volume Classnil
master.persistence.accessModeMaster persistent Access ModeReadWriteOnce
data.exposeHttpExpose http port 9200 on data Pods for monitoring, etcfalse
data.replicasData node replicas (statefulset)3
data.resourcesData node resources requests & limits{} - cpu limit must be an integer
data.heapSizeData node heap size1536m
data.persistence.enabledData persistent enabled/disabledtrue
data.persistence.nameData statefulset PVC template namedata
data.persistence.sizeData persistent volume size30Gi
data.persistence.storageClassData persistent volume Classnil
data.persistence.accessModeData persistent Access ModeReadWriteOnce
data.podAnnotationsData StatefulSet annotations{}
data.terminationGracePeriodSecondsData termination grace period (seconds)3600
data.antiAffinityData anti-affinity policysoft

Specify each parameter using the --set key=value[,key=value] argument to helm install.

In terms of Memory resources you should make sure that you follow that equation:

  • ${role}HeapSize < ${role}MemoryRequests < ${role}MemoryLimits

The YAML value of cluster.config is appended to elasticsearch.yml file for additional customization ("script.inline: on" for example to allow inline scripting)

Deep dive

Application Version

This chart aims to support Elasticsearch v2 and v5 deployments by specifying the values.yaml parameter appVersion.

Version Specific Features

  • Memory Locking (variable renamed)
  • Ingest Node (v5)
  • X-Pack Plugin (v5)

Upgrade paths & more info: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-upgrade.html

Mlocking

This is a limitation in kubernetes right now. There is no way to raise the limits of lockable memory, so that these memory areas won't be swapped. This would degrade performance heavily. The issue is tracked in kubernetes/#3595.

[WARN ][bootstrap] Unable to lock JVM Memory: error=12,reason=Cannot allocate memory
[WARN ][bootstrap] This can result in part of the JVM being swapped out.
[WARN ][bootstrap] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536

Minimum Master Nodes

The minimum_master_nodes setting is extremely important to the stability of your cluster. This setting helps prevent split brains, the existence of two masters in a single cluster.

When you have a split brain, your cluster is at danger of losing data. Because the master is considered the supreme ruler of the cluster, it decides when new indices can be created, how shards are moved, and so forth. If you have two masters, data integrity becomes perilous, since you have two nodes that think they are in charge.

This setting tells Elasticsearch to not elect a master unless there are enough master-eligible nodes available. Only then will an election take place.

This setting should always be configured to a quorum (majority) of your master-eligible nodes. A quorum is (number of master-eligible nodes / 2) + 1

More info: https://www.elastic.co/guide/en/elasticsearch/guide/1.x/_important_configuration_changes.html#_minimum_master_nodes

Client and Coordinating Nodes

Elasticsearch v5 terminology has updated, and now refers to a Client Node as a Coordinating Node.

More info: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/modules-node.html#coordinating-node

Select right storage class for SSD volumes

GCE + Kubernetes 1.5

Create StorageClass for SSD-PD

$ kubectl create -f - <<EOF
kind: StorageClass
apiVersion: extensions/v1beta1
metadata:
  name: ssd
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd
EOF

Create cluster with Storage class ssd on Kubernetes 1.5+

$ helm install incubator/elasticsearch --name my-release --set data.storageClass=ssd,data.storage=100Gi

Deploy elasticsearch with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has elasticsearch on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartelasticsearch is pinned at v0.6.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply