Configure ECK to store data on mounted drive

I'm setting up an Elasticsearch cluster using Kubernetes on 4 nodes. Each node has a mounted drive that I want to use for Elasticsearch storage instead of the host volume. I know that in each container that runs Elasticsearch there is an data directory where the indices are stored. What I want to do is to make the underlying storage of this data directory in the container map to the drive that I have mounted. So basically I want to solve the following problems

  • Can I use hostPath type mounts with Elasticsearch? In that case I will configure Elasticsearch Pods to use my drive as the storage for the path.data
  • How do PVCs work in Elasticsearch? Can I use those to to achieve similar behaviour as I want?

Hey :wave:

I hope it can help you (maybe too late)
Yes and Yes :smiley:

First Yes : Yes you can use a hostPath but It is not necessarily a sustainable solution to use a HostPath.
Second Yes : I recommend you to use StorageClass to deal this problem

For the first Yes, you can try something like this (it's in yaml) :
Exemple with 1 node Elasticsearch cluster

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: elasticsearch-p
spec:
  version: 8.13.2
  nodeSets:
  - name: intg
    count: 1
    config:
      node.roles: [ "master", "data", "ingest" ]
      node.store.allow_mmap: false
      xpack.security.enabled: true
      xpack.security.authc.api_key.enabled: true
    podTemplate:
      spec:
        containers:
        - name: elasticsearch
          volumeMounts:
          - mountPath: /usr/share/elasticsearch/data
            name: elasticsearch-data

For second yes :

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: elasticsearch-p
spec:
  version: 8.13.2
  nodeSets:
  - name: intg
    count: 1
    config:
      node.roles: [ "master", "data" ,"ingest" ]
      node.store.allow_mmap: false
      xpack.security.enabled: true
      xpack.security.authc.api_key.enabled: true
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        storageClassName: dev-default-storageclass
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi