apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: elasticsearch
  labels:
    app: onify
    tier: persistance
spec:
  serviceName: elasticsearch
  replicas: 1
  selector:
    matchLabels:
      app: onify
      tier: persistance
  template:
    metadata:
      labels:
        app: onify
        tier: persistance
        service: elasticsearch
    spec:
      containers:
      - name: elasticsearch
        resources:
          requests:
            memory: "1000Mi"
          limits:
            memory: "2000Mi"
        image: elasticsearch:7.16.1
        env:
        - name: ES_JAVA_OPTS
          value: -Xms1g -Xmx1g 
        - name: discovery.type
          value: single-node
        - name: cluster.name
          value: onify
        ports:
        - containerPort: 9200
          name: client
        - containerPort: 9300
          name: nodes
        volumeMounts:
        - name: data
          mountPath: /usr/share/elasticsearch/data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: onify-elasticsearch-pvc