apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    role: elasticsearch
    name: elasticsearch
    service: logging
  name: elasticsearch
spec:
  selector:
    matchLabels:
      role: elasticsearch
  replicas: 1
  template:
    metadata:
      labels:
        role: elasticsearch
        name: elasticsearch
        service: logging
    spec:
#      initContainers:
#        - name: init-sysctl
#          image: busybox
#          imagePullPolicy: IfNotPresent
#          command: ["sysctl", "-w", "vm.max_map_count=262144"]
#          securityContext:
#            privileged: true
      containers:
        - name: elasticsearch
          image: docker.elastic.co/elasticsearch/elasticsearch:7.10.2
          securityContext:
            privileged: false
            capabilities:
              add:
                - IPC_LOCK
                - SYS_RESOURCE
          ports:
            - containerPort: 9200
            - containerPort: 9300
          env:
            - name: ES_JAVA_OPTS
              value: "-Xmx256m -Xms256m"
            - name: ELASTIC_PASSWORD
              value: "changeme"
            - name: DISCOVERY_TYPE
              value: "single-node"
            - name: discovery.type
              value: "single-node"
          volumeMounts:
            - name: config-volume
              mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
              subPath: elasticsearch.yml

      volumes:
        - name: config-volume
          configMap:
            name: elasticsearch-config