apiVersion: apps/v1
kind: Deployment
metadata:
  name: elasticsearch
  namespace: bitbucket
  labels:
    app: elasticsearch
spec:
  replicas: 1
  selector:
    matchLabels:
      app: elasticsearch
  template:
    metadata:
      labels:
        app: elasticsearch
    spec:
      serviceAccountName: elasticsearch
      initContainers:
        - name: sysctl
          image: busybox
          imagePullPolicy: IfNotPresent
          command: ["sysctl", "-w", "vm.max_map_count=262144"]
          securityContext:
            privileged: true
      containers:
        - name: elasticsearch
          image: elasticsearch:5.6.14-alpine
          securityContext:
            privileged: true
            capabilities:
              add:
                - IPC_LOCK
                - SYS_RESOURCE
          ports:
            - name: http
              containerPort: 9200
          resources:
            limits:
              memory: 3Gi
              cpu: 1
            requests:
              memory: 3Gi
              cpu: 200m
          livenessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 30
            timeoutSeconds: 1
            periodSeconds: 5
          readinessProbe:
            httpGet:
              path: /
              port: http
            initialDelaySeconds: 5
            timeoutSeconds: 1
            periodSeconds: 5
          volumeMounts:
            - name: data
              mountPath: /usr/share/elasticsearch/data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: elasticsearch
