# Making elastic persistence on Kubernetes env

**URL:** <https://discuss.elastic.co/t/making-elastic-persistence-on-kubernetes-env/293666>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [January 6, 2022, 3:27pm UTC](https://discuss.elastic.co/t/making-elastic-persistence-on-kubernetes-env/293666 "2022-01-06T15:27:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bargb](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@bargb](https://discuss.elastic.co/u/bargb)\
**Post date:** [January 6, 2022, 3:27pm UTC](https://discuss.elastic.co/t/making-elastic-persistence-on-kubernetes-env/293666/1 "2022-01-06T15:27:16Z")

</div>

Hi..

I am running elastic on kubernetes cluster. My Yaml is as below but this is not persisting the data after elastic restarts. What should i do to persist it

```auto
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: elasticsearch-volume
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: "standard-nfs"
  resources:
    requests:
      storage: 8Gi
-----------------
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: elasticsearch
  namespace: bb
  labels:
    k8s-app: elasticsearch
spec:
  serviceName: elasticsearch
  replicas: 1
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      k8s-app: elasticsearch
  template:
    metadata:
      labels:
        k8s-app: elasticsearch
    spec:
      containers:
      - image: elasticsearch:7.10.1
        name: elasticsearch
        ports:
        - containerPort: 9200
          name: db
          protocol: TCP
        - containerPort: 9300
          name: transport
          protocol: TCP
        volumeMounts:
        - name: elasticsearch
          mountPath: /data
      volumes:
      - name: elasticsearch
        persistentVolumeClaim:
          claimName: elasticsearch-volume
---
apiVersion: v1
kind: Service
metadata:
  name: elasticsearch
  namespace: bb
  labels:
    k8s-app: elasticsearch
spec:
  ports:
  - port: 9200
    protocol: TCP
    targetPort: db
  selector:
    k8s-app: elasticsearch

```

---

<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:** [February 3, 2022, 3:27pm UTC](https://discuss.elastic.co/t/making-elastic-persistence-on-kubernetes-env/293666/2 "2022-02-03T15:27:19Z")

</div>

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