# Changing kubernetes storage class for data nodes without data loss

**URL:** https://discuss.elastic.co/t/changing-kubernetes-storage-class-for-data-nodes-without-data-loss/248693
**Category:** Elasticsearch
**Created:** [September 15, 2020, 2:18pm UTC](https://discuss.elastic.co/t/changing-kubernetes-storage-class-for-data-nodes-without-data-loss/248693 "2020-09-15T14:18:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![danksim](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@danksim](https://discuss.elastic.co/u/danksim)
#### Post date: [September 15, 2020, 2:18pm UTC](https://discuss.elastic.co/t/changing-kubernetes-storage-class-for-data-nodes-without-data-loss/248693/1 "2020-09-15T14:18:28Z")

</div>

Elasticsearch version: 7.6.2

```auto
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T23:34:25Z", GoVersion:"go1.14.2", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.11-eks-065dce", GitCommit:"065dcecfcd2a91bd68a17ee0b5e895088430bd05", GitTreeState:"clean", BuildDate:"2020-07-16T01:44:47Z", GoVersion:"go1.12.17", Compiler:"gc", Platform:"linux/amd64"}

```

```auto
$ helm version --tls --tiller-namespace kube-system
Client: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.13.1", GitCommit:"618447cbf203d147601b4b9bd7f8c37a5d39fbb4", GitTreeState:"clean"}

```

I am trying to change the `storageClassName` from `aws-ebs-st1` (HDD) to `aws-ebs-gp2` (SSD) for all data nodes (_note that all coordinator/master nodes are already bound to SSDs_) without data loss and I think it might be possible. Here is my proposal:

1. Delete the `data``statefulset` to rid the `statefulset` contract but keep the pods (the pods will be "[orphaned](https://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/#non-cascading-delete)"):

```auto
kubectl delete statefulset my-elastic-stack-data -n system-logging --cascade=false

```

2. Make a copy of the rendered helm manifest for each of the `data` pods:

```auto
for i in {0..11}; do; kubectl get pod my-elastic-stack-data-$i -n system-logging -oyaml > /tmp/data-$i.yaml; done

```

3. Delete the existing `data-11` pod (HDD):

```auto
kubectl delete pod my-elastic-stack-data-11 -n system-logging

```

4. Delete `pvc` for `data-11` (because the new claim name will be the same):

```auto
kubectl delete pvc my-elastic-stack-data-pvc-11 -n system-logging

```

5. Wait for the remaining 11 pods (not 12, since we have deleted `data-11` ) to rebalance the shards among each other
6. Somehow create new SSD `pv` (and `pvc` ) for `data-11`
7. Create new `data-11` pod (that will now attach to the SSD `pv` / `pvc` created in step 6):

```auto
kubectl -n system-logging apply -f /tmp/data-11.yaml

```

8. Wait for all 11 pods to rebalance the shards
9. Repeat steps 3-8 for all remaining `data ` pods from `data-10` through `data-0`
10. Re-deploy helm chart using the new `storageClass` and the `statefulset` should "adopt" the existing pods if conditions are met:

Would love some advice on this. Thanks in advance!

---

<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: [October 13, 2020, 2:18pm UTC](https://discuss.elastic.co/t/changing-kubernetes-storage-class-for-data-nodes-without-data-loss/248693/2 "2020-10-13T14:18:30Z")

</div>

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