apiVersion: apps/v1
kind: Deployment
metadata:
  name: es-master
spec:
  minReadySeconds: 60
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
  selector:
    matchLabels:
      application: es-master
  replicas: 1
  template:
    metadata:
      labels:
        application: es-master
    spec:
      serviceAccountName: operator
      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
      containers:
      - name: elasticsearch
        image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.6.1
        env:
        - name: ES_JAVA_OPTS
          value: "-Xms256m -Xmx256m"
        - name: node.master
          value: "true"
        - name: node.data
          value: "false"
        resources:
          requests:
            memory: 512Mi
            cpu: 100m
          limits:
            memory: 512Mi
            cpu: 100m
        ports:
        - containerPort: 9300
          name: transport
        readinessProbe:
          tcpSocket:
            port: 9200
          initialDelaySeconds: 20
        livenessProbe:
          tcpSocket:
            port: transport
        volumeMounts:
        - name: es-data
          mountPath: /usr/share/elasticsearch/data
        - name: elasticsearch-config
          mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
          subPath: elasticsearch.yml
      volumes:
      - name: es-data
        emptyDir: {}
      - name: elasticsearch-config
        configMap:
          name: es-config
          items:
          - key: elasticsearch.yml
            path: elasticsearch.yml
