kind: Deployment
apiVersion: apps/v1
metadata:
  labels:
    app: elasticsearch
    role: master
  name: elasticsearch-master
spec:
  replicas: 1
  selector:
    matchLabels:
      app: elasticsearch
      role: master
  template:
    metadata:
      labels:
        app: elasticsearch
        role: master
    spec:
      containers:
      - name: elasticsearch-master
        image: elasticsearch
        ports:
        - containerPort: 9200
          protocol: TCP
        - containerPort: 9300
          protocol: TCP
        volumeMounts:
        - name: data
          mountPath: /usr/share/elasticsearch/data
        env:
        - name: "cluster.name"
          value: "elasticsearch-cluster"
        - name: "discovery.zen.ping.unicast.hosts"
          value: "elasticsearch-discovery"
        - name: "discovery.zen.minimum_master_nodes"
          value: "1"
        - name: "discovery.zen.ping_timeout"
          value: "5s"
        - name: "node.master"
          value: "true"
        - name: "node.data"
          value: "false"
        - name: "node.ingest"
          value: "false"
        - name: "ES_JAVA_OPTS"
          value: "-Xms256m -Xmx256m"
      initContainers:
      - name: increase-vm-max-map
        image: busybox
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
      volumes:
          - emptyDir: {}
            name: "data"
# ---
# kind: Service
# apiVersion: v1
# metadata:
#   labels:
#     app: elasticsearch
#   name: elasticsearch-discovery
# spec:
#   ports:
#     - port: 9300
#       targetPort: 9300
#   selector:
#     app: elasticsearch
#     role: master

# ---
# apiVersion: apps/v1
# kind: StatefulSet
# metadata:
#   name: elasticsearch-data
# spec:
#   serviceName: elasticsearch
#   replicas: 1
#   selector:
#     matchLabels:
#       app: elasticsearch
#       role: data
#   template:
#     metadata:
#       labels:
#         app: elasticsearch
#         role: data
#     spec:
#       containers:
#       - name: elasticsearch
#         image: elasticsearch
#         ports:
#         - containerPort: 9200
#           protocol: TCP
#         - containerPort: 9300
#           protocol: TCP
#         volumeMounts:
#         - name: data
#           mountPath: /usr/share/elasticsearch/data
#         env:
#         - name: "cluster.name"
#           value: "elasticsearch-cluster"
#         - name: "discovery.zen.ping.unicast.hosts"
#           value: "elasticsearch-discovery"
#         - name: "node.master"
#           value: "false"
#         - name: "node.data"
#           value: "true"
#         - name: "ES_JAVA_OPTS"
#           value: "-Xms256m -Xmx256m"
#       initContainers:
#       - name: increase-vm-max-map
#         image: busybox
#         command: ["sysctl", "-w", "vm.max_map_count=262144"]
#         securityContext:
#           privileged: true

  # volumeClaimTemplates:
  # - metadata:
  #     name: data
  #   spec:
  #     accessModes: [ "ReadWriteOnce" ]
  #     storageClassName: nfs
  #     resources:
  #       requests:
  #         storage: 10Gi