# Deploy Elastic Search with Kubernetes StatefulSet cannot persist the index data

**URL:** <https://discuss.elastic.co/t/deploy-elastic-search-with-kubernetes-statefulset-cannot-persist-the-index-data/126484>\
**Category:** Elasticsearch\
**Created:** [April 3, 2018, 12:45am UTC](https://discuss.elastic.co/t/deploy-elastic-search-with-kubernetes-statefulset-cannot-persist-the-index-data/126484 "2018-04-03T00:45:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bai](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Bai](https://discuss.elastic.co/u/Bai)\
**Post date:** [April 3, 2018, 12:45am UTC](https://discuss.elastic.co/t/deploy-elastic-search-with-kubernetes-statefulset-cannot-persist-the-index-data/126484/1 "2018-04-03T00:45:53Z")

</div>

Hi All,

I'm deploying Elastic Search as StatefulSet in Kubernetes, but cannot make the persistent volume working properly. (Reference: [https://github.com/pires/kubernetes-elasticsearch-cluster/tree/master/stateful](https://github.com/pires/kubernetes-elasticsearch-cluster/tree/master/stateful), I don't create dedicated master, so simply master & data are in one).

I'm testing the persistent volume by:

1. create ES and insert some data;
2. delete and re-create the service;
3. check if the index is still there.

The deployment showed all green, and the Elasticsearch is also working fine. But the data is not persistent if I re-create the ES. Could someone shed some light on this? Thanks!

Attached some stats, and let me know if I need to post other logs.

> kubectl describe pvc

```
Name: storage-elasticsearch-logging-v1-0
Namespace: kube-system
StorageClass: standard
Status: Bound
Volume: pvc-96453dd3-36c9-11e8-9f27-029b836b1aaa
Labels: k8s-app=elasticsearch-logging
               kubernetes.io/cluster-service=true
               version=v1
Annotations: pv.kubernetes.io/bind-completed=yes
               pv.kubernetes.io/bound-by-controller=yes
               volume.beta.kubernetes.io/storage-provisioner=kubernetes.io/aws-ebs
Finalizers: []
Capacity: 2Gi
Access Modes: RWO
Events: <none>

```

> kubectl describe pv

```
Name: pvc-a1825ec9-36c9-11e8-9f27-029b836b1aaa
Labels: failure-domain.beta.kubernetes.io/region=us-west-2
                 failure-domain.beta.kubernetes.io/zone=us-west-2a
Annotations: kubernetes.io/createdby=aws-ebs-dynamic-provisioner
                 pv.kubernetes.io/bound-by-controller=yes
                 pv.kubernetes.io/provisioned-by=kubernetes.io/aws-ebs
StorageClass: standard
Status: Bound
Claim: kube-system/storage-elasticsearch-logging-v1-1
Reclaim Policy: Retain
Access Modes: RWO
Capacity: 2Gi
Message:
Source:
    Type: AWSElasticBlockStore (a Persistent Disk resource in AWS)
    VolumeID: aws://us-west-2a/vol-01aa1c6a2ad2eae3a
    FSType: ext4
    Partition: 0
    ReadOnly: false
Events: <none>

```

> kubectl describe sc standard

```
Name: standard
IsDefaultClass: No
Annotations: <none>
Provisioner: kubernetes.io/aws-ebs
Parameters: type=gp2
ReclaimPolicy: Retain
Events: <none>

```

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [April 6, 2018, 11:16am UTC](https://discuss.elastic.co/t/deploy-elastic-search-with-kubernetes-statefulset-cannot-persist-the-index-data/126484/2 "2018-04-06T11:16:19Z")

</div>

Elasticsearch keeps its data in the [configured data directories](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/path-settings.html). It seems likely that `path.data` isn't pointing to the persistent disk, so it's writing its data somewhere else that is lost when you shut the container down.

---

<div class="post-metadata">

**Author:** ![Bai](https://avatars.discourse-cdn.com/v4/letter/b/76d3ee/32.png) [@Bai](https://discuss.elastic.co/u/Bai)\
**Post date:** [April 6, 2018, 5:15pm UTC](https://discuss.elastic.co/t/deploy-elastic-search-with-kubernetes-statefulset-cannot-persist-the-index-data/126484/3 "2018-04-06T17:15:29Z")

</div>

Thanks David! Indeed that was the case, as we also figured the ES data is stored in "/usr/share/elasticsearch" while we were mounting "/data" folder.

---

<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:** [May 4, 2018, 5:16pm UTC](https://discuss.elastic.co/t/deploy-elastic-search-with-kubernetes-statefulset-cannot-persist-the-index-data/126484/4 "2018-05-04T17:16:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
