# Multiple elasticsearch-data Volumes

**URL:** <https://discuss.elastic.co/t/multiple-elasticsearch-data-volumes/230972>\
**Category:** Elastic Cloud on Kubernetes (ECK)\
**Created:** [May 4, 2020, 1:01pm UTC](https://discuss.elastic.co/t/multiple-elasticsearch-data-volumes/230972 "2020-05-04T13:01:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![taseer94](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@taseer94](https://discuss.elastic.co/u/taseer94)\
**Post date:** [May 4, 2020, 1:01pm UTC](https://discuss.elastic.co/t/multiple-elasticsearch-data-volumes/230972/1 "2020-05-04T13:01:25Z")

</div>

Hi everyone,

I have 3 azure disks which I would like to have the cluster store data to. I want to have a 3 node cluster, each attached to a separate disk. My current config is as follows. However, all the 3 volumes get attached to the first pod and all the rest are left in pending state. Any help will be really appreciated...

My config is as follows

```auto
---
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: quickstart
  namespace: testing
spec:
  version: 7.6.2
  http:
    tls:
      selfSignedCertificate:
        disabled: true
  nodeSets:
  - name: nodes
    count: 3
    config:
      node.master: true
      node.data: true
      node.ingest: true
      node.store.allow_mmap: false
      path:
        data:
          - "/usr/share/elasticsearch/data"
          - "/usr/share/elasticsearch/data1"
          - "/usr/share/elasticsearch/data2"
    podTemplate:
      spec:
        volumes:
          - name: elasticsearch-data
          - name: elasticsearch-data1
          - name: elasticsearch-data2
        containers:
          - name: elasticsearch
            env:
              - name: ES_JAVA_OPTS
                value: "-Xms2g -Xmx2g"
            resources:
              limits:
                cpu: "1"
                memory: 5Gi
              requests:
                cpu: "100m"
                memory: 5Gi
            volumeMounts:
              - name: elasticsearch-data
                mountPath: /usr/share/elasticsearch/data
              - name: elasticsearch-data1
                mountPath: /usr/share/elasticsearch/data1
              - name: elasticsearch-data2
                mountPath: /usr/share/elasticsearch/data2
        initContainers:
          - name: chown-data-volumes
            command: ["sh", "-c", "chown elasticsearch:elasticsearch /usr/share/elasticsearch/data && chown elasticsearch:elasticsearch /usr/share/elasticsearch/data1 && chown elasticsearch:elasticsearch /usr/share/elasticsearch/data2"]
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 256Gi
        storageClassName: standard
    - metadata:
        name: elasticsearch-data1
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 256Gi
        storageClassName: standard
    - metadata:
        name: elasticsearch-data2
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 256Gi
        storageClassName: standard

```

---

<div class="post-metadata">

**Author:** ![sebgl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sebgl/32/48702_2.png) [@sebgl](https://discuss.elastic.co/u/sebgl)\
**Post date:** [May 7, 2020, 8:19am UTC](https://discuss.elastic.co/t/multiple-elasticsearch-data-volumes/230972/2 "2020-05-07T08:19:33Z")

</div>

You can probably inspect the existing PVCs and Pending Pods in your cluster to get more details:  
`kubectl get pvc`  
`kubectl describe pvc <pvc-name>`  
`kubectl describe pod <pending-pod-name>`

I guess something prevents more PVs from being provisioned.

---

<div class="post-metadata">

**Author:** ![taseer94](https://avatars.discourse-cdn.com/v4/letter/t/f9ae1b/32.png) [@taseer94](https://discuss.elastic.co/u/taseer94)\
**Post date:** [May 7, 2020, 9:57am UTC](https://discuss.elastic.co/t/multiple-elasticsearch-data-volumes/230972/3 "2020-05-07T09:57:47Z")

</div>

Hi Sebastian,

Thanks for the reply. I was able to fix the issue myself. The problem was with the way I was creating the persistent volumes. I had to create a Storage Class that was able to take care of dynamic provisioning of volumes. The following config worked for me..

```auto
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
    name: eck-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer

---
apiVersion: v1
kind: PersistentVolume
metadata:
  finalizers:
  - kubernetes.io/pv-protection
  name: elasticsearch-data-a
spec:
  accessModes:
  - ReadWriteOnce
  azureDisk:

---
apiVersion: v1
kind: PersistentVolume
metadata:
  finalizers:
  - kubernetes.io/pv-protection
  name: elasticsearch-data-b
spec:
  accessModes:
  - ReadWriteOnce
  azureDisk:

---
apiVersion: v1
kind: PersistentVolume
metadata:
  finalizers:
  - kubernetes.io/pv-protection
  name: elasticsearch-data-c
spec:
  accessModes:
  - ReadWriteOnce
  azureDisk:
    cachingMode: ReadOnly
    diskName: <your_disk_name>
    diskURI: <disk_uri>

---
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: es-ha-cluster
spec:
  version: 7.6.2
  http:
    tls:
      selfSignedCertificate:
        disabled: true
  nodeSets:
  - name: nodes
    count: 3
    config:
      node.master: true
      node.data: true
      node.ingest: true
      node.store.allow_mmap: false
    podTemplate:
      spec:
        containers:
          - name: elasticsearch
            env:
              - name: ES_JAVA_OPTS
                value: "-Xms2g -Xmx2g"
            resources:
              limits:
                cpu: "1"
                memory: 5Gi
              requests:
                cpu: "100m"
                memory: 5Gi
            volumeMounts:
              - name: elasticsearch-data
                mountPath: /usr/share/elasticsearch/data
        initContainers:
          - name: chown-data-volumes
            command: ["sh", "-c", "chown elasticsearch:elasticsearch /usr/share/elasticsearch/data"]
    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
          - ReadWriteOnce
        resources:
          requests:
            storage: 256Gi
        storageClassName: eck-storage

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 4, 2022, 7:56am UTC](https://discuss.elastic.co/t/multiple-elasticsearch-data-volumes/230972/4 "2022-11-04T07:56:40Z")

</div>


