apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: logging
  name: elasticsearch-master
  labels:
    app: elasticsearch
    role: master
spec:
  replicas: 3
  selector:
    matchLabels:
      app: elasticsearch
      role: master
  template:
    metadata:
      labels:
        app: elasticsearch
        role: master
    spec:
      initContainers:
      - command:
        - /sbin/sysctl
        - -w
        - vm.max_map_count=262144
        image: alpine:3.6
        imagePullPolicy: IfNotPresent
        name: sysctl
        securityContext:
          privileged: true
      containers:
      - env:
        - name: ES_JAVA_OPTS
          value: -Xms512m -Xmx512m
        - name: discovery.zen.ping.unicast.hosts
          value: "elasticsearch-discovery.logging.svc.cluster.local,elasticsearch-logging.logging.svc.cluster.local"
        - name: discovery.zen.minimum_master_nodes
          value: "2"
        - name: node.master
          value: "true"
        - name: node.ingest
          value: "false"
        - name: node.data
          value: "false"
        - name: search.remote.connect
          value: "false"
        - name: cluster.name
          value: "k8scloud"
        - name: node.name
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.2
        imagePullPolicy: IfNotPresent
        name: elasticsearch-master
        ports:
        - containerPort: 9200
          name: http
          protocol: TCP
        - containerPort: 9300
          name: transport
          protocol: TCP
        resources:
          limits:
            cpu: "1"
            memory: 2Gi
          requests:
            cpu: 100m
            memory: 520Mi
        volumeMounts:
        - mountPath: /data
          name: elasticsearch-data
      tolerations:
      - effect: NoSchedule
        key: node-role.kubernetes.io/master
      - key: CriticalAddonsOnly
        operator: Exists
      volumes:
      - name: elasticsearch-data
        emptyDir:
          medium: ""

