apiVersion: apps/v1
kind: Deployment
metadata:
  name: es-master
  labels:
    role: master
    app: elasticsearch
spec:
  replicas: 2
  selector:
    matchLabels:
      role: master
      app: elasticsearch
  template:
    metadata:
      labels:
        role: master
        app: elasticsearch
    spec:
      serviceAccount: elasticsearch
      initContainers:
        - name: init-sysctl
          image: busybox:1.27.2
          command:
            - sysctl
            - -w
            - vm.max_map_count=262144
          securityContext:
            privileged: true
      containers:
        - name: es-master
          image: quay.io/pires/docker-elasticsearch-kubernetes:6.2.3
          env:
            - name: KUBERNETES_CA_CERTIFICATE_FILE
              value: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
            - name: NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            - name: NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: CLUSTER_NAME
              value: "cota-k8s"
            - name: NUMBER_OF_MASTERS
              value: "2"
            - name: NODE_MASTER
              value: "true"
            - name: NODE_INGEST
              value: "false"
            - name: NODE_DATA
              value: "false"
            - name: HTTP_ENABLE
              value: "false"
            - name: ES_JAVA_OPTS
              value: -Xms256m -Xmx256m
          ports:
            - containerPort: 9300
              name: transport
              protocol: TCP
          livenessProbe:
            tcpSocket:
              port: transport
