# Configure ECK to store data on mounted drive

**URL:** <https://discuss.elastic.co/t/configure-eck-to-store-data-on-mounted-drive/361616>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Created:** [June 18, 2024, 5:23am UTC](https://discuss.elastic.co/t/configure-eck-to-store-data-on-mounted-drive/361616 "2024-06-18T05:23:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varun\_Tokas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varun_tokas/32/124452_2.png) [@Varun\_Tokas](https://discuss.elastic.co/u/Varun_Tokas)\
**Post date:** [June 18, 2024, 5:23am UTC](https://discuss.elastic.co/t/configure-eck-to-store-data-on-mounted-drive/361616/1 "2024-06-18T05:23:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BarS](https://avatars.discourse-cdn.com/v4/letter/b/ea5d25/32.png) [@BarS](https://discuss.elastic.co/u/BarS)\
**Post date:** [July 16, 2024, 8:03am UTC](https://discuss.elastic.co/t/configure-eck-to-store-data-on-mounted-drive/361616/2 "2024-07-16T08:03:34Z")

</div>

Hey 👋

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

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

```auto
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 :

```auto
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

```
