Skip to content

Instantly share code, notes, and snippets.

@puttpotsawee
Last active September 24, 2018 14:18
Show Gist options
  • Save puttpotsawee/e50b60dea67a80a406fbd306c1775a31 to your computer and use it in GitHub Desktop.
Save puttpotsawee/e50b60dea67a80a406fbd306c1775a31 to your computer and use it in GitHub Desktop.
The elasticsearch 6 cluster
---
apiVersion: v1
kind: Service
metadata:
name: logging-elastic-service
labels:
service: logging-elastic
spec:
clusterIP: None
ports:
- port: 9200
name: serving
- port: 9300
name: node-to-node
selector:
service: logging-elastic
---
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: logging-elastic-cluster
labels:
service: logging-elastic
spec:
serviceName: logging-elastic-service
# NOTE: This is number of nodes that we want to run
# you may update this
replicas: 2
selector:
matchLabels:
service: logging-elastic
template:
metadata:
labels:
service: logging-elastic
spec:
terminationGracePeriodSeconds: 30
initContainers:
# NOTE:
# This is to fix the permission on the volume
# By default elasticsearch container is not run as
# non root user.
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_notes_for_production_use_and_defaults
- name: fix-the-volume-permission
image: busybox
command:
- sh
- -c
- chown -R 1000:1000 /usr/share/elasticsearch/data
securityContext:
privileged: true
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
# NOTE:
# To increase the default vm.max_map_count to 262144
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-prod-mode
- name: increase-the-vm-max-map-count
image: busybox
command:
- sysctl
- -w
- vm.max_map_count=262144
securityContext:
privileged: true
# To increase the ulimit
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_notes_for_production_use_and_defaults
- name: increase-the-ulimit
image: busybox
command:
- sh
- -c
- ulimit -n 65536
securityContext:
privileged: true
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:6.3.1
ports:
- containerPort: 9200
name: http
- containerPort: 9300
name: tcp
# NOTE: you can increase this resources
resources:
requests:
memory: 2Gi
limits:
memory: 8Gi
env:
# NOTE: the cluster name; update this
- name: cluster.name
value: elasticsearch-cluster
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
# NOTE: This will tell the elasticsearch node where to connect to other nodes to form a cluster
- name: discovery.zen.ping.unicast.hosts
value: "logging-elastic-cluster-0.logging-elastic-service.svc.cluster.local,logging-elastic-cluster-1.logging-elastic-service.svc.cluster.local"
# - name: discovery.type
# value: single-node
# NOTE: You can increase the heap size
- name: ES_JAVA_OPTS
value: -Xms4g -Xmx4g
- name: reindex.remote.whitelist
value: logging-elastic-service-old:9200
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
storageClassName: fast
# NOTE: You can increase the storage size
resources:
requests:
storage: 60Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment