apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: elasticsearch
  namespace: heliumevents
spec:
  serviceName: elasticsearch-service
  replicas: 1
  selector:
    matchLabels:
      app: elasticsearch
      version: v1
  template:
    metadata:
      labels:
        app: elasticsearch
        version: v1
    spec:
      containers:
        - name: elasticsearch
          env:
            - name: ES_JAVA_OPTS
              value: "-Xmx1024m"
            - name: "discovery.type"
              value: "single-node"
          image: elasticsearch:7.14.2
          imagePullPolicy: IfNotPresent
          resources:
            requests:
              cpu: "100m"
              memory: "512Mi"
            limits:
              cpu: "4000m"
              memory: "2048Mi"
          ports:
            - containerPort: 9200
              name: api
            - containerPort: 9300
              name: other
          livenessProbe:
            httpGet:
              port: 9200
              path: /_cluster/health
            initialDelaySeconds: 40
            periodSeconds: 10
          readinessProbe:
            httpGet:
              port: 9200
              path: /_cluster/health
          startupProbe:
            tcpSocket:
              port: 9300
            initialDelaySeconds: 120
            timeoutSeconds: 2
            failureThreshold: 10
            periodSeconds: 10
          volumeMounts:
          - name: heliumevents-data
            mountPath: /usr/share/elasticsearch/data
          - name: elasticsearch-config
            mountPath: /usr/share/elasticsearch/config/
      volumes:
      - name: heliumevents-data
        persistentVolumeClaim:
          claimName: heliumevents-data
      - name: elasticsearch-config
        persistentVolumeClaim:
          claimName: heliumevents-config
