apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: es6-master
spec:
  replicas: 1
  serviceName: es6-master
  selector:
    matchLabels:
      application: es6
      role: master
  template:
    metadata:
      labels:
        application: es6
        role: master
    spec:
      serviceAccountName: operator
      securityContext:
        fsGroup: 1000
      initContainers:
      - name: init-sysctl
        image: busybox:1.30
        command:
        - sysctl
        - -w
        - vm.max_map_count=262144
        resources:
          requests:
            memory: 50Mi
            cpu: 50m
          limits:
            memory: 50Mi
            cpu: 50m
        securityContext:
          privileged: true
          runAsUser: 0
      containers:
      - name: elasticsearch
        resources:
          requests:
            memory: 512Mi
            cpu: 100m
          limits:
            memory: 512Mi
            cpu: 100m
        image: "docker.elastic.co/elasticsearch/elasticsearch-oss:6.7.1"
        env:
        - name: "node.name"
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: "ES_JAVA_OPTS"
          value: "-Xms256m -Xmx256m"
        - name: node.master
          value: "true"
        - name: node.data
          value: "false"
        readinessProbe:
          httpGet:
            scheme: HTTP
            path: /_cluster/health?local=true
            port: 9200
        ports:
        - containerPort: 9200
          name: es-http
        - containerPort: 9300
          name: es-transport
        volumeMounts:
        - name: data
          mountPath: /usr/share/elasticsearch/data
        - name: config
          mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
          subPath: elasticsearch.yml
      volumes:
      - name: data
        emptyDir: {}
      - name: config
        configMap:
          name: es6-config
          items:
          - key: elasticsearch.yml
            path: elasticsearch.yml
