Created
June 19, 2018 01:30
-
-
Save kvudata/bf5ee8b7a895fa873afa5afad43f4cba to your computer and use it in GitHub Desktop.
Elasticsearch on kubernetes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: apps/v1 | |
kind: StatefulSet | |
metadata: | |
name: elasticsearch | |
spec: | |
selector: | |
matchLabels: &POD_LABELS | |
app: elasticsearch | |
serviceName: elasticsearch | |
replicas: 1 | |
template: | |
metadata: | |
labels: *POD_LABELS | |
spec: | |
securityContext: | |
# the elasticsearch image runs ES as the elasticsearch user, we need | |
# this configuration to ensure the container + volume mount get associated | |
# to the same group ID 1000 and the volume is thus writable for elasticsearch | |
fsGroup: 1000 | |
initContainers: | |
- name: init-mem-limit | |
image: busybox | |
# the amount of virtual memory allowed to a vm needs to be bumped up to run ES | |
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-prod-mode | |
command: ['sysctl', '-w', 'vm.max_map_count=262144'] | |
# need to run this container in privileged mode to allow it to change this setting | |
securityContext: | |
privileged: true | |
containers: | |
- name: elasticsearch | |
image: docker.elastic.co/elasticsearch/elasticsearch:6.2.3 | |
ports: | |
- containerPort: 9200 | |
volumeMounts: | |
- name: es-data | |
mountPath: /usr/share/elasticsearch/data | |
- name: es-logs | |
mountPath: /usr/share/elasticsearch/logs | |
volumeClaimTemplates: | |
- metadata: | |
name: es-data | |
spec: | |
accessModes: ['ReadWriteOnce'] | |
resources: | |
requests: | |
storage: 50Gi | |
- metadata: | |
name: es-logs | |
spec: | |
accessModes: ['ReadWriteOnce'] | |
resources: | |
requests: | |
storage: 50Gi | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: elasticsearch | |
labels: | |
app: elasticsearch | |
spec: | |
selector: | |
app: elasticsearch | |
ports: | |
- port: 9200 | |
# StatefulSet's require a headless service, specified by clusterIP: None | |
clusterIP: None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment